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

Side by Side Diff: components/keyed_service/content/browser_context_keyed_base_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
« no previous file with comments | « no previous file | components/keyed_service/content/browser_context_keyed_service_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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().
22 DCHECK(CalledOnValidThread());
23
24 // Safe default for the Incognito mode: no service. 21 // Safe default for the Incognito mode: no service.
25 if (context->IsOffTheRecord()) 22 if (context->IsOffTheRecord())
26 return NULL; 23 return NULL;
27 24
28 return context; 25 return context;
29 } 26 }
30 27
31 void BrowserContextKeyedBaseFactory::RegisterUserPrefsOnBrowserContextForTest( 28 void BrowserContextKeyedBaseFactory::RegisterUserPrefsOnBrowserContextForTest(
32 content::BrowserContext* context) { 29 content::BrowserContext* context) {
33 KeyedServiceBaseFactory::RegisterUserPrefsOnContextForTest(context); 30 KeyedServiceBaseFactory::RegisterUserPrefsOnContextForTest(context);
34 } 31 }
35 32
36 bool BrowserContextKeyedBaseFactory::ServiceIsCreatedWithBrowserContext() 33 bool BrowserContextKeyedBaseFactory::ServiceIsCreatedWithBrowserContext()
37 const { 34 const {
38 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext(); 35 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext();
39 } 36 }
40 37
41 bool BrowserContextKeyedBaseFactory::ServiceIsNULLWhileTesting() const { 38 bool BrowserContextKeyedBaseFactory::ServiceIsNULLWhileTesting() const {
42 return KeyedServiceBaseFactory::ServiceIsNULLWhileTesting(); 39 return KeyedServiceBaseFactory::ServiceIsNULLWhileTesting();
43 } 40 }
44 41
45 void BrowserContextKeyedBaseFactory::BrowserContextDestroyed( 42 void BrowserContextKeyedBaseFactory::BrowserContextDestroyed(
46 content::BrowserContext* context) { 43 content::BrowserContext* context) {
47 KeyedServiceBaseFactory::ContextDestroyed(context); 44 KeyedServiceBaseFactory::ContextDestroyed(context);
48 } 45 }
49 46
50 base::SupportsUserData* BrowserContextKeyedBaseFactory::GetContextToUse( 47 base::SupportsUserData* BrowserContextKeyedBaseFactory::GetContextToUse(
51 base::SupportsUserData* context) const { 48 base::SupportsUserData* context) const {
49 DCHECK(CalledOnValidThread());
52 AssertContextWasntDestroyed(context); 50 AssertContextWasntDestroyed(context);
53 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); 51 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context));
54 } 52 }
55 53
56 bool BrowserContextKeyedBaseFactory::ServiceIsCreatedWithContext() const { 54 bool BrowserContextKeyedBaseFactory::ServiceIsCreatedWithContext() const {
57 return ServiceIsCreatedWithBrowserContext(); 55 return ServiceIsCreatedWithBrowserContext();
58 } 56 }
59 57
60 void BrowserContextKeyedBaseFactory::ContextShutdown( 58 void BrowserContextKeyedBaseFactory::ContextShutdown(
61 base::SupportsUserData* context) { 59 base::SupportsUserData* context) {
(...skipping 17 matching lines...) Expand all
79 77
80 bool BrowserContextKeyedBaseFactory::HasTestingFactory( 78 bool BrowserContextKeyedBaseFactory::HasTestingFactory(
81 base::SupportsUserData* context) { 79 base::SupportsUserData* context) {
82 return HasTestingFactory(static_cast<content::BrowserContext*>(context)); 80 return HasTestingFactory(static_cast<content::BrowserContext*>(context));
83 } 81 }
84 82
85 void BrowserContextKeyedBaseFactory::CreateServiceNow( 83 void BrowserContextKeyedBaseFactory::CreateServiceNow(
86 base::SupportsUserData* context) { 84 base::SupportsUserData* context) {
87 CreateServiceNow(static_cast<content::BrowserContext*>(context)); 85 CreateServiceNow(static_cast<content::BrowserContext*>(context));
88 } 86 }
OLDNEW
« no previous file with comments | « no previous file | components/keyed_service/content/browser_context_keyed_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698