Chromium Code Reviews| 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_service_factory .h" | 5 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 10 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 KeyedService* BrowserContextKeyedServiceFactory::GetServiceForBrowserContext( | 42 KeyedService* BrowserContextKeyedServiceFactory::GetServiceForBrowserContext( |
| 43 content::BrowserContext* context, | 43 content::BrowserContext* context, |
| 44 bool create) { | 44 bool create) { |
| 45 return KeyedServiceFactory::GetServiceForContext(context, create); | 45 return KeyedServiceFactory::GetServiceForContext(context, create); |
| 46 } | 46 } |
| 47 | 47 |
| 48 content::BrowserContext* | 48 content::BrowserContext* |
| 49 BrowserContextKeyedServiceFactory::GetBrowserContextToUse( | 49 BrowserContextKeyedServiceFactory::GetBrowserContextToUse( |
| 50 content::BrowserContext* context) const { | 50 content::BrowserContext* context) const { |
| 51 // TODO(crbug.com/701326): This DCHECK should be moved to GetContextToUse(). | |
| 51 DCHECK(CalledOnValidThread()); | 52 DCHECK(CalledOnValidThread()); |
| 52 | 53 |
| 53 #ifndef NDEBUG | |
| 54 AssertContextWasntDestroyed(context); | |
|
Paweł Hajdan Jr.
2017/03/21 13:03:24
Why do we remove this assertion?
| |
| 55 #endif | |
| 56 | |
| 57 // Safe default for Incognito mode: no service. | 54 // Safe default for Incognito mode: no service. |
| 58 if (context->IsOffTheRecord()) | 55 if (context->IsOffTheRecord()) |
| 59 return nullptr; | 56 return nullptr; |
| 60 | 57 |
| 61 return context; | 58 return context; |
| 62 } | 59 } |
| 63 | 60 |
| 64 void | 61 void |
| 65 BrowserContextKeyedServiceFactory::RegisterUserPrefsOnBrowserContextForTest( | 62 BrowserContextKeyedServiceFactory::RegisterUserPrefsOnBrowserContextForTest( |
| 66 content::BrowserContext* context) { | 63 content::BrowserContext* context) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 95 BuildServiceInstanceFor(static_cast<content::BrowserContext*>(context))); | 92 BuildServiceInstanceFor(static_cast<content::BrowserContext*>(context))); |
| 96 } | 93 } |
| 97 | 94 |
| 98 bool BrowserContextKeyedServiceFactory::IsOffTheRecord( | 95 bool BrowserContextKeyedServiceFactory::IsOffTheRecord( |
| 99 base::SupportsUserData* context) const { | 96 base::SupportsUserData* context) const { |
| 100 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord(); | 97 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord(); |
| 101 } | 98 } |
| 102 | 99 |
| 103 base::SupportsUserData* BrowserContextKeyedServiceFactory::GetContextToUse( | 100 base::SupportsUserData* BrowserContextKeyedServiceFactory::GetContextToUse( |
| 104 base::SupportsUserData* context) const { | 101 base::SupportsUserData* context) const { |
| 102 AssertContextWasntDestroyed(context); | |
| 105 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); | 103 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); |
| 106 } | 104 } |
| 107 | 105 |
| 108 bool BrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext() const { | 106 bool BrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext() const { |
| 109 return ServiceIsCreatedWithBrowserContext(); | 107 return ServiceIsCreatedWithBrowserContext(); |
| 110 } | 108 } |
| 111 | 109 |
| 112 void BrowserContextKeyedServiceFactory::ContextShutdown( | 110 void BrowserContextKeyedServiceFactory::ContextShutdown( |
| 113 base::SupportsUserData* context) { | 111 base::SupportsUserData* context) { |
| 114 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); | 112 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); |
| 115 } | 113 } |
| 116 | 114 |
| 117 void BrowserContextKeyedServiceFactory::ContextDestroyed( | 115 void BrowserContextKeyedServiceFactory::ContextDestroyed( |
| 118 base::SupportsUserData* context) { | 116 base::SupportsUserData* context) { |
| 119 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context)); | 117 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context)); |
| 120 } | 118 } |
| 121 | 119 |
| 122 void BrowserContextKeyedServiceFactory::RegisterPrefs( | 120 void BrowserContextKeyedServiceFactory::RegisterPrefs( |
| 123 user_prefs::PrefRegistrySyncable* registry) { | 121 user_prefs::PrefRegistrySyncable* registry) { |
| 124 RegisterProfilePrefs(registry); | 122 RegisterProfilePrefs(registry); |
| 125 } | 123 } |
| OLD | NEW |