| 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/canned_syncable_file_system.h" | 5 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | |
| 9 #include <algorithm> | 8 #include <algorithm> |
| 10 #include <iterator> | 9 #include <iterator> |
| 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/files/file.h" | 14 #include "base/files/file.h" |
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 16 #include "base/guid.h" | 16 #include "base/guid.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 20 #include "base/task_runner_util.h" | 20 #include "base/task_runner_util.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 additional_allowed_schemes.push_back(origin_.scheme()); | 251 additional_allowed_schemes.push_back(origin_.scheme()); |
| 252 storage::FileSystemOptions options( | 252 storage::FileSystemOptions options( |
| 253 storage::FileSystemOptions::PROFILE_MODE_NORMAL, | 253 storage::FileSystemOptions::PROFILE_MODE_NORMAL, |
| 254 additional_allowed_schemes, | 254 additional_allowed_schemes, |
| 255 env_override_); | 255 env_override_); |
| 256 | 256 |
| 257 ScopedVector<storage::FileSystemBackend> additional_backends; | 257 ScopedVector<storage::FileSystemBackend> additional_backends; |
| 258 additional_backends.push_back(SyncFileSystemBackend::CreateForTesting()); | 258 additional_backends.push_back(SyncFileSystemBackend::CreateForTesting()); |
| 259 | 259 |
| 260 file_system_context_ = new FileSystemContext( | 260 file_system_context_ = new FileSystemContext( |
| 261 io_task_runner_.get(), | 261 io_task_runner_.get(), file_task_runner_.get(), |
| 262 file_task_runner_.get(), | |
| 263 storage::ExternalMountPoints::CreateRefCounted().get(), | 262 storage::ExternalMountPoints::CreateRefCounted().get(), |
| 264 storage_policy.get(), | 263 storage_policy.get(), |
| 265 quota_manager_.get() ? quota_manager_->proxy() : nullptr, | 264 quota_manager_.get() ? quota_manager_->proxy() : nullptr, |
| 266 additional_backends.Pass(), | 265 std::move(additional_backends), |
| 267 std::vector<storage::URLRequestAutoMountHandler>(), | 266 std::vector<storage::URLRequestAutoMountHandler>(), data_dir_.path(), |
| 268 data_dir_.path(), | |
| 269 options); | 267 options); |
| 270 | 268 |
| 271 is_filesystem_set_up_ = true; | 269 is_filesystem_set_up_ = true; |
| 272 } | 270 } |
| 273 | 271 |
| 274 void CannedSyncableFileSystem::TearDown() { | 272 void CannedSyncableFileSystem::TearDown() { |
| 275 quota_manager_ = nullptr; | 273 quota_manager_ = nullptr; |
| 276 file_system_context_ = nullptr; | 274 file_system_context_ = nullptr; |
| 277 | 275 |
| 278 // Make sure we give some more time to finish tasks on other threads. | 276 // Make sure we give some more time to finish tasks on other threads. |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 } | 683 } |
| 686 | 684 |
| 687 void CannedSyncableFileSystem::DoWrite( | 685 void CannedSyncableFileSystem::DoWrite( |
| 688 net::URLRequestContext* url_request_context, | 686 net::URLRequestContext* url_request_context, |
| 689 const FileSystemURL& url, | 687 const FileSystemURL& url, |
| 690 scoped_ptr<storage::BlobDataHandle> blob_data_handle, | 688 scoped_ptr<storage::BlobDataHandle> blob_data_handle, |
| 691 const WriteCallback& callback) { | 689 const WriteCallback& callback) { |
| 692 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 690 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 693 EXPECT_TRUE(is_filesystem_opened_); | 691 EXPECT_TRUE(is_filesystem_opened_); |
| 694 WriteHelper* helper = new WriteHelper; | 692 WriteHelper* helper = new WriteHelper; |
| 695 operation_runner()->Write(url_request_context, url, | 693 operation_runner()->Write( |
| 696 blob_data_handle.Pass(), 0, | 694 url_request_context, url, std::move(blob_data_handle), 0, |
| 697 base::Bind(&WriteHelper::DidWrite, | 695 base::Bind(&WriteHelper::DidWrite, base::Owned(helper), callback)); |
| 698 base::Owned(helper), callback)); | |
| 699 } | 696 } |
| 700 | 697 |
| 701 void CannedSyncableFileSystem::DoWriteString( | 698 void CannedSyncableFileSystem::DoWriteString( |
| 702 const FileSystemURL& url, | 699 const FileSystemURL& url, |
| 703 const std::string& data, | 700 const std::string& data, |
| 704 const WriteCallback& callback) { | 701 const WriteCallback& callback) { |
| 705 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 702 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 706 EXPECT_TRUE(is_filesystem_opened_); | 703 EXPECT_TRUE(is_filesystem_opened_); |
| 707 MockBlobURLRequestContext* url_request_context( | 704 MockBlobURLRequestContext* url_request_context( |
| 708 new MockBlobURLRequestContext(file_system_context_.get())); | 705 new MockBlobURLRequestContext(file_system_context_.get())); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 sync_status_ = status; | 757 sync_status_ = status; |
| 761 quit_closure.Run(); | 758 quit_closure.Run(); |
| 762 } | 759 } |
| 763 | 760 |
| 764 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { | 761 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { |
| 765 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 762 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 766 backend()->sync_context()->sync_status()->AddObserver(this); | 763 backend()->sync_context()->sync_status()->AddObserver(this); |
| 767 } | 764 } |
| 768 | 765 |
| 769 } // namespace sync_file_system | 766 } // namespace sync_file_system |
| OLD | NEW |