Ensure low-memory renderers retry failed loads correctly.
[chromium-blink-merge.git] / components / keyed_service / content / refcounted_browser_context_keyed_service_factory.cc
blob03c99158b48d02580038250909832a0115ea49e4
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 "components/keyed_service/content/browser_context_dependency_manager.h"
9 #include "components/keyed_service/core/refcounted_keyed_service.h"
10 #include "content/public/browser/browser_context.h"
12 void RefcountedBrowserContextKeyedServiceFactory::SetTestingFactory(
13 content::BrowserContext* context,
14 TestingFactoryFunction testing_factory) {
15 RefcountedKeyedServiceFactory::SetTestingFactory(
16 context,
17 reinterpret_cast<RefcountedKeyedServiceFactory::TestingFactoryFunction>(
18 testing_factory));
21 scoped_refptr<RefcountedKeyedService>
22 RefcountedBrowserContextKeyedServiceFactory::SetTestingFactoryAndUse(
23 content::BrowserContext* context,
24 TestingFactoryFunction testing_factory) {
25 return RefcountedKeyedServiceFactory::SetTestingFactoryAndUse(
26 context,
27 reinterpret_cast<RefcountedKeyedServiceFactory::TestingFactoryFunction>(
28 testing_factory));
31 RefcountedBrowserContextKeyedServiceFactory::
32 RefcountedBrowserContextKeyedServiceFactory(
33 const char* name,
34 BrowserContextDependencyManager* manager)
35 : RefcountedKeyedServiceFactory(name, manager) {
38 RefcountedBrowserContextKeyedServiceFactory::
39 ~RefcountedBrowserContextKeyedServiceFactory() {
42 scoped_refptr<RefcountedKeyedService>
43 RefcountedBrowserContextKeyedServiceFactory::GetServiceForBrowserContext(
44 content::BrowserContext* context,
45 bool create) {
46 return RefcountedKeyedServiceFactory::GetServiceForContext(context, create);
49 content::BrowserContext*
50 RefcountedBrowserContextKeyedServiceFactory::GetBrowserContextToUse(
51 content::BrowserContext* context) const {
52 DCHECK(CalledOnValidThread());
54 #ifndef NDEBUG
55 AssertContextWasntDestroyed(context);
56 #endif
58 // Safe default for Incognito mode: no service.
59 if (context->IsOffTheRecord())
60 return nullptr;
62 return context;
65 bool RefcountedBrowserContextKeyedServiceFactory::
66 ServiceIsCreatedWithBrowserContext() const {
67 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext();
70 bool RefcountedBrowserContextKeyedServiceFactory::ServiceIsNULLWhileTesting()
71 const {
72 return KeyedServiceBaseFactory::ServiceIsNULLWhileTesting();
75 void RefcountedBrowserContextKeyedServiceFactory::BrowserContextShutdown(
76 content::BrowserContext* context) {
77 RefcountedKeyedServiceFactory::ContextShutdown(context);
80 void RefcountedBrowserContextKeyedServiceFactory::BrowserContextDestroyed(
81 content::BrowserContext* context) {
82 RefcountedKeyedServiceFactory::ContextDestroyed(context);
85 scoped_refptr<RefcountedKeyedService>
86 RefcountedBrowserContextKeyedServiceFactory::BuildServiceInstanceFor(
87 base::SupportsUserData* context) const {
88 return BuildServiceInstanceFor(
89 static_cast<content::BrowserContext*>(context));
92 bool RefcountedBrowserContextKeyedServiceFactory::IsOffTheRecord(
93 base::SupportsUserData* context) const {
94 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord();
97 base::SupportsUserData*
98 RefcountedBrowserContextKeyedServiceFactory::GetContextToUse(
99 base::SupportsUserData* context) const {
100 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context));
103 bool RefcountedBrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext()
104 const {
105 return ServiceIsCreatedWithBrowserContext();
108 void RefcountedBrowserContextKeyedServiceFactory::ContextShutdown(
109 base::SupportsUserData* context) {
110 BrowserContextShutdown(static_cast<content::BrowserContext*>(context));
113 void RefcountedBrowserContextKeyedServiceFactory::ContextDestroyed(
114 base::SupportsUserData* context) {
115 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context));
118 void RefcountedBrowserContextKeyedServiceFactory::RegisterPrefs(
119 user_prefs::PrefRegistrySyncable* registry) {
120 RegisterProfilePrefs(registry);