OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_DEPENDENCY_MANAGER_H_ | 5 #ifndef COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_DEPENDENCY_MANAGER_H_ |
6 #define COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_DEPENDENCY_MANAGER_H_ | 6 #define COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_DEPENDENCY_MANAGER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 // Registers a |callback| that will be called just before executing | 62 // Registers a |callback| that will be called just before executing |
63 // CreateBrowserContextServices() or CreateBrowserContextServicesForTest(). | 63 // CreateBrowserContextServices() or CreateBrowserContextServicesForTest(). |
64 // This can be useful in browser tests which wish to substitute test or mock | 64 // This can be useful in browser tests which wish to substitute test or mock |
65 // builders for the keyed services. | 65 // builders for the keyed services. |
66 std::unique_ptr< | 66 std::unique_ptr< |
67 base::CallbackList<void(content::BrowserContext*)>::Subscription> | 67 base::CallbackList<void(content::BrowserContext*)>::Subscription> |
68 RegisterWillCreateBrowserContextServicesCallbackForTesting( | 68 RegisterWillCreateBrowserContextServicesCallbackForTesting( |
69 const base::Callback<void(content::BrowserContext*)>& callback); | 69 const base::Callback<void(content::BrowserContext*)>& callback); |
70 | 70 |
71 #ifndef NDEBUG | 71 // Runtime assertion called as a part of GetServiceForBrowserContext() to |
72 // Debugging assertion called as part of GetServiceForBrowserContext in debug | 72 // check if |context| is considered stale. This will NOTREACHED() or |
73 // mode. This will NOTREACHED() whenever the user is trying to access a stale | 73 // base::debug::DumpWithoutCrashing() depending on the DCHECK_IS_ON() value. |
74 // BrowserContext*. | 74 void AssertBrowserContextWasntDestroyed( |
75 void AssertBrowserContextWasntDestroyed(content::BrowserContext* context); | 75 content::BrowserContext* context) const; |
76 | 76 |
77 // Marks |context| as live (i.e., not stale). This method can be called as a | 77 // Marks |context| as live (i.e., not stale). This method can be called as a |
78 // safeguard against |AssertBrowserContextWasntDestroyed()| checks going off | 78 // safeguard against |AssertBrowserContextWasntDestroyed()| checks going off |
79 // due to |context| aliasing a BrowserContext instance from a prior test | 79 // due to |context| aliasing a BrowserContext instance from a prior |
80 // (i.e., 0xWhatever might be created, be destroyed, and then a new | 80 // construction (i.e., 0xWhatever might be created, be destroyed, and then a |
81 // BrowserContext object might be created at 0xWhatever). | 81 // new BrowserContext object might be created at 0xWhatever). |
82 void MarkBrowserContextLiveForTesting(content::BrowserContext* context); | 82 void MarkBrowserContextLive(content::BrowserContext* context); |
83 #endif // NDEBUG | |
84 | 83 |
85 static BrowserContextDependencyManager* GetInstance(); | 84 static BrowserContextDependencyManager* GetInstance(); |
86 | 85 |
87 private: | 86 private: |
88 friend class BrowserContextDependencyManagerUnittests; | 87 friend class BrowserContextDependencyManagerUnittests; |
89 friend struct base::DefaultSingletonTraits<BrowserContextDependencyManager>; | 88 friend struct base::DefaultSingletonTraits<BrowserContextDependencyManager>; |
90 | 89 |
91 // Helper function used by CreateBrowserContextServices[ForTest]. | 90 // Helper function used by CreateBrowserContextServices[ForTest]. |
92 void DoCreateBrowserContextServices(content::BrowserContext* context, | 91 void DoCreateBrowserContextServices(content::BrowserContext* context, |
93 bool is_testing_context); | 92 bool is_testing_context); |
94 | 93 |
95 BrowserContextDependencyManager(); | 94 BrowserContextDependencyManager(); |
96 ~BrowserContextDependencyManager() override; | 95 ~BrowserContextDependencyManager() override; |
97 | 96 |
98 #ifndef NDEBUG | 97 #ifndef NDEBUG |
99 // DependencyManager: | 98 // DependencyManager: |
100 void DumpContextDependencies(base::SupportsUserData* context) const final; | 99 void DumpContextDependencies(base::SupportsUserData* context) const final; |
101 #endif // NDEBUG | 100 #endif // NDEBUG |
102 | 101 |
103 // A list of callbacks to call just before executing | 102 // A list of callbacks to call just before executing |
104 // CreateBrowserContextServices() or CreateBrowserContextServicesForTest(). | 103 // CreateBrowserContextServices() or CreateBrowserContextServicesForTest(). |
105 base::CallbackList<void(content::BrowserContext*)> | 104 base::CallbackList<void(content::BrowserContext*)> |
106 will_create_browser_context_services_callbacks_; | 105 will_create_browser_context_services_callbacks_; |
107 }; | 106 }; |
108 | 107 |
109 #endif // COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_DEPENDENCY_MANAGER_H
_ | 108 #endif // COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_DEPENDENCY_MANAGER_H
_ |
OLD | NEW |