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

Side by Side Diff: components/keyed_service/ios/refcounted_browser_state_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
« no previous file with comments | « components/keyed_service/ios/browser_state_keyed_service_factory.cc ('k') | no next file » | 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/ios/refcounted_browser_state_keyed_service_fa ctory.h" 5 #include "components/keyed_service/ios/refcounted_browser_state_keyed_service_fa ctory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "components/keyed_service/core/refcounted_keyed_service.h" 8 #include "components/keyed_service/core/refcounted_keyed_service.h"
9 #include "components/keyed_service/ios/browser_state_dependency_manager.h" 9 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
10 #include "ios/web/public/browser_state.h" 10 #include "ios/web/public/browser_state.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 scoped_refptr<RefcountedKeyedService> 42 scoped_refptr<RefcountedKeyedService>
43 RefcountedBrowserStateKeyedServiceFactory::GetServiceForBrowserState( 43 RefcountedBrowserStateKeyedServiceFactory::GetServiceForBrowserState(
44 web::BrowserState* context, 44 web::BrowserState* context,
45 bool create) { 45 bool create) {
46 return RefcountedKeyedServiceFactory::GetServiceForContext(context, create); 46 return RefcountedKeyedServiceFactory::GetServiceForContext(context, create);
47 } 47 }
48 48
49 web::BrowserState* 49 web::BrowserState*
50 RefcountedBrowserStateKeyedServiceFactory::GetBrowserStateToUse( 50 RefcountedBrowserStateKeyedServiceFactory::GetBrowserStateToUse(
51 web::BrowserState* context) const { 51 web::BrowserState* 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 RefcountedBrowserStateKeyedServiceFactory:: 59 bool RefcountedBrowserStateKeyedServiceFactory::
63 ServiceIsCreatedWithBrowserState() const { 60 ServiceIsCreatedWithBrowserState() const {
64 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext(); 61 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext();
(...skipping 21 matching lines...) Expand all
86 } 83 }
87 84
88 bool RefcountedBrowserStateKeyedServiceFactory::IsOffTheRecord( 85 bool RefcountedBrowserStateKeyedServiceFactory::IsOffTheRecord(
89 base::SupportsUserData* context) const { 86 base::SupportsUserData* context) const {
90 return static_cast<web::BrowserState*>(context)->IsOffTheRecord(); 87 return static_cast<web::BrowserState*>(context)->IsOffTheRecord();
91 } 88 }
92 89
93 base::SupportsUserData* 90 base::SupportsUserData*
94 RefcountedBrowserStateKeyedServiceFactory::GetContextToUse( 91 RefcountedBrowserStateKeyedServiceFactory::GetContextToUse(
95 base::SupportsUserData* context) const { 92 base::SupportsUserData* context) const {
93 DCHECK(CalledOnValidThread());
96 AssertContextWasntDestroyed(context); 94 AssertContextWasntDestroyed(context);
97 return GetBrowserStateToUse(static_cast<web::BrowserState*>(context)); 95 return GetBrowserStateToUse(static_cast<web::BrowserState*>(context));
98 } 96 }
99 97
100 bool RefcountedBrowserStateKeyedServiceFactory::ServiceIsCreatedWithContext() 98 bool RefcountedBrowserStateKeyedServiceFactory::ServiceIsCreatedWithContext()
101 const { 99 const {
102 return ServiceIsCreatedWithBrowserState(); 100 return ServiceIsCreatedWithBrowserState();
103 } 101 }
104 102
105 void RefcountedBrowserStateKeyedServiceFactory::ContextShutdown( 103 void RefcountedBrowserStateKeyedServiceFactory::ContextShutdown(
106 base::SupportsUserData* context) { 104 base::SupportsUserData* context) {
107 BrowserStateShutdown(static_cast<web::BrowserState*>(context)); 105 BrowserStateShutdown(static_cast<web::BrowserState*>(context));
108 } 106 }
109 107
110 void RefcountedBrowserStateKeyedServiceFactory::ContextDestroyed( 108 void RefcountedBrowserStateKeyedServiceFactory::ContextDestroyed(
111 base::SupportsUserData* context) { 109 base::SupportsUserData* context) {
112 BrowserStateDestroyed(static_cast<web::BrowserState*>(context)); 110 BrowserStateDestroyed(static_cast<web::BrowserState*>(context));
113 } 111 }
114 112
115 void RefcountedBrowserStateKeyedServiceFactory::RegisterPrefs( 113 void RefcountedBrowserStateKeyedServiceFactory::RegisterPrefs(
116 user_prefs::PrefRegistrySyncable* registry) { 114 user_prefs::PrefRegistrySyncable* registry) {
117 RegisterBrowserStatePrefs(registry); 115 RegisterBrowserStatePrefs(registry);
118 } 116 }
OLDNEW
« no previous file with comments | « components/keyed_service/ios/browser_state_keyed_service_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698