| 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(). | |
| 53 DCHECK(CalledOnValidThread()); | |
| 54 | |
| 55 // Safe default for Incognito mode: no service. | 52 // Safe default for Incognito mode: no service. |
| 56 if (context->IsOffTheRecord()) | 53 if (context->IsOffTheRecord()) |
| 57 return nullptr; | 54 return nullptr; |
| 58 | 55 |
| 59 return context; | 56 return context; |
| 60 } | 57 } |
| 61 | 58 |
| 62 bool RefcountedBrowserContextKeyedServiceFactory:: | 59 bool RefcountedBrowserContextKeyedServiceFactory:: |
| 63 ServiceIsCreatedWithBrowserContext() const { | 60 ServiceIsCreatedWithBrowserContext() const { |
| 64 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext(); | 61 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 87 } | 84 } |
| 88 | 85 |
| 89 bool RefcountedBrowserContextKeyedServiceFactory::IsOffTheRecord( | 86 bool RefcountedBrowserContextKeyedServiceFactory::IsOffTheRecord( |
| 90 base::SupportsUserData* context) const { | 87 base::SupportsUserData* context) const { |
| 91 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord(); | 88 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord(); |
| 92 } | 89 } |
| 93 | 90 |
| 94 base::SupportsUserData* | 91 base::SupportsUserData* |
| 95 RefcountedBrowserContextKeyedServiceFactory::GetContextToUse( | 92 RefcountedBrowserContextKeyedServiceFactory::GetContextToUse( |
| 96 base::SupportsUserData* context) const { | 93 base::SupportsUserData* context) const { |
| 94 DCHECK(CalledOnValidThread()); |
| 97 AssertContextWasntDestroyed(context); | 95 AssertContextWasntDestroyed(context); |
| 98 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); | 96 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); |
| 99 } | 97 } |
| 100 | 98 |
| 101 bool RefcountedBrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext() | 99 bool RefcountedBrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext() |
| 102 const { | 100 const { |
| 103 return ServiceIsCreatedWithBrowserContext(); | 101 return ServiceIsCreatedWithBrowserContext(); |
| 104 } | 102 } |
| 105 | 103 |
| 106 void RefcountedBrowserContextKeyedServiceFactory::ContextShutdown( | 104 void RefcountedBrowserContextKeyedServiceFactory::ContextShutdown( |
| 107 base::SupportsUserData* context) { | 105 base::SupportsUserData* context) { |
| 108 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); | 106 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); |
| 109 } | 107 } |
| 110 | 108 |
| 111 void RefcountedBrowserContextKeyedServiceFactory::ContextDestroyed( | 109 void RefcountedBrowserContextKeyedServiceFactory::ContextDestroyed( |
| 112 base::SupportsUserData* context) { | 110 base::SupportsUserData* context) { |
| 113 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context)); | 111 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context)); |
| 114 } | 112 } |
| 115 | 113 |
| 116 void RefcountedBrowserContextKeyedServiceFactory::RegisterPrefs( | 114 void RefcountedBrowserContextKeyedServiceFactory::RegisterPrefs( |
| 117 user_prefs::PrefRegistrySyncable* registry) { | 115 user_prefs::PrefRegistrySyncable* registry) { |
| 118 RegisterProfilePrefs(registry); | 116 RegisterProfilePrefs(registry); |
| 119 } | 117 } |
| OLD | NEW |