chromium/extensions/browser/browser_context_keyed_api_factory.h

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_
#define EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_

#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/keyed_service/core/keyed_service.h"
#include "extensions/browser/extension_system_provider.h"
#include "extensions/browser/extensions_browser_client.h"

namespace extensions {

template <typename T>
class BrowserContextKeyedAPIFactory;

// Instantiations of BrowserContextKeyedAPIFactory should use this base class
// and also define a static const char* service_name() function (used in the
// BrowserContextKeyedServiceFactory constructor). These fields should
// be accessible to the BrowserContextKeyedAPIFactory for the service.
class BrowserContextKeyedAPI : public KeyedService {};

// Declare dependencies on other factories.
// By default, ExtensionSystemFactory is the only dependency; however,
// specializations can override this. Declare your specialization in
// your header file after the BrowserContextKeyedAPI class definition.
// Declare this struct in the header file. The implementation may optionally
// be placed in your .cc file.
// This method should be used instead of
// BrowserContextKeyedAPIFactory<T>::DeclareFactoryDependencies() because it
// permits partial specialization, as in the case of ApiResourceManager<T>.
//
//   template <>
//   struct BrowserContextFactoryDependencies<MyService> {
//     static void DeclareFactoryDependencies(
//         BrowserContextKeyedAPIFactory<ApiResourceManager<T>>* factory) {
//       factory->DependsOn(
//           ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
//       factory->DependsOn(SyncServiceFactory::GetInstance());
//       ...
//     }
//   };
template <typename T>
struct BrowserContextFactoryDependencies {};

// A template for factories for KeyedServices that manage extension APIs. T is
// a KeyedService that uses this factory template instead of its own separate
// factory definition to manage its per-profile instances.
template <typename T>
class BrowserContextKeyedAPIFactory : public BrowserContextKeyedServiceFactory {};

}  // namespace extensions

#endif  // EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_