Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / components / keyed_service / content / refcounted_browser_context_keyed_service_factory.cc
blob7a7a6f076ad1aa2ec53de2040d464bbef8c72455
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 void RefcountedBrowserContextKeyedServiceFactory::
66 RegisterUserPrefsOnBrowserContextForTest(content::BrowserContext* context) {
67 KeyedServiceBaseFactory::RegisterUserPrefsOnContextForTest(context);
70 bool RefcountedBrowserContextKeyedServiceFactory::
71 ServiceIsCreatedWithBrowserContext() const {
72 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext();
75 bool RefcountedBrowserContextKeyedServiceFactory::ServiceIsNULLWhileTesting()
76 const {
77 return KeyedServiceBaseFactory::ServiceIsNULLWhileTesting();
80 void RefcountedBrowserContextKeyedServiceFactory::BrowserContextShutdown(
81 content::BrowserContext* context) {
82 RefcountedKeyedServiceFactory::ContextShutdown(context);
85 void RefcountedBrowserContextKeyedServiceFactory::BrowserContextDestroyed(
86 content::BrowserContext* context) {
87 RefcountedKeyedServiceFactory::ContextDestroyed(context);
90 scoped_refptr<RefcountedKeyedService>
91 RefcountedBrowserContextKeyedServiceFactory::BuildServiceInstanceFor(
92 base::SupportsUserData* context) const {
93 return BuildServiceInstanceFor(
94 static_cast<content::BrowserContext*>(context));
97 bool RefcountedBrowserContextKeyedServiceFactory::IsOffTheRecord(
98 base::SupportsUserData* context) const {
99 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord();
102 base::SupportsUserData*
103 RefcountedBrowserContextKeyedServiceFactory::GetContextToUse(
104 base::SupportsUserData* context) const {
105 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context));
108 bool RefcountedBrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext()
109 const {
110 return ServiceIsCreatedWithBrowserContext();
113 void RefcountedBrowserContextKeyedServiceFactory::ContextShutdown(
114 base::SupportsUserData* context) {
115 BrowserContextShutdown(static_cast<content::BrowserContext*>(context));
118 void RefcountedBrowserContextKeyedServiceFactory::ContextDestroyed(
119 base::SupportsUserData* context) {
120 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context));
123 void RefcountedBrowserContextKeyedServiceFactory::RegisterPrefs(
124 user_prefs::PrefRegistrySyncable* registry) {
125 RegisterProfilePrefs(registry);