Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / components / keyed_service / ios / refcounted_browser_state_keyed_service_factory.cc
blob26828c021224a55ca892579922f4efe0c0110ef0
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/ios/refcounted_browser_state_keyed_service_factory.h"
7 #include "base/logging.h"
8 #include "components/keyed_service/core/refcounted_keyed_service.h"
9 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
10 #include "components/keyed_service/ios/browser_state_helper.h"
11 #include "ios/web/public/browser_state.h"
13 void RefcountedBrowserStateKeyedServiceFactory::SetTestingFactory(
14 web::BrowserState* context,
15 TestingFactoryFunction testing_factory) {
16 RefcountedKeyedServiceFactory::SetTestingFactory(
17 context,
18 reinterpret_cast<RefcountedKeyedServiceFactory::TestingFactoryFunction>(
19 testing_factory));
22 scoped_refptr<RefcountedKeyedService>
23 RefcountedBrowserStateKeyedServiceFactory::SetTestingFactoryAndUse(
24 web::BrowserState* context,
25 TestingFactoryFunction testing_factory) {
26 return RefcountedKeyedServiceFactory::SetTestingFactoryAndUse(
27 context,
28 reinterpret_cast<RefcountedKeyedServiceFactory::TestingFactoryFunction>(
29 testing_factory));
32 RefcountedBrowserStateKeyedServiceFactory::
33 RefcountedBrowserStateKeyedServiceFactory(
34 const char* name,
35 /*BrowserState*/DependencyManager* manager)
36 : RefcountedKeyedServiceFactory(name, manager) {
39 RefcountedBrowserStateKeyedServiceFactory::
40 ~RefcountedBrowserStateKeyedServiceFactory() {
43 scoped_refptr<RefcountedKeyedService>
44 RefcountedBrowserStateKeyedServiceFactory::GetServiceForBrowserState(
45 web::BrowserState* context,
46 bool create) {
47 return RefcountedKeyedServiceFactory::GetServiceForContext(context, create);
50 web::BrowserState*
51 RefcountedBrowserStateKeyedServiceFactory::GetBrowserStateToUse(
52 web::BrowserState* context) const {
53 DCHECK(CalledOnValidThread());
55 #ifndef NDEBUG
56 AssertContextWasntDestroyed(context);
57 #endif
59 // Safe default for Incognito mode: no service.
60 if (context->IsOffTheRecord())
61 return nullptr;
63 return context;
66 bool RefcountedBrowserStateKeyedServiceFactory::
67 ServiceIsCreatedWithBrowserState() const {
68 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext();
71 bool RefcountedBrowserStateKeyedServiceFactory::ServiceIsNULLWhileTesting()
72 const {
73 return KeyedServiceBaseFactory::ServiceIsNULLWhileTesting();
76 void RefcountedBrowserStateKeyedServiceFactory::BrowserStateShutdown(
77 web::BrowserState* context) {
78 RefcountedKeyedServiceFactory::ContextShutdown(context);
81 void RefcountedBrowserStateKeyedServiceFactory::BrowserStateDestroyed(
82 web::BrowserState* context) {
83 RefcountedKeyedServiceFactory::ContextDestroyed(context);
86 scoped_refptr<RefcountedKeyedService>
87 RefcountedBrowserStateKeyedServiceFactory::BuildServiceInstanceFor(
88 base::SupportsUserData* context) const {
89 return BuildServiceInstanceFor(BrowserStateFromContext(context));
92 bool RefcountedBrowserStateKeyedServiceFactory::IsOffTheRecord(
93 base::SupportsUserData* context) const {
94 return BrowserStateFromContext(context)->IsOffTheRecord();
97 user_prefs::PrefRegistrySyncable*
98 RefcountedBrowserStateKeyedServiceFactory::GetAssociatedPrefRegistry(
99 base::SupportsUserData* context) const {
100 NOTREACHED();
101 return nullptr;
104 base::SupportsUserData*
105 RefcountedBrowserStateKeyedServiceFactory::GetContextToUse(
106 base::SupportsUserData* context) const {
107 return GetBrowserStateToUse(BrowserStateFromContext(context));
110 bool RefcountedBrowserStateKeyedServiceFactory::ServiceIsCreatedWithContext()
111 const {
112 return ServiceIsCreatedWithBrowserState();
115 void RefcountedBrowserStateKeyedServiceFactory::ContextShutdown(
116 base::SupportsUserData* context) {
117 BrowserStateShutdown(BrowserStateFromContext(context));
120 void RefcountedBrowserStateKeyedServiceFactory::ContextDestroyed(
121 base::SupportsUserData* context) {
122 BrowserStateDestroyed(BrowserStateFromContext(context));
125 void RefcountedBrowserStateKeyedServiceFactory::RegisterPrefs(
126 user_prefs::PrefRegistrySyncable* registry) {
127 RegisterProfilePrefs(registry);