| 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/local/syncable_file_operation_runner.h
" | 5 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h
" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 write_status_(File::FILE_ERROR_FAILED), | 65 write_status_(File::FILE_ERROR_FAILED), |
| 66 write_bytes_(0), | 66 write_bytes_(0), |
| 67 write_complete_(false), | 67 write_complete_(false), |
| 68 url_request_context_(file_system_.file_system_context()), | 68 url_request_context_(file_system_.file_system_context()), |
| 69 weak_factory_(this) {} | 69 weak_factory_(this) {} |
| 70 | 70 |
| 71 void SetUp() override { | 71 void SetUp() override { |
| 72 ASSERT_TRUE(dir_.CreateUniqueTempDir()); | 72 ASSERT_TRUE(dir_.CreateUniqueTempDir()); |
| 73 | 73 |
| 74 file_system_.SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); | 74 file_system_.SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); |
| 75 sync_context_ = new LocalFileSyncContext( | 75 sync_context_ = |
| 76 dir_.path(), | 76 new LocalFileSyncContext(dir_.GetPath(), in_memory_env_.get(), |
| 77 in_memory_env_.get(), | 77 base::ThreadTaskRunnerHandle::Get().get(), |
| 78 base::ThreadTaskRunnerHandle::Get().get(), | 78 base::ThreadTaskRunnerHandle::Get().get()); |
| 79 base::ThreadTaskRunnerHandle::Get().get()); | |
| 80 ASSERT_EQ( | 79 ASSERT_EQ( |
| 81 SYNC_STATUS_OK, | 80 SYNC_STATUS_OK, |
| 82 file_system_.MaybeInitializeFileSystemContext(sync_context_.get())); | 81 file_system_.MaybeInitializeFileSystemContext(sync_context_.get())); |
| 83 | 82 |
| 84 ASSERT_EQ(File::FILE_OK, file_system_.OpenFileSystem()); | 83 ASSERT_EQ(File::FILE_OK, file_system_.OpenFileSystem()); |
| 85 ASSERT_EQ(File::FILE_OK, | 84 ASSERT_EQ(File::FILE_OK, |
| 86 file_system_.CreateDirectory(URL(kParent))); | 85 file_system_.CreateDirectory(URL(kParent))); |
| 87 } | 86 } |
| 88 | 87 |
| 89 void TearDown() override { | 88 void TearDown() override { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 134 |
| 136 void DidFinish(const tracked_objects::Location& location, | 135 void DidFinish(const tracked_objects::Location& location, |
| 137 File::Error expect, File::Error status) { | 136 File::Error expect, File::Error status) { |
| 138 SCOPED_TRACE(testing::Message() << location.ToString()); | 137 SCOPED_TRACE(testing::Message() << location.ToString()); |
| 139 EXPECT_EQ(expect, status); | 138 EXPECT_EQ(expect, status); |
| 140 ++callback_count_; | 139 ++callback_count_; |
| 141 base::MessageLoop::current()->QuitWhenIdle(); | 140 base::MessageLoop::current()->QuitWhenIdle(); |
| 142 } | 141 } |
| 143 | 142 |
| 144 bool CreateTempFile(base::FilePath* path) { | 143 bool CreateTempFile(base::FilePath* path) { |
| 145 return base::CreateTemporaryFileInDir(dir_.path(), path); | 144 return base::CreateTemporaryFileInDir(dir_.GetPath(), path); |
| 146 } | 145 } |
| 147 | 146 |
| 148 content::TestBrowserThreadBundle thread_bundle_; | 147 content::TestBrowserThreadBundle thread_bundle_; |
| 149 | 148 |
| 150 base::ScopedTempDir dir_; | 149 base::ScopedTempDir dir_; |
| 151 std::unique_ptr<leveldb::Env> in_memory_env_; | 150 std::unique_ptr<leveldb::Env> in_memory_env_; |
| 152 | 151 |
| 153 CannedSyncableFileSystem file_system_; | 152 CannedSyncableFileSystem file_system_; |
| 154 scoped_refptr<LocalFileSyncContext> sync_context_; | 153 scoped_refptr<LocalFileSyncContext> sync_context_; |
| 155 | 154 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 storage::FileSystemOperationRunner::OperationID id = | 407 storage::FileSystemOperationRunner::OperationID id = |
| 409 file_system_.operation_runner()->Truncate( | 408 file_system_.operation_runner()->Truncate( |
| 410 URL(kFile), 10, ExpectStatus(FROM_HERE, File::FILE_OK)); | 409 URL(kFile), 10, ExpectStatus(FROM_HERE, File::FILE_OK)); |
| 411 file_system_.operation_runner()->Cancel( | 410 file_system_.operation_runner()->Cancel( |
| 412 id, ExpectStatus(FROM_HERE, File::FILE_ERROR_INVALID_OPERATION)); | 411 id, ExpectStatus(FROM_HERE, File::FILE_ERROR_INVALID_OPERATION)); |
| 413 base::RunLoop().Run(); | 412 base::RunLoop().Run(); |
| 414 EXPECT_EQ(2, callback_count_); | 413 EXPECT_EQ(2, callback_count_); |
| 415 } | 414 } |
| 416 | 415 |
| 417 } // namespace sync_file_system | 416 } // namespace sync_file_system |
| OLD | NEW |