Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/internal_api/public/attachments/on_disk_attachment_store.h" | |
| 6 | |
| 7 #include <string> | 5 #include <string> |
| 6 #include <utility> | |
| 8 | 7 |
| 9 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 14 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 15 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 16 #include "sync/internal_api/attachments/attachment_store_test_template.h" | 15 #include "sync/internal_api/attachments/attachment_store_test_template.h" |
| 17 #include "sync/internal_api/attachments/proto/attachment_store.pb.h" | 16 #include "sync/internal_api/attachments/proto/attachment_store.pb.h" |
| 17 #include "sync/internal_api/public/attachments/on_disk_attachment_store.h" | |
|
Nicolas Zea
2015/12/18 23:46:55
keep up top
| |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 20 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
| 21 #include "third_party/leveldatabase/src/include/leveldb/options.h" | 21 #include "third_party/leveldatabase/src/include/leveldb/options.h" |
| 22 #include "third_party/leveldatabase/src/include/leveldb/slice.h" | 22 #include "third_party/leveldatabase/src/include/leveldb/slice.h" |
| 23 #include "third_party/leveldatabase/src/include/leveldb/status.h" | 23 #include "third_party/leveldatabase/src/include/leveldb/status.h" |
| 24 | 24 |
| 25 namespace syncer { | 25 namespace syncer { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 CopyResult(destination_result, source_result); | 90 CopyResult(destination_result, source_result); |
| 91 *destination_failed_attachment_ids = *source_failed_attachment_ids; | 91 *destination_failed_attachment_ids = *source_failed_attachment_ids; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void CopyResultMetadata( | 94 void CopyResultMetadata( |
| 95 AttachmentStore::Result* destination_result, | 95 AttachmentStore::Result* destination_result, |
| 96 scoped_ptr<AttachmentMetadataList>* destination_metadata, | 96 scoped_ptr<AttachmentMetadataList>* destination_metadata, |
| 97 const AttachmentStore::Result& source_result, | 97 const AttachmentStore::Result& source_result, |
| 98 scoped_ptr<AttachmentMetadataList> source_metadata) { | 98 scoped_ptr<AttachmentMetadataList> source_metadata) { |
| 99 CopyResult(destination_result, source_result); | 99 CopyResult(destination_result, source_result); |
| 100 *destination_metadata = source_metadata.Pass(); | 100 *destination_metadata = std::move(source_metadata); |
| 101 } | 101 } |
| 102 | 102 |
| 103 scoped_ptr<leveldb::DB> OpenLevelDB() { | 103 scoped_ptr<leveldb::DB> OpenLevelDB() { |
| 104 leveldb::DB* db; | 104 leveldb::DB* db; |
| 105 leveldb::Options options; | 105 leveldb::Options options; |
| 106 options.create_if_missing = true; | 106 options.create_if_missing = true; |
| 107 leveldb::Status s = | 107 leveldb::Status s = |
| 108 leveldb::DB::Open(options, db_path_.AsUTF8Unsafe(), &db); | 108 leveldb::DB::Open(options, db_path_.AsUTF8Unsafe(), &db); |
| 109 EXPECT_TRUE(s.ok()); | 109 EXPECT_TRUE(s.ok()); |
| 110 return make_scoped_ptr(db); | 110 return make_scoped_ptr(db); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 store_->ReadMetadata( | 511 store_->ReadMetadata( |
| 512 base::Bind(&OnDiskAttachmentStoreSpecificTest::CopyResultMetadata, | 512 base::Bind(&OnDiskAttachmentStoreSpecificTest::CopyResultMetadata, |
| 513 base::Unretained(this), &metadata_result, &metadata_list)); | 513 base::Unretained(this), &metadata_result, &metadata_list)); |
| 514 RunLoop(); | 514 RunLoop(); |
| 515 EXPECT_EQ(AttachmentStore::SUCCESS, create_result); | 515 EXPECT_EQ(AttachmentStore::SUCCESS, create_result); |
| 516 EXPECT_EQ(AttachmentStore::UNSPECIFIED_ERROR, metadata_result); | 516 EXPECT_EQ(AttachmentStore::UNSPECIFIED_ERROR, metadata_result); |
| 517 EXPECT_EQ(2U, metadata_list->size()); | 517 EXPECT_EQ(2U, metadata_list->size()); |
| 518 } | 518 } |
| 519 | 519 |
| 520 } // namespace syncer | 520 } // namespace syncer |
| OLD | NEW |