| 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/core/model_type_store_backend.h" | 5 #include "components/sync/core/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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "third_party/leveldatabase/env_chromium.h" | 11 #include "third_party/leveldatabase/env_chromium.h" |
| 12 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" | 12 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
| 13 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 13 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
| 14 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 14 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
| 15 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" | 15 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" |
| 16 #include "third_party/leveldatabase/src/include/leveldb/options.h" | 16 #include "third_party/leveldatabase/src/include/leveldb/options.h" |
| 17 #include "third_party/leveldatabase/src/include/leveldb/slice.h" | 17 #include "third_party/leveldatabase/src/include/leveldb/slice.h" |
| 18 #include "third_party/leveldatabase/src/include/leveldb/status.h" | 18 #include "third_party/leveldatabase/src/include/leveldb/status.h" |
| 19 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 19 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
| 20 | 20 |
| 21 namespace syncer { | 21 namespace syncer_v2 { |
| 22 | 22 |
| 23 // static | 23 // static |
| 24 base::LazyInstance<ModelTypeStoreBackend::BackendMap> | 24 base::LazyInstance<ModelTypeStoreBackend::BackendMap> |
| 25 ModelTypeStoreBackend::backend_map_ = LAZY_INSTANCE_INITIALIZER; | 25 ModelTypeStoreBackend::backend_map_ = LAZY_INSTANCE_INITIALIZER; |
| 26 | 26 |
| 27 ModelTypeStoreBackend::ModelTypeStoreBackend(const std::string& path) | 27 ModelTypeStoreBackend::ModelTypeStoreBackend(const std::string& path) |
| 28 : path_(path) {} | 28 : path_(path) {} |
| 29 | 29 |
| 30 ModelTypeStoreBackend::~ModelTypeStoreBackend() { | 30 ModelTypeStoreBackend::~ModelTypeStoreBackend() { |
| 31 backend_map_.Get().erase(path_); | 31 backend_map_.Get().erase(path_); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 ModelTypeStore::Result ModelTypeStoreBackend::WriteModifications( | 135 ModelTypeStore::Result ModelTypeStoreBackend::WriteModifications( |
| 136 std::unique_ptr<leveldb::WriteBatch> write_batch) { | 136 std::unique_ptr<leveldb::WriteBatch> write_batch) { |
| 137 DFAKE_SCOPED_LOCK(push_pop_); | 137 DFAKE_SCOPED_LOCK(push_pop_); |
| 138 DCHECK(db_); | 138 DCHECK(db_); |
| 139 leveldb::Status status = | 139 leveldb::Status status = |
| 140 db_->Write(leveldb::WriteOptions(), write_batch.get()); | 140 db_->Write(leveldb::WriteOptions(), write_batch.get()); |
| 141 return status.ok() ? ModelTypeStore::Result::SUCCESS | 141 return status.ok() ? ModelTypeStore::Result::SUCCESS |
| 142 : ModelTypeStore::Result::UNSPECIFIED_ERROR; | 142 : ModelTypeStore::Result::UNSPECIFIED_ERROR; |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace syncer | 145 } // namespace syncer_v2 |
| OLD | NEW |