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/keyed_service/content/browser_context_keyed_service_factory.h" 10 11namespace extensions { 12 13class NetworkingPrivateEventRouter; 14 15// This is a factory class used by the BrowserContextDependencyManager 16// to instantiate the networking event router per profile (since the extension 17// event router is per profile). 18class NetworkingPrivateEventRouterFactory 19 : public BrowserContextKeyedServiceFactory { 20 public: 21 // Returns the NetworkingPrivateEventRouter for |profile|, creating it if 22 // it is not yet created. 23 static NetworkingPrivateEventRouter* GetForProfile( 24 content::BrowserContext* context); 25 26 // Returns the NetworkingPrivateEventRouterFactory instance. 27 static NetworkingPrivateEventRouterFactory* GetInstance(); 28 29 protected: 30 // BrowserContextKeyedBaseFactory overrides: 31 virtual content::BrowserContext* GetBrowserContextToUse( 32 content::BrowserContext* context) const OVERRIDE; 33 virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE; 34 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE; 35 36 private: 37 friend struct DefaultSingletonTraits<NetworkingPrivateEventRouterFactory>; 38 39 NetworkingPrivateEventRouterFactory(); 40 virtual ~NetworkingPrivateEventRouterFactory(); 41 42 // BrowserContextKeyedServiceFactory: 43 virtual KeyedService* BuildServiceInstanceFor( 44 content::BrowserContext* profile) const OVERRIDE; 45 46 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateEventRouterFactory); 47}; 48 49} // namespace extensions 50 51#endif // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_EVENT_ROUTER_FACTORY_H_ 52