service_factory.h revision cedac228d2dd51db4b79ea1e72c7f249408ee061
1// Copyright 2014 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_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_FACTORY_H_ 6#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_FACTORY_H_ 7 8#include <map> 9#include <string> 10#include <vector> 11 12#include "base/memory/singleton.h" 13#include "components/keyed_service/content/browser_context_keyed_service_factory.h" 14#include "content/public/browser/browser_context.h" 15 16namespace chromeos { 17namespace file_system_provider { 18 19class Service; 20 21// Creates services per profile. 22class ServiceFactory : public BrowserContextKeyedServiceFactory { 23 public: 24 // Returns a service instance singleton, after creating it (if necessary). 25 static Service* Get(content::BrowserContext* context); 26 27 // Returns a service instance for the context if exists. Otherwise, returns 28 // NULL. 29 static Service* FindExisting(content::BrowserContext* context); 30 31 // Gets a singleton instance of the factory. 32 static ServiceFactory* GetInstance(); 33 34 private: 35 friend struct DefaultSingletonTraits<ServiceFactory>; 36 37 ServiceFactory(); 38 virtual ~ServiceFactory(); 39 40 // BrowserContextKeyedServiceFactory overrides: 41 virtual KeyedService* BuildServiceInstanceFor( 42 content::BrowserContext* profile) const OVERRIDE; 43 virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE; 44 45 DISALLOW_COPY_AND_ASSIGN(ServiceFactory); 46}; 47 48} // namespace file_system_provider 49} // namespace chromeos 50 51#endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_FACTORY_H_ 52