| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/sync/model_impl/model_type_store_backend.h" | 5 #include "components/sync/model_impl/model_type_store_backend.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 void EraseBackend(const std::string& path); | 69 void EraseBackend(const std::string& path); |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 mutable base::Lock lock_; | 72 mutable base::Lock lock_; |
| 73 | 73 |
| 74 std::unordered_map<std::string, ModelTypeStoreBackend*> backends_; | 74 std::unordered_map<std::string, ModelTypeStoreBackend*> backends_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(BackendMap); | 76 DISALLOW_COPY_AND_ASSIGN(BackendMap); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 base::LazyInstance<BackendMap>::DestructorAtExit backend_map = | 79 base::LazyInstance<BackendMap>::Leaky backend_map = LAZY_INSTANCE_INITIALIZER; |
| 80 LAZY_INSTANCE_INITIALIZER; | |
| 81 | 80 |
| 82 scoped_refptr<ModelTypeStoreBackend> BackendMap::GetBackend( | 81 scoped_refptr<ModelTypeStoreBackend> BackendMap::GetBackend( |
| 83 const std::string& path) const { | 82 const std::string& path) const { |
| 84 base::AutoLock scoped_lock(lock_); | 83 base::AutoLock scoped_lock(lock_); |
| 85 auto it = backends_.find(path); | 84 auto it = backends_.find(path); |
| 86 return (it == backends_.end()) ? nullptr : it->second; | 85 return (it == backends_.end()) ? nullptr : it->second; |
| 87 } | 86 } |
| 88 | 87 |
| 89 void BackendMap::SetBackend(const std::string& path, | 88 void BackendMap::SetBackend(const std::string& path, |
| 90 ModelTypeStoreBackend* backend) { | 89 ModelTypeStoreBackend* backend) { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 UMA_HISTOGRAM_ENUMERATION(kStoreInitResultHistogramName, result, | 306 UMA_HISTOGRAM_ENUMERATION(kStoreInitResultHistogramName, result, |
| 308 STORE_INIT_RESULT_COUNT); | 307 STORE_INIT_RESULT_COUNT); |
| 309 } | 308 } |
| 310 | 309 |
| 311 // static | 310 // static |
| 312 bool ModelTypeStoreBackend::BackendExistsForTest(const std::string& path) { | 311 bool ModelTypeStoreBackend::BackendExistsForTest(const std::string& path) { |
| 313 return backend_map.Get().GetBackend(path) != nullptr; | 312 return backend_map.Get().GetBackend(path) != nullptr; |
| 314 } | 313 } |
| 315 | 314 |
| 316 } // namespace syncer | 315 } // namespace syncer |
| OLD | NEW |