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_IOS_BROWSER_STATE_DEPENDENCY_MANAGER_H_ | 5 #ifndef COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_DEPENDENCY_MANAGER_H_ |
6 #define COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_DEPENDENCY_MANAGER_H_ | 6 #define COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_DEPENDENCY_MANAGER_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/callback_list.h" | 9 #include "base/callback_list.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // Similar to CreateBrowserStateServices(), except this is used for creating | 49 // Similar to CreateBrowserStateServices(), except this is used for creating |
50 // test BrowserStates - these contexts will not create services for any | 50 // test BrowserStates - these contexts will not create services for any |
51 // BrowserStateKeyedBaseFactories that return true from | 51 // BrowserStateKeyedBaseFactories that return true from |
52 // ServiceIsNULLWhileTesting(). | 52 // ServiceIsNULLWhileTesting(). |
53 void CreateBrowserStateServicesForTest(web::BrowserState* context); | 53 void CreateBrowserStateServicesForTest(web::BrowserState* context); |
54 | 54 |
55 // Called by each BrowserState to alert us that we should destroy services | 55 // Called by each BrowserState to alert us that we should destroy services |
56 // associated with it. | 56 // associated with it. |
57 void DestroyBrowserStateServices(web::BrowserState* context); | 57 void DestroyBrowserStateServices(web::BrowserState* context); |
58 | 58 |
59 #ifndef NDEBUG | 59 // Runtime assertion called as a part of GetServiceForBrowserState() to check |
60 // Debugging assertion called as part of GetServiceForBrowserState in debug | 60 // if |context| is considered stale. This will NOTREACHED() or |
61 // mode. This will NOTREACHED() whenever the user is trying to access a stale | 61 // base::debug::DumpWithoutCrashing() depending on the DCHECK_IS_ON() value. |
62 // BrowserState*. | 62 void AssertBrowserStateWasntDestroyed(web::BrowserState* context) const; |
63 void AssertBrowserStateWasntDestroyed(web::BrowserState* context); | |
64 | 63 |
65 // Marks |context| as live (i.e., not stale). This method can be called as a | 64 // Marks |context| as live (i.e., not stale). This method can be called as a |
66 // safeguard against |AssertBrowserStateWasntDestroyed()| checks going off | 65 // safeguard against |AssertBrowserStateWasntDestroyed()| checks going off |
67 // due to |context| aliasing a BrowserState instance from a prior test | 66 // due to |context| aliasing a BrowserState instance from a prior construction |
68 // (i.e., 0xWhatever might be created, be destroyed, and then a new | 67 // (i.e., 0xWhatever might be created, be destroyed, and then a new |
69 // BrowserState object might be created at 0xWhatever). | 68 // BrowserState object might be created at 0xWhatever). |
70 void MarkBrowserStateLiveForTesting(web::BrowserState* context); | 69 void MarkBrowserStateLive(web::BrowserState* context); |
71 #endif // NDEBUG | |
72 | 70 |
73 private: | 71 private: |
74 friend struct base::DefaultSingletonTraits<BrowserStateDependencyManager>; | 72 friend struct base::DefaultSingletonTraits<BrowserStateDependencyManager>; |
75 | 73 |
76 BrowserStateDependencyManager(); | 74 BrowserStateDependencyManager(); |
77 ~BrowserStateDependencyManager() override; | 75 ~BrowserStateDependencyManager() override; |
78 | 76 |
79 // Helper function used by CreateBrowserStateServices[ForTest]. | 77 // Helper function used by CreateBrowserStateServices[ForTest]. |
80 void DoCreateBrowserStateServices(web::BrowserState* context, | 78 void DoCreateBrowserStateServices(web::BrowserState* context, |
81 bool is_testing_context); | 79 bool is_testing_context); |
82 | 80 |
83 #ifndef NDEBUG | 81 #ifndef NDEBUG |
84 // DependencyManager: | 82 // DependencyManager: |
85 void DumpContextDependencies(base::SupportsUserData* context) const final; | 83 void DumpContextDependencies(base::SupportsUserData* context) const final; |
86 #endif // NDEBUG | 84 #endif // NDEBUG |
87 | 85 |
88 DISALLOW_COPY_AND_ASSIGN(BrowserStateDependencyManager); | 86 DISALLOW_COPY_AND_ASSIGN(BrowserStateDependencyManager); |
89 }; | 87 }; |
90 | 88 |
91 #endif // COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_DEPENDENCY_MANAGER_H_ | 89 #endif // COMPONENTS_KEYED_SERVICE_IOS_BROWSER_STATE_DEPENDENCY_MANAGER_H_ |
OLD | NEW |