| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sync_file_system/drive_backend/metadata_database.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" |
| 16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.
h" | 19 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.
h" |
| 19 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.
h" | 20 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.
h" |
| 20 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" | 21 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" |
| 21 #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" | 22 #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" |
| 22 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" | 23 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" |
| 23 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index.
h" | 24 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index.
h" |
| 24 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
interface.h" | 25 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
interface.h" |
| 25 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
on_disk.h" | 26 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
on_disk.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 SyncStatusCode InitializeMetadataDatabase() { | 211 SyncStatusCode InitializeMetadataDatabase() { |
| 211 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 212 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
| 212 metadata_database_ = MetadataDatabase::CreateInternal( | 213 metadata_database_ = MetadataDatabase::CreateInternal( |
| 213 database_dir_.path(), in_memory_env_.get(), | 214 database_dir_.path(), in_memory_env_.get(), |
| 214 GetParam(), &status); | 215 GetParam(), &status); |
| 215 return status; | 216 return status; |
| 216 } | 217 } |
| 217 | 218 |
| 218 void DropDatabase() { | 219 void DropDatabase() { |
| 219 metadata_database_.reset(); | 220 metadata_database_.reset(); |
| 220 message_loop_.RunUntilIdle(); | 221 base::RunLoop().RunUntilIdle(); |
| 221 } | 222 } |
| 222 | 223 |
| 223 void SetUpDatabaseByTrackedFiles(const TrackedFile** tracked_files, | 224 void SetUpDatabaseByTrackedFiles(const TrackedFile** tracked_files, |
| 224 int size) { | 225 int size) { |
| 225 std::unique_ptr<LevelDBWrapper> db = InitializeLevelDB(); | 226 std::unique_ptr<LevelDBWrapper> db = InitializeLevelDB(); |
| 226 ASSERT_TRUE(db); | 227 ASSERT_TRUE(db); |
| 227 | 228 |
| 228 for (int i = 0; i < size; ++i) { | 229 for (int i = 0; i < size; ++i) { |
| 229 const TrackedFile* file = tracked_files[i]; | 230 const TrackedFile* file = tracked_files[i]; |
| 230 if (file->should_be_absent) | 231 if (file->should_be_absent) |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 EXPECT_TRUE(file->HasKey("details")); | 1156 EXPECT_TRUE(file->HasKey("details")); |
| 1156 | 1157 |
| 1157 ASSERT_TRUE(files->GetDictionary(1, &file)); | 1158 ASSERT_TRUE(files->GetDictionary(1, &file)); |
| 1158 EXPECT_TRUE(file->GetString("title", &str) && str == "file_0"); | 1159 EXPECT_TRUE(file->GetString("title", &str) && str == "file_0"); |
| 1159 EXPECT_TRUE(file->GetString("type", &str) && str == "file"); | 1160 EXPECT_TRUE(file->GetString("type", &str) && str == "file"); |
| 1160 EXPECT_TRUE(file->HasKey("details")); | 1161 EXPECT_TRUE(file->HasKey("details")); |
| 1161 } | 1162 } |
| 1162 | 1163 |
| 1163 } // namespace drive_backend | 1164 } // namespace drive_backend |
| 1164 } // namespace sync_file_system | 1165 } // namespace sync_file_system |
| OLD | NEW |