OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_DEPENDENCY_MANA GER_H_ | 5 #ifndef COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_DEPENDENCY_MANA GER_H_ |
6 #define COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_DEPENDENCY_MANA GER_H_ | 6 #define COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_DEPENDENCY_MANA GER_H_ |
7 | 7 |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "components/browser_context_keyed_service/browser_context_keyed_service _export.h" | 9 #include "components/browser_context_keyed_service/browser_context_keyed_service _export.h" |
10 #include "components/browser_context_keyed_service/dependency_graph.h" | 10 #include "components/browser_context_keyed_service/dependency_graph.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 // Adds/Removes a component from our list of live components. Removing will | 27 // Adds/Removes a component from our list of live components. Removing will |
28 // also remove live dependency links. | 28 // also remove live dependency links. |
29 void AddComponent(BrowserContextKeyedBaseFactory* component); | 29 void AddComponent(BrowserContextKeyedBaseFactory* component); |
30 void RemoveComponent(BrowserContextKeyedBaseFactory* component); | 30 void RemoveComponent(BrowserContextKeyedBaseFactory* component); |
31 | 31 |
32 // Adds a dependency between two factories. | 32 // Adds a dependency between two factories. |
33 void AddEdge(BrowserContextKeyedBaseFactory* depended, | 33 void AddEdge(BrowserContextKeyedBaseFactory* depended, |
34 BrowserContextKeyedBaseFactory* dependee); | 34 BrowserContextKeyedBaseFactory* dependee); |
35 | 35 |
36 // Called by each BrowserContext to alert us of its creation. Several services | 36 // Called by each BrowserContext to alert us of its creation. Several services |
37 // want to be started when a context is created. Testing configuration is also | 37 // want to be started when a context is created. If you want your |
38 // done at this time. (If you want your BrowserContextKeyedService to be | 38 // BrowserContextKeyedService to be started with the BrowserContext, override |
39 // started with the BrowserContext, override BrowserContextKeyedBaseFactory:: | 39 // BrowserContextKeyedBaseFactory::ServiceIsCreatedWithBrowserContext() to |
40 // ServiceIsCreatedWithBrowserContext() to return true.) | 40 // return true. This method also registers any service-related preferences |
41 void CreateBrowserContextServices(content::BrowserContext* context, | 41 // for non-incognito profiles. |
42 bool is_testing_context); | 42 void CreateBrowserContextServices(content::BrowserContext* context); |
43 | |
44 // Similar to CreateBrowserContextServices(), except this is used for creating | |
45 // test BrowserContexts - these contexts will not create services for any | |
46 // BrowserContextKeyedBaseFactories that return true from | |
47 // ServiceIsNULLWhileTesting(). Callers can pass |force_register_prefs| as | |
48 // true to have preferences registered even for incognito profiles - this | |
49 // allows tests to specify a standalone incognito profile without an | |
50 // associated normal profile. | |
51 void CreateBrowserContextServicesForTest(content::BrowserContext* context, | |
52 bool force_register_prefs); | |
43 | 53 |
44 // Called by each BrowserContext to alert us that we should destroy services | 54 // Called by each BrowserContext to alert us that we should destroy services |
45 // associated with it. | 55 // associated with it. |
46 void DestroyBrowserContextServices(content::BrowserContext* context); | 56 void DestroyBrowserContextServices(content::BrowserContext* context); |
47 | 57 |
48 #ifndef NDEBUG | 58 #ifndef NDEBUG |
49 // Debugging assertion called as part of GetServiceForBrowserContext in debug | 59 // Debugging assertion called as part of GetServiceForBrowserContext in debug |
50 // mode. This will NOTREACHED() whenever the user is trying to access a stale | 60 // mode. This will NOTREACHED() whenever the user is trying to access a stale |
51 // BrowserContext*. | 61 // BrowserContext*. |
52 void AssertBrowserContextWasntDestroyed(content::BrowserContext* context); | 62 void AssertBrowserContextWasntDestroyed(content::BrowserContext* context); |
53 #endif | 63 #endif |
54 | 64 |
55 static BrowserContextDependencyManager* GetInstance(); | 65 static BrowserContextDependencyManager* GetInstance(); |
56 | 66 |
57 private: | 67 private: |
58 friend class BrowserContextDependencyManagerUnittests; | 68 friend class BrowserContextDependencyManagerUnittests; |
59 friend struct DefaultSingletonTraits<BrowserContextDependencyManager>; | 69 friend struct DefaultSingletonTraits<BrowserContextDependencyManager>; |
60 | 70 |
71 // Helper function used by CreateBrowserContextServices[ForTest]. | |
72 void DoCreateBrowserContextServices(content::BrowserContext* context, | |
73 bool is_testing_context, | |
74 bool force_register_prefs); | |
75 | |
Mattias Nissler (ping if slow)
2013/08/19 14:03:22
nit: remove extra blank line
Andrew T Wilson (Slow)
2013/08/20 09:28:35
Done.
| |
76 | |
61 BrowserContextDependencyManager(); | 77 BrowserContextDependencyManager(); |
62 virtual ~BrowserContextDependencyManager(); | 78 virtual ~BrowserContextDependencyManager(); |
63 | 79 |
64 #ifndef NDEBUG | 80 #ifndef NDEBUG |
65 void DumpBrowserContextDependencies(content::BrowserContext* context); | 81 void DumpBrowserContextDependencies(content::BrowserContext* context); |
66 #endif | 82 #endif |
67 | 83 |
68 DependencyGraph dependency_graph_; | 84 DependencyGraph dependency_graph_; |
69 | 85 |
70 #ifndef NDEBUG | 86 #ifndef NDEBUG |
71 // A list of context objects that have gone through the Shutdown() | 87 // A list of context objects that have gone through the Shutdown() |
72 // phase. These pointers are most likely invalid, but we keep track of their | 88 // phase. These pointers are most likely invalid, but we keep track of their |
73 // locations in memory so we can nicely assert if we're asked to do anything | 89 // locations in memory so we can nicely assert if we're asked to do anything |
74 // with them. | 90 // with them. |
75 std::set<content::BrowserContext*> dead_context_pointers_; | 91 std::set<content::BrowserContext*> dead_context_pointers_; |
76 #endif | 92 #endif |
77 }; | 93 }; |
78 | 94 |
79 #endif // COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_DEPENDENCY_M ANAGER_H_ | 95 #endif // COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_DEPENDENCY_M ANAGER_H_ |
OLD | NEW |