12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_FACTORY_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_FACTORY_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/singleton.h"
9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class GAIAInfoUpdateService;
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Profile;
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
14c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace user_prefs {
15c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class PrefRegistrySyncable;
16c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
17c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Singleton that owns all GAIAInfoUpdateServices and associates them with
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Profiles. Listens for the Profile's destruction notification and cleans up
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// the associated GAIAInfoUpdateService.
2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class GAIAInfoUpdateServiceFactory : public BrowserContextKeyedServiceFactory {
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns the instance of GAIAInfoUpdateService associated with this profile
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // (creating one if none exists). Returns NULL if this profile cannot have a
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // GAIAInfoUpdateService (for example, if |profile| is incognito).
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static GAIAInfoUpdateService* GetForProfile(Profile* profile);
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns an instance of the GAIAInfoUpdateServiceFactory singleton.
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static GAIAInfoUpdateServiceFactory* GetInstance();
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  friend struct DefaultSingletonTraits<GAIAInfoUpdateServiceFactory>;
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GAIAInfoUpdateServiceFactory();
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~GAIAInfoUpdateServiceFactory();
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // BrowserContextKeyedServiceFactory:
38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual KeyedService* BuildServiceInstanceFor(
39c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      content::BrowserContext* context) const OVERRIDE;
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
417dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  virtual void RegisterProfilePrefs(
42c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(GAIAInfoUpdateServiceFactory);
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CHROME_BROWSER_PROFILES_GAIA_INFO_UPDATE_SERVICE_FACTORY_H_
49