Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_context_keyed_service/browser_context_keyed_service _factory.h" | 5 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 BrowserContextKeyedService* | 43 BrowserContextKeyedService* |
| 44 BrowserContextKeyedServiceFactory::SetTestingFactoryAndUse( | 44 BrowserContextKeyedServiceFactory::SetTestingFactoryAndUse( |
| 45 content::BrowserContext* context, | 45 content::BrowserContext* context, |
| 46 TestingFactoryFunction testing_factory) { | 46 TestingFactoryFunction testing_factory) { |
| 47 DCHECK(testing_factory); | 47 DCHECK(testing_factory); |
| 48 SetTestingFactory(context, testing_factory); | 48 SetTestingFactory(context, testing_factory); |
| 49 return GetServiceForBrowserContext(context, true); | 49 return GetServiceForBrowserContext(context, true); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void BrowserContextKeyedServiceFactory::RemoveTestingFactory( | |
| 53 content::BrowserContext* context) { | |
| 54 testing_factories_.erase(context); | |
|
Andrew T Wilson (Slow)
2014/03/10 12:30:45
I think we should get rid of this, but if we keep
| |
| 55 } | |
| 56 | |
| 52 BrowserContextKeyedServiceFactory::BrowserContextKeyedServiceFactory( | 57 BrowserContextKeyedServiceFactory::BrowserContextKeyedServiceFactory( |
| 53 const char* name, BrowserContextDependencyManager* manager) | 58 const char* name, BrowserContextDependencyManager* manager) |
| 54 : BrowserContextKeyedBaseFactory(name, manager) { | 59 : BrowserContextKeyedBaseFactory(name, manager) { |
| 55 } | 60 } |
| 56 | 61 |
| 57 BrowserContextKeyedServiceFactory::~BrowserContextKeyedServiceFactory() { | 62 BrowserContextKeyedServiceFactory::~BrowserContextKeyedServiceFactory() { |
| 58 DCHECK(mapping_.empty()); | 63 DCHECK(mapping_.empty()); |
| 59 } | 64 } |
| 60 | 65 |
| 61 BrowserContextKeyedService* | 66 BrowserContextKeyedService* |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 } | 125 } |
| 121 | 126 |
| 122 void BrowserContextKeyedServiceFactory::BrowserContextDestroyed( | 127 void BrowserContextKeyedServiceFactory::BrowserContextDestroyed( |
| 123 content::BrowserContext* context) { | 128 content::BrowserContext* context) { |
| 124 Disassociate(context); | 129 Disassociate(context); |
| 125 | 130 |
| 126 // For unit tests, we also remove the factory function both so we don't | 131 // For unit tests, we also remove the factory function both so we don't |
| 127 // maintain a big map of dead pointers, but also since we may have a second | 132 // maintain a big map of dead pointers, but also since we may have a second |
| 128 // object that lives at the same address (see other comments about unit tests | 133 // object that lives at the same address (see other comments about unit tests |
| 129 // in this file). | 134 // in this file). |
| 130 testing_factories_.erase(context); | 135 RemoveTestingFactory(context); |
| 131 | 136 |
| 132 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); | 137 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); |
| 133 } | 138 } |
| 134 | 139 |
| 135 void BrowserContextKeyedServiceFactory::SetEmptyTestingFactory( | 140 void BrowserContextKeyedServiceFactory::SetEmptyTestingFactory( |
| 136 content::BrowserContext* context) { | 141 content::BrowserContext* context) { |
| 137 SetTestingFactory(context, NULL); | 142 SetTestingFactory(context, NULL); |
| 138 } | 143 } |
| 139 | 144 |
| 140 void BrowserContextKeyedServiceFactory::CreateServiceNow( | 145 void BrowserContextKeyedServiceFactory::CreateServiceNow( |
| 141 content::BrowserContext* context) { | 146 content::BrowserContext* context) { |
| 142 GetServiceForBrowserContext(context, true); | 147 GetServiceForBrowserContext(context, true); |
| 143 } | 148 } |
| OLD | NEW |