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