Home | History | Annotate | Download | only in networking_private
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_EVENT_ROUTER_FACTORY_H_
      6 #define CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_EVENT_ROUTER_FACTORY_H_
      7 
      8 #include "base/memory/singleton.h"
      9 #include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
     10 
     11 class Profile;
     12 
     13 namespace chromeos {
     14 
     15 class NetworkingPrivateEventRouter;
     16 
     17 // This is a factory class used by the BrowserContextDependencyManager
     18 // to instantiate the networking event router per profile (since the extension
     19 // event router is per profile).
     20 class NetworkingPrivateEventRouterFactory
     21     : public BrowserContextKeyedServiceFactory {
     22  public:
     23   // Returns the NetworkingPrivateEventRouter for |profile|, creating it if
     24   // it is not yet created.
     25   static NetworkingPrivateEventRouter* GetForProfile(Profile* profile);
     26 
     27   // Returns the NetworkingPrivateEventRouterFactory instance.
     28   static NetworkingPrivateEventRouterFactory* GetInstance();
     29 
     30  protected:
     31   // BrowserContextKeyedBaseFactory overrides:
     32   virtual content::BrowserContext* GetBrowserContextToUse(
     33       content::BrowserContext* context) const OVERRIDE;
     34   virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE;
     35   virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
     36 
     37  private:
     38   friend struct DefaultSingletonTraits<NetworkingPrivateEventRouterFactory>;
     39 
     40   NetworkingPrivateEventRouterFactory();
     41   virtual ~NetworkingPrivateEventRouterFactory();
     42 
     43   // BrowserContextKeyedServiceFactory:
     44   virtual BrowserContextKeyedService* BuildServiceInstanceFor(
     45       content::BrowserContext* profile) const OVERRIDE;
     46 
     47   DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateEventRouterFactory);
     48 };
     49 
     50 }  // namespace chromeos
     51 
     52 #endif  // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_EVENT_ROUTER_FACTORY_H_
     53 
     54