Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / policy / schema_registry_service_factory.h
blob4b33df9e245173c0ee87bd936858b3b09dabec6f
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.
5 #ifndef CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_SERVICE_FACTORY_H_
8 #include <map>
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/singleton.h"
14 #include "components/keyed_service/content/browser_context_keyed_base_factory.h"
16 namespace content {
17 class BrowserContext;
20 namespace policy {
22 class CombinedSchemaRegistry;
23 class Schema;
24 class SchemaRegistryService;
26 // Creates SchemaRegistryServices for BrowserContexts.
27 // TODO(joaodasilva): Convert this class to a proper BCKS once the PrefService
28 // becomes a BCKS too. For now the PrefService depends on the
29 // UserCloudPolicyManager, which depends on this.
30 class SchemaRegistryServiceFactory : public BrowserContextKeyedBaseFactory {
31 public:
32 // Returns the SchemaRegistryServiceFactory singleton.
33 static SchemaRegistryServiceFactory* GetInstance();
35 // Returns the SchemaRegistryService associated with |context|. This is only
36 // valid before |context| is shut down.
37 static SchemaRegistryService* GetForContext(content::BrowserContext* context);
39 // Creates a new SchemaRegistryService for |context|, which must be managed
40 // by the caller. Subsequent calls to GetForContext() will return the instance
41 // created, as long as it lives.
42 static scoped_ptr<SchemaRegistryService> CreateForContext(
43 content::BrowserContext* context,
44 const Schema& chrome_schema,
45 CombinedSchemaRegistry* global_registry);
47 private:
48 friend struct DefaultSingletonTraits<SchemaRegistryServiceFactory>;
50 SchemaRegistryServiceFactory();
51 ~SchemaRegistryServiceFactory() override;
53 SchemaRegistryService* GetForContextInternal(
54 content::BrowserContext* context);
56 scoped_ptr<SchemaRegistryService> CreateForContextInternal(
57 content::BrowserContext* context,
58 const Schema& chrome_schema,
59 CombinedSchemaRegistry* global_registry);
61 // BrowserContextKeyedBaseFactory:
62 void BrowserContextShutdown(content::BrowserContext* context) override;
63 void BrowserContextDestroyed(content::BrowserContext* context) override;
64 void SetEmptyTestingFactory(content::BrowserContext* context) override;
65 bool HasTestingFactory(content::BrowserContext* context) override;
66 void CreateServiceNow(content::BrowserContext* context) override;
68 typedef std::map<content::BrowserContext*, SchemaRegistryService*>
69 RegistryMap;
70 RegistryMap registries_;
72 DISALLOW_COPY_AND_ASSIGN(SchemaRegistryServiceFactory);
75 } // namespace policy
77 #endif // CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_SERVICE_FACTORY_H_