Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / components / keyed_service / content / refcounted_browser_context_keyed_service_factory.cc
blob98ba79060c3e4e3f2693e20a1cd73685e3223ee9
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
3 // found in the LICENSE file.
5 #include "components/keyed_service/content/refcounted_browser_context_keyed_service_factory.h"
7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
10 #include "components/keyed_service/core/refcounted_keyed_service.h"
11 #include "components/pref_registry/pref_registry_syncable.h"
12 #include "components/user_prefs/user_prefs.h"
13 #include "content/public/browser/browser_context.h"
15 void RefcountedBrowserContextKeyedServiceFactory::SetTestingFactory(
16 content::BrowserContext* context,
17 TestingFactoryFunction testing_factory) {
18 RefcountedKeyedServiceFactory::SetTestingFactory(
19 context,
20 reinterpret_cast<RefcountedKeyedServiceFactory::TestingFactoryFunction>(
21 testing_factory));
24 scoped_refptr<RefcountedKeyedService>
25 RefcountedBrowserContextKeyedServiceFactory::SetTestingFactoryAndUse(
26 content::BrowserContext* context,
27 TestingFactoryFunction testing_factory) {
28 return RefcountedKeyedServiceFactory::SetTestingFactoryAndUse(
29 context,
30 reinterpret_cast<RefcountedKeyedServiceFactory::TestingFactoryFunction>(
31 testing_factory));
34 RefcountedBrowserContextKeyedServiceFactory::
35 RefcountedBrowserContextKeyedServiceFactory(
36 const char* name,
37 BrowserContextDependencyManager* manager)
38 : RefcountedKeyedServiceFactory(name, manager) {
41 RefcountedBrowserContextKeyedServiceFactory::
42 ~RefcountedBrowserContextKeyedServiceFactory() {
45 scoped_refptr<RefcountedKeyedService>
46 RefcountedBrowserContextKeyedServiceFactory::GetServiceForBrowserContext(
47 content::BrowserContext* context,
48 bool create) {
49 return RefcountedKeyedServiceFactory::GetServiceForContext(context, create);
52 content::BrowserContext*
53 RefcountedBrowserContextKeyedServiceFactory::GetBrowserContextToUse(
54 content::BrowserContext* context) const {
55 DCHECK(CalledOnValidThread());
57 #ifndef NDEBUG
58 AssertContextWasntDestroyed(context);
59 #endif
61 // Safe default for Incognito mode: no service.
62 if (context->IsOffTheRecord())
63 return nullptr;
65 return context;
68 void RefcountedBrowserContextKeyedServiceFactory::
69 RegisterUserPrefsOnBrowserContextForTest(content::BrowserContext* context) {
70 KeyedServiceBaseFactory::RegisterUserPrefsOnContextForTest(context);
73 bool RefcountedBrowserContextKeyedServiceFactory::
74 ServiceIsCreatedWithBrowserContext() const {
75 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext();
78 bool RefcountedBrowserContextKeyedServiceFactory::ServiceIsNULLWhileTesting()
79 const {
80 return KeyedServiceBaseFactory::ServiceIsNULLWhileTesting();
83 void RefcountedBrowserContextKeyedServiceFactory::BrowserContextShutdown(
84 content::BrowserContext* context) {
85 RefcountedKeyedServiceFactory::ContextShutdown(context);
88 void RefcountedBrowserContextKeyedServiceFactory::BrowserContextDestroyed(
89 content::BrowserContext* context) {
90 RefcountedKeyedServiceFactory::ContextDestroyed(context);
93 scoped_refptr<RefcountedKeyedService>
94 RefcountedBrowserContextKeyedServiceFactory::BuildServiceInstanceFor(
95 base::SupportsUserData* context) const {
96 return BuildServiceInstanceFor(
97 static_cast<content::BrowserContext*>(context));
100 bool RefcountedBrowserContextKeyedServiceFactory::IsOffTheRecord(
101 base::SupportsUserData* context) const {
102 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord();
105 user_prefs::PrefRegistrySyncable*
106 RefcountedBrowserContextKeyedServiceFactory::GetAssociatedPrefRegistry(
107 base::SupportsUserData* context) const {
108 PrefService* prefs = user_prefs::UserPrefs::Get(
109 static_cast<content::BrowserContext*>(context));
110 user_prefs::PrefRegistrySyncable* registry =
111 static_cast<user_prefs::PrefRegistrySyncable*>(
112 prefs->DeprecatedGetPrefRegistry());
113 return registry;
116 base::SupportsUserData*
117 RefcountedBrowserContextKeyedServiceFactory::GetContextToUse(
118 base::SupportsUserData* context) const {
119 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context));
122 bool RefcountedBrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext()
123 const {
124 return ServiceIsCreatedWithBrowserContext();
127 void RefcountedBrowserContextKeyedServiceFactory::ContextShutdown(
128 base::SupportsUserData* context) {
129 BrowserContextShutdown(static_cast<content::BrowserContext*>(context));
132 void RefcountedBrowserContextKeyedServiceFactory::ContextDestroyed(
133 base::SupportsUserData* context) {
134 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context));
137 void RefcountedBrowserContextKeyedServiceFactory::RegisterPrefs(
138 user_prefs::PrefRegistrySyncable* registry) {
139 RegisterProfilePrefs(registry);