Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: components/keyed_service/content/browser_context_keyed_service_factory.cc

Issue 2775753002: Restore thread check in KeyedService factories.
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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().
52 DCHECK(CalledOnValidThread());
53
54 // Safe default for Incognito mode: no service. 51 // Safe default for Incognito mode: no service.
55 if (context->IsOffTheRecord()) 52 if (context->IsOffTheRecord())
56 return nullptr; 53 return nullptr;
57 54
58 return context; 55 return context;
59 } 56 }
60 57
61 void 58 void
62 BrowserContextKeyedServiceFactory::RegisterUserPrefsOnBrowserContextForTest( 59 BrowserContextKeyedServiceFactory::RegisterUserPrefsOnBrowserContextForTest(
63 content::BrowserContext* context) { 60 content::BrowserContext* context) {
(...skipping 28 matching lines...) Expand all
92 BuildServiceInstanceFor(static_cast<content::BrowserContext*>(context))); 89 BuildServiceInstanceFor(static_cast<content::BrowserContext*>(context)));
93 } 90 }
94 91
95 bool BrowserContextKeyedServiceFactory::IsOffTheRecord( 92 bool BrowserContextKeyedServiceFactory::IsOffTheRecord(
96 base::SupportsUserData* context) const { 93 base::SupportsUserData* context) const {
97 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord(); 94 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord();
98 } 95 }
99 96
100 base::SupportsUserData* BrowserContextKeyedServiceFactory::GetContextToUse( 97 base::SupportsUserData* BrowserContextKeyedServiceFactory::GetContextToUse(
101 base::SupportsUserData* context) const { 98 base::SupportsUserData* context) const {
99 DCHECK(CalledOnValidThread());
102 AssertContextWasntDestroyed(context); 100 AssertContextWasntDestroyed(context);
103 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); 101 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context));
104 } 102 }
105 103
106 bool BrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext() const { 104 bool BrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext() const {
107 return ServiceIsCreatedWithBrowserContext(); 105 return ServiceIsCreatedWithBrowserContext();
108 } 106 }
109 107
110 void BrowserContextKeyedServiceFactory::ContextShutdown( 108 void BrowserContextKeyedServiceFactory::ContextShutdown(
111 base::SupportsUserData* context) { 109 base::SupportsUserData* context) {
112 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); 110 BrowserContextShutdown(static_cast<content::BrowserContext*>(context));
113 } 111 }
114 112
115 void BrowserContextKeyedServiceFactory::ContextDestroyed( 113 void BrowserContextKeyedServiceFactory::ContextDestroyed(
116 base::SupportsUserData* context) { 114 base::SupportsUserData* context) {
117 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context)); 115 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context));
118 } 116 }
119 117
120 void BrowserContextKeyedServiceFactory::RegisterPrefs( 118 void BrowserContextKeyedServiceFactory::RegisterPrefs(
121 user_prefs::PrefRegistrySyncable* registry) { 119 user_prefs::PrefRegistrySyncable* registry) {
122 RegisterProfilePrefs(registry); 120 RegisterProfilePrefs(registry);
123 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698