OLD | NEW |
---|---|
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/core/keyed_service_factory.h" | 5 #include "components/keyed_service/core/keyed_service_factory.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/trace_event/trace_event.h" | |
9 #include "components/keyed_service/core/dependency_manager.h" | 10 #include "components/keyed_service/core/dependency_manager.h" |
10 #include "components/keyed_service/core/keyed_service.h" | 11 #include "components/keyed_service/core/keyed_service.h" |
11 | 12 |
12 KeyedServiceFactory::KeyedServiceFactory(const char* name, | 13 KeyedServiceFactory::KeyedServiceFactory(const char* name, |
13 DependencyManager* manager) | 14 DependencyManager* manager) |
14 : KeyedServiceBaseFactory(name, manager) { | 15 : KeyedServiceBaseFactory(name, manager) { |
15 } | 16 } |
16 | 17 |
17 KeyedServiceFactory::~KeyedServiceFactory() { | 18 KeyedServiceFactory::~KeyedServiceFactory() { |
18 DCHECK(mapping_.empty()); | 19 DCHECK(mapping_.empty()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 base::SupportsUserData* context, | 52 base::SupportsUserData* context, |
52 TestingFactoryFunction testing_factory) { | 53 TestingFactoryFunction testing_factory) { |
53 DCHECK(testing_factory); | 54 DCHECK(testing_factory); |
54 SetTestingFactory(context, testing_factory); | 55 SetTestingFactory(context, testing_factory); |
55 return GetServiceForContext(context, true); | 56 return GetServiceForContext(context, true); |
56 } | 57 } |
57 | 58 |
58 KeyedService* KeyedServiceFactory::GetServiceForContext( | 59 KeyedService* KeyedServiceFactory::GetServiceForContext( |
59 base::SupportsUserData* context, | 60 base::SupportsUserData* context, |
60 bool create) { | 61 bool create) { |
62 TRACE_EVENT0("browser,startup", "KeyedServiceFactory::GetServiceForContext"); | |
Elliot Glaysher
2015/03/04 19:06:00
I expect that this event will be extremely spammy.
| |
61 context = GetContextToUse(context); | 63 context = GetContextToUse(context); |
62 if (!context) | 64 if (!context) |
63 return nullptr; | 65 return nullptr; |
64 | 66 |
65 // NOTE: If you modify any of the logic below, make sure to update the | 67 // NOTE: If you modify any of the logic below, make sure to update the |
66 // refcounted version in refcounted_context_keyed_service_factory.cc! | 68 // refcounted version in refcounted_context_keyed_service_factory.cc! |
67 const auto& it = mapping_.find(context); | 69 const auto& it = mapping_.find(context); |
68 if (it != mapping_.end()) | 70 if (it != mapping_.end()) |
69 return it->second; | 71 return it->second; |
70 | 72 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 SetTestingFactory(context, nullptr); | 130 SetTestingFactory(context, nullptr); |
129 } | 131 } |
130 | 132 |
131 bool KeyedServiceFactory::HasTestingFactory(base::SupportsUserData* context) { | 133 bool KeyedServiceFactory::HasTestingFactory(base::SupportsUserData* context) { |
132 return testing_factories_.find(context) != testing_factories_.end(); | 134 return testing_factories_.find(context) != testing_factories_.end(); |
133 } | 135 } |
134 | 136 |
135 void KeyedServiceFactory::CreateServiceNow(base::SupportsUserData* context) { | 137 void KeyedServiceFactory::CreateServiceNow(base::SupportsUserData* context) { |
136 GetServiceForContext(context, true); | 138 GetServiceForContext(context, true); |
137 } | 139 } |
OLD | NEW |