| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/profiles/profile_keyed_service_factory.h" | 5 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool ProfileKeyedServiceFactory::ServiceRedirectedInIncognito() { | 102 bool ProfileKeyedServiceFactory::ServiceRedirectedInIncognito() { |
| 103 return false; | 103 return false; |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool ProfileKeyedServiceFactory::ServiceHasOwnInstanceInIncognito() { | 106 bool ProfileKeyedServiceFactory::ServiceHasOwnInstanceInIncognito() { |
| 107 return false; | 107 return false; |
| 108 } | 108 } |
| 109 | 109 |
| 110 bool ProfileKeyedServiceFactory::ServiceIsCreatedWithProfile() { |
| 111 return false; |
| 112 } |
| 113 |
| 114 bool ProfileKeyedServiceFactory::ServiceIsNULLWhileTesting() { |
| 115 return false; |
| 116 } |
| 117 |
| 110 void ProfileKeyedServiceFactory::ProfileShutdown(Profile* profile) { | 118 void ProfileKeyedServiceFactory::ProfileShutdown(Profile* profile) { |
| 111 std::map<Profile*, ProfileKeyedService*>::iterator it = | 119 std::map<Profile*, ProfileKeyedService*>::iterator it = |
| 112 mapping_.find(profile); | 120 mapping_.find(profile); |
| 113 if (it != mapping_.end() && it->second) | 121 if (it != mapping_.end() && it->second) |
| 114 it->second->Shutdown(); | 122 it->second->Shutdown(); |
| 115 } | 123 } |
| 116 | 124 |
| 117 void ProfileKeyedServiceFactory::ProfileDestroyed(Profile* profile) { | 125 void ProfileKeyedServiceFactory::ProfileDestroyed(Profile* profile) { |
| 118 std::map<Profile*, ProfileKeyedService*>::iterator it = | 126 std::map<Profile*, ProfileKeyedService*>::iterator it = |
| 119 mapping_.find(profile); | 127 mapping_.find(profile); |
| 120 if (it != mapping_.end()) { | 128 if (it != mapping_.end()) { |
| 121 delete it->second; | 129 delete it->second; |
| 122 mapping_.erase(it); | 130 mapping_.erase(it); |
| 123 } | 131 } |
| 124 | 132 |
| 125 // For unit tests, we also remove the factory function both so we don't | 133 // For unit tests, we also remove the factory function both so we don't |
| 126 // maintain a big map of dead pointers, but also since we may have a second | 134 // maintain a big map of dead pointers, but also since we may have a second |
| 127 // object that lives at the same address (see other comments about unit tests | 135 // object that lives at the same address (see other comments about unit tests |
| 128 // in this file). | 136 // in this file). |
| 129 factories_.erase(profile); | 137 factories_.erase(profile); |
| 130 } | 138 } |
| OLD | NEW |