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 #include "components/keyed_service/content/browser_context_keyed_base_factory.h" | 5 #include "components/keyed_service/content/browser_context_keyed_base_factory.h" |
6 | 6 |
7 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 7 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
8 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
9 | 9 |
10 BrowserContextKeyedBaseFactory::BrowserContextKeyedBaseFactory( | 10 BrowserContextKeyedBaseFactory::BrowserContextKeyedBaseFactory( |
11 const char* name, | 11 const char* name, |
12 BrowserContextDependencyManager* manager) | 12 BrowserContextDependencyManager* manager) |
13 : KeyedServiceBaseFactory(name, manager) { | 13 : KeyedServiceBaseFactory(name, manager) { |
14 } | 14 } |
15 | 15 |
16 BrowserContextKeyedBaseFactory::~BrowserContextKeyedBaseFactory() { | 16 BrowserContextKeyedBaseFactory::~BrowserContextKeyedBaseFactory() { |
17 } | 17 } |
18 | 18 |
19 content::BrowserContext* BrowserContextKeyedBaseFactory::GetBrowserContextToUse( | 19 content::BrowserContext* BrowserContextKeyedBaseFactory::GetBrowserContextToUse( |
20 content::BrowserContext* context) const { | 20 content::BrowserContext* context) const { |
| 21 // TODO(crbug.com/701326): This DCHECK should be moved to GetContextToUse(). |
21 DCHECK(CalledOnValidThread()); | 22 DCHECK(CalledOnValidThread()); |
22 | 23 |
23 #ifndef NDEBUG | |
24 AssertContextWasntDestroyed(context); | |
25 #endif | |
26 | |
27 // Safe default for the Incognito mode: no service. | 24 // Safe default for the Incognito mode: no service. |
28 if (context->IsOffTheRecord()) | 25 if (context->IsOffTheRecord()) |
29 return NULL; | 26 return NULL; |
30 | 27 |
31 return context; | 28 return context; |
32 } | 29 } |
33 | 30 |
34 void BrowserContextKeyedBaseFactory::RegisterUserPrefsOnBrowserContextForTest( | 31 void BrowserContextKeyedBaseFactory::RegisterUserPrefsOnBrowserContextForTest( |
35 content::BrowserContext* context) { | 32 content::BrowserContext* context) { |
36 KeyedServiceBaseFactory::RegisterUserPrefsOnContextForTest(context); | 33 KeyedServiceBaseFactory::RegisterUserPrefsOnContextForTest(context); |
37 } | 34 } |
38 | 35 |
39 bool BrowserContextKeyedBaseFactory::ServiceIsCreatedWithBrowserContext() | 36 bool BrowserContextKeyedBaseFactory::ServiceIsCreatedWithBrowserContext() |
40 const { | 37 const { |
41 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext(); | 38 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext(); |
42 } | 39 } |
43 | 40 |
44 bool BrowserContextKeyedBaseFactory::ServiceIsNULLWhileTesting() const { | 41 bool BrowserContextKeyedBaseFactory::ServiceIsNULLWhileTesting() const { |
45 return KeyedServiceBaseFactory::ServiceIsNULLWhileTesting(); | 42 return KeyedServiceBaseFactory::ServiceIsNULLWhileTesting(); |
46 } | 43 } |
47 | 44 |
48 void BrowserContextKeyedBaseFactory::BrowserContextDestroyed( | 45 void BrowserContextKeyedBaseFactory::BrowserContextDestroyed( |
49 content::BrowserContext* context) { | 46 content::BrowserContext* context) { |
50 KeyedServiceBaseFactory::ContextDestroyed(context); | 47 KeyedServiceBaseFactory::ContextDestroyed(context); |
51 } | 48 } |
52 | 49 |
53 base::SupportsUserData* BrowserContextKeyedBaseFactory::GetContextToUse( | 50 base::SupportsUserData* BrowserContextKeyedBaseFactory::GetContextToUse( |
54 base::SupportsUserData* context) const { | 51 base::SupportsUserData* context) const { |
| 52 AssertContextWasntDestroyed(context); |
55 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); | 53 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); |
56 } | 54 } |
57 | 55 |
58 bool BrowserContextKeyedBaseFactory::ServiceIsCreatedWithContext() const { | 56 bool BrowserContextKeyedBaseFactory::ServiceIsCreatedWithContext() const { |
59 return ServiceIsCreatedWithBrowserContext(); | 57 return ServiceIsCreatedWithBrowserContext(); |
60 } | 58 } |
61 | 59 |
62 void BrowserContextKeyedBaseFactory::ContextShutdown( | 60 void BrowserContextKeyedBaseFactory::ContextShutdown( |
63 base::SupportsUserData* context) { | 61 base::SupportsUserData* context) { |
64 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); | 62 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); |
(...skipping 16 matching lines...) Expand all Loading... |
81 | 79 |
82 bool BrowserContextKeyedBaseFactory::HasTestingFactory( | 80 bool BrowserContextKeyedBaseFactory::HasTestingFactory( |
83 base::SupportsUserData* context) { | 81 base::SupportsUserData* context) { |
84 return HasTestingFactory(static_cast<content::BrowserContext*>(context)); | 82 return HasTestingFactory(static_cast<content::BrowserContext*>(context)); |
85 } | 83 } |
86 | 84 |
87 void BrowserContextKeyedBaseFactory::CreateServiceNow( | 85 void BrowserContextKeyedBaseFactory::CreateServiceNow( |
88 base::SupportsUserData* context) { | 86 base::SupportsUserData* context) { |
89 CreateServiceNow(static_cast<content::BrowserContext*>(context)); | 87 CreateServiceNow(static_cast<content::BrowserContext*>(context)); |
90 } | 88 } |
OLD | NEW |