| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include "webkit/browser/fileapi/external_mount_points.h" | 28 #include "webkit/browser/fileapi/external_mount_points.h" |
| 29 #include "webkit/browser/fileapi/file_system_backend.h" | 29 #include "webkit/browser/fileapi/file_system_backend.h" |
| 30 #include "webkit/browser/fileapi/file_system_context.h" | 30 #include "webkit/browser/fileapi/file_system_context.h" |
| 31 #include "webkit/browser/fileapi/file_system_operation_context.h" | 31 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 32 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 32 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
| 33 #include "webkit/browser/quota/quota_manager.h" | 33 #include "webkit/browser/quota/quota_manager.h" |
| 34 #include "webkit/common/blob/shareable_file_reference.h" | 34 #include "webkit/common/blob/shareable_file_reference.h" |
| 35 | 35 |
| 36 using base::File; | 36 using base::File; |
| 37 using fileapi::FileSystemContext; | 37 using storage::FileSystemContext; |
| 38 using fileapi::FileSystemOperationRunner; | 38 using storage::FileSystemOperationRunner; |
| 39 using fileapi::FileSystemURL; | 39 using storage::FileSystemURL; |
| 40 using fileapi::FileSystemURLSet; | 40 using storage::FileSystemURLSet; |
| 41 using quota::QuotaManager; | 41 using storage::QuotaManager; |
| 42 using content::MockBlobURLRequestContext; | 42 using content::MockBlobURLRequestContext; |
| 43 using content::ScopedTextBlob; | 43 using content::ScopedTextBlob; |
| 44 | 44 |
| 45 namespace sync_file_system { | 45 namespace sync_file_system { |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 template <typename R> | 49 template <typename R> |
| 50 void AssignAndQuit(base::TaskRunner* original_task_runner, | 50 void AssignAndQuit(base::TaskRunner* original_task_runner, |
| 51 const base::Closure& quit_closure, | 51 const base::Closure& quit_closure, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 runner1->PostTask(FROM_HERE, | 97 runner1->PostTask(FROM_HERE, |
| 98 base::Bind(&EnsureRunningOn, make_scoped_refptr(runner2))); | 98 base::Bind(&EnsureRunningOn, make_scoped_refptr(runner2))); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void OnCreateSnapshotFileAndVerifyData( | 101 void OnCreateSnapshotFileAndVerifyData( |
| 102 const std::string& expected_data, | 102 const std::string& expected_data, |
| 103 const CannedSyncableFileSystem::StatusCallback& callback, | 103 const CannedSyncableFileSystem::StatusCallback& callback, |
| 104 base::File::Error result, | 104 base::File::Error result, |
| 105 const base::File::Info& file_info, | 105 const base::File::Info& file_info, |
| 106 const base::FilePath& platform_path, | 106 const base::FilePath& platform_path, |
| 107 const scoped_refptr<webkit_blob::ShareableFileReference>& /* file_ref */) { | 107 const scoped_refptr<storage::ShareableFileReference>& /* file_ref */) { |
| 108 if (result != base::File::FILE_OK) { | 108 if (result != base::File::FILE_OK) { |
| 109 callback.Run(result); | 109 callback.Run(result); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 EXPECT_EQ(expected_data.size(), static_cast<size_t>(file_info.size)); | 112 EXPECT_EQ(expected_data.size(), static_cast<size_t>(file_info.size)); |
| 113 std::string data; | 113 std::string data; |
| 114 const bool read_status = base::ReadFileToString(platform_path, &data); | 114 const bool read_status = base::ReadFileToString(platform_path, &data); |
| 115 EXPECT_TRUE(read_status); | 115 EXPECT_TRUE(read_status); |
| 116 EXPECT_EQ(expected_data, data); | 116 EXPECT_EQ(expected_data, data); |
| 117 callback.Run(result); | 117 callback.Run(result); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void OnCreateSnapshotFile( | 120 void OnCreateSnapshotFile( |
| 121 base::File::Info* file_info_out, | 121 base::File::Info* file_info_out, |
| 122 base::FilePath* platform_path_out, | 122 base::FilePath* platform_path_out, |
| 123 const CannedSyncableFileSystem::StatusCallback& callback, | 123 const CannedSyncableFileSystem::StatusCallback& callback, |
| 124 base::File::Error result, | 124 base::File::Error result, |
| 125 const base::File::Info& file_info, | 125 const base::File::Info& file_info, |
| 126 const base::FilePath& platform_path, | 126 const base::FilePath& platform_path, |
| 127 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { | 127 const scoped_refptr<storage::ShareableFileReference>& file_ref) { |
| 128 DCHECK(!file_ref.get()); | 128 DCHECK(!file_ref.get()); |
| 129 DCHECK(file_info_out); | 129 DCHECK(file_info_out); |
| 130 DCHECK(platform_path_out); | 130 DCHECK(platform_path_out); |
| 131 *file_info_out = file_info; | 131 *file_info_out = file_info; |
| 132 *platform_path_out = platform_path; | 132 *platform_path_out = platform_path; |
| 133 callback.Run(result); | 133 callback.Run(result); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void OnReadDirectory( | 136 void OnReadDirectory(CannedSyncableFileSystem::FileEntryList* entries_out, |
| 137 CannedSyncableFileSystem::FileEntryList* entries_out, | 137 const CannedSyncableFileSystem::StatusCallback& callback, |
| 138 const CannedSyncableFileSystem::StatusCallback& callback, | 138 base::File::Error error, |
| 139 base::File::Error error, | 139 const storage::FileSystemOperation::FileEntryList& entries, |
| 140 const fileapi::FileSystemOperation::FileEntryList& entries, | 140 bool has_more) { |
| 141 bool has_more) { | |
| 142 DCHECK(entries_out); | 141 DCHECK(entries_out); |
| 143 entries_out->reserve(entries_out->size() + entries.size()); | 142 entries_out->reserve(entries_out->size() + entries.size()); |
| 144 std::copy(entries.begin(), entries.end(), std::back_inserter(*entries_out)); | 143 std::copy(entries.begin(), entries.end(), std::back_inserter(*entries_out)); |
| 145 | 144 |
| 146 if (!has_more) | 145 if (!has_more) |
| 147 callback.Run(error); | 146 callback.Run(error); |
| 148 } | 147 } |
| 149 | 148 |
| 150 class WriteHelper { | 149 class WriteHelper { |
| 151 public: | 150 public: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 180 } | 179 } |
| 181 | 180 |
| 182 private: | 181 private: |
| 183 int64 bytes_written_; | 182 int64 bytes_written_; |
| 184 scoped_ptr<MockBlobURLRequestContext> request_context_; | 183 scoped_ptr<MockBlobURLRequestContext> request_context_; |
| 185 scoped_ptr<ScopedTextBlob> blob_data_; | 184 scoped_ptr<ScopedTextBlob> blob_data_; |
| 186 | 185 |
| 187 DISALLOW_COPY_AND_ASSIGN(WriteHelper); | 186 DISALLOW_COPY_AND_ASSIGN(WriteHelper); |
| 188 }; | 187 }; |
| 189 | 188 |
| 190 void DidGetUsageAndQuota(const quota::StatusCallback& callback, | 189 void DidGetUsageAndQuota(const storage::StatusCallback& callback, |
| 191 int64* usage_out, int64* quota_out, | 190 int64* usage_out, |
| 192 quota::QuotaStatusCode status, | 191 int64* quota_out, |
| 193 int64 usage, int64 quota) { | 192 storage::QuotaStatusCode status, |
| 193 int64 usage, |
| 194 int64 quota) { |
| 194 *usage_out = usage; | 195 *usage_out = usage; |
| 195 *quota_out = quota; | 196 *quota_out = quota; |
| 196 callback.Run(status); | 197 callback.Run(status); |
| 197 } | 198 } |
| 198 | 199 |
| 199 void EnsureLastTaskRuns(base::SingleThreadTaskRunner* runner) { | 200 void EnsureLastTaskRuns(base::SingleThreadTaskRunner* runner) { |
| 200 base::RunLoop run_loop; | 201 base::RunLoop run_loop; |
| 201 runner->PostTaskAndReply( | 202 runner->PostTaskAndReply( |
| 202 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure()); | 203 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure()); |
| 203 run_loop.Run(); | 204 run_loop.Run(); |
| 204 } | 205 } |
| 205 | 206 |
| 206 } // namespace | 207 } // namespace |
| 207 | 208 |
| 208 CannedSyncableFileSystem::CannedSyncableFileSystem( | 209 CannedSyncableFileSystem::CannedSyncableFileSystem( |
| 209 const GURL& origin, | 210 const GURL& origin, |
| 210 leveldb::Env* env_override, | 211 leveldb::Env* env_override, |
| 211 base::SingleThreadTaskRunner* io_task_runner, | 212 base::SingleThreadTaskRunner* io_task_runner, |
| 212 base::SingleThreadTaskRunner* file_task_runner) | 213 base::SingleThreadTaskRunner* file_task_runner) |
| 213 : origin_(origin), | 214 : origin_(origin), |
| 214 type_(fileapi::kFileSystemTypeSyncable), | 215 type_(storage::kFileSystemTypeSyncable), |
| 215 result_(base::File::FILE_OK), | 216 result_(base::File::FILE_OK), |
| 216 sync_status_(sync_file_system::SYNC_STATUS_OK), | 217 sync_status_(sync_file_system::SYNC_STATUS_OK), |
| 217 env_override_(env_override), | 218 env_override_(env_override), |
| 218 io_task_runner_(io_task_runner), | 219 io_task_runner_(io_task_runner), |
| 219 file_task_runner_(file_task_runner), | 220 file_task_runner_(file_task_runner), |
| 220 is_filesystem_set_up_(false), | 221 is_filesystem_set_up_(false), |
| 221 is_filesystem_opened_(false), | 222 is_filesystem_opened_(false), |
| 222 sync_status_observers_(new ObserverList) { | 223 sync_status_observers_(new ObserverList) { |
| 223 } | 224 } |
| 224 | 225 |
| 225 CannedSyncableFileSystem::~CannedSyncableFileSystem() {} | 226 CannedSyncableFileSystem::~CannedSyncableFileSystem() {} |
| 226 | 227 |
| 227 void CannedSyncableFileSystem::SetUp(QuotaMode quota_mode) { | 228 void CannedSyncableFileSystem::SetUp(QuotaMode quota_mode) { |
| 228 ASSERT_FALSE(is_filesystem_set_up_); | 229 ASSERT_FALSE(is_filesystem_set_up_); |
| 229 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 230 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
| 230 | 231 |
| 231 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 232 scoped_refptr<storage::SpecialStoragePolicy> storage_policy = |
| 232 new content::MockSpecialStoragePolicy(); | 233 new content::MockSpecialStoragePolicy(); |
| 233 | 234 |
| 234 if (quota_mode == QUOTA_ENABLED) { | 235 if (quota_mode == QUOTA_ENABLED) { |
| 235 quota_manager_ = new QuotaManager(false /* is_incognito */, | 236 quota_manager_ = new QuotaManager(false /* is_incognito */, |
| 236 data_dir_.path(), | 237 data_dir_.path(), |
| 237 io_task_runner_, | 238 io_task_runner_, |
| 238 base::ThreadTaskRunnerHandle::Get().get(), | 239 base::ThreadTaskRunnerHandle::Get().get(), |
| 239 storage_policy.get()); | 240 storage_policy.get()); |
| 240 } | 241 } |
| 241 | 242 |
| 242 std::vector<std::string> additional_allowed_schemes; | 243 std::vector<std::string> additional_allowed_schemes; |
| 243 additional_allowed_schemes.push_back(origin_.scheme()); | 244 additional_allowed_schemes.push_back(origin_.scheme()); |
| 244 fileapi::FileSystemOptions options( | 245 storage::FileSystemOptions options( |
| 245 fileapi::FileSystemOptions::PROFILE_MODE_NORMAL, | 246 storage::FileSystemOptions::PROFILE_MODE_NORMAL, |
| 246 additional_allowed_schemes, | 247 additional_allowed_schemes, |
| 247 env_override_); | 248 env_override_); |
| 248 | 249 |
| 249 ScopedVector<fileapi::FileSystemBackend> additional_backends; | 250 ScopedVector<storage::FileSystemBackend> additional_backends; |
| 250 additional_backends.push_back(SyncFileSystemBackend::CreateForTesting()); | 251 additional_backends.push_back(SyncFileSystemBackend::CreateForTesting()); |
| 251 | 252 |
| 252 file_system_context_ = new FileSystemContext( | 253 file_system_context_ = new FileSystemContext( |
| 253 io_task_runner_, | 254 io_task_runner_, |
| 254 file_task_runner_, | 255 file_task_runner_, |
| 255 fileapi::ExternalMountPoints::CreateRefCounted().get(), | 256 storage::ExternalMountPoints::CreateRefCounted().get(), |
| 256 storage_policy.get(), | 257 storage_policy.get(), |
| 257 quota_manager_ ? quota_manager_->proxy() : NULL, | 258 quota_manager_ ? quota_manager_->proxy() : NULL, |
| 258 additional_backends.Pass(), | 259 additional_backends.Pass(), |
| 259 std::vector<fileapi::URLRequestAutoMountHandler>(), | 260 std::vector<storage::URLRequestAutoMountHandler>(), |
| 260 data_dir_.path(), options); | 261 data_dir_.path(), |
| 262 options); |
| 261 | 263 |
| 262 is_filesystem_set_up_ = true; | 264 is_filesystem_set_up_ = true; |
| 263 } | 265 } |
| 264 | 266 |
| 265 void CannedSyncableFileSystem::TearDown() { | 267 void CannedSyncableFileSystem::TearDown() { |
| 266 quota_manager_ = NULL; | 268 quota_manager_ = NULL; |
| 267 file_system_context_ = NULL; | 269 file_system_context_ = NULL; |
| 268 | 270 |
| 269 // Make sure we give some more time to finish tasks on other threads. | 271 // Make sure we give some more time to finish tasks on other threads. |
| 270 EnsureLastTaskRuns(io_task_runner_); | 272 EnsureLastTaskRuns(io_task_runner_); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 io_task_runner_, | 450 io_task_runner_, |
| 449 FROM_HERE, | 451 FROM_HERE, |
| 450 base::Bind(&CannedSyncableFileSystem::DoGetMetadataAndPlatformPath, | 452 base::Bind(&CannedSyncableFileSystem::DoGetMetadataAndPlatformPath, |
| 451 base::Unretained(this), | 453 base::Unretained(this), |
| 452 url, | 454 url, |
| 453 info, | 455 info, |
| 454 platform_path)); | 456 platform_path)); |
| 455 } | 457 } |
| 456 | 458 |
| 457 File::Error CannedSyncableFileSystem::ReadDirectory( | 459 File::Error CannedSyncableFileSystem::ReadDirectory( |
| 458 const fileapi::FileSystemURL& url, | 460 const storage::FileSystemURL& url, |
| 459 FileEntryList* entries) { | 461 FileEntryList* entries) { |
| 460 return RunOnThread<File::Error>( | 462 return RunOnThread<File::Error>( |
| 461 io_task_runner_, | 463 io_task_runner_, |
| 462 FROM_HERE, | 464 FROM_HERE, |
| 463 base::Bind(&CannedSyncableFileSystem::DoReadDirectory, | 465 base::Bind(&CannedSyncableFileSystem::DoReadDirectory, |
| 464 base::Unretained(this), | 466 base::Unretained(this), |
| 465 url, | 467 url, |
| 466 entries)); | 468 entries)); |
| 467 } | 469 } |
| 468 | 470 |
| 469 int64 CannedSyncableFileSystem::Write( | 471 int64 CannedSyncableFileSystem::Write( |
| 470 net::URLRequestContext* url_request_context, | 472 net::URLRequestContext* url_request_context, |
| 471 const FileSystemURL& url, | 473 const FileSystemURL& url, |
| 472 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle) { | 474 scoped_ptr<storage::BlobDataHandle> blob_data_handle) { |
| 473 return RunOnThread<int64>(io_task_runner_, | 475 return RunOnThread<int64>(io_task_runner_, |
| 474 FROM_HERE, | 476 FROM_HERE, |
| 475 base::Bind(&CannedSyncableFileSystem::DoWrite, | 477 base::Bind(&CannedSyncableFileSystem::DoWrite, |
| 476 base::Unretained(this), | 478 base::Unretained(this), |
| 477 url_request_context, | 479 url_request_context, |
| 478 url, | 480 url, |
| 479 base::Passed(&blob_data_handle))); | 481 base::Passed(&blob_data_handle))); |
| 480 } | 482 } |
| 481 | 483 |
| 482 int64 CannedSyncableFileSystem::WriteString( | 484 int64 CannedSyncableFileSystem::WriteString( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 493 EXPECT_TRUE(is_filesystem_set_up_); | 495 EXPECT_TRUE(is_filesystem_set_up_); |
| 494 return RunOnThread<File::Error>( | 496 return RunOnThread<File::Error>( |
| 495 io_task_runner_, | 497 io_task_runner_, |
| 496 FROM_HERE, | 498 FROM_HERE, |
| 497 base::Bind(&FileSystemContext::DeleteFileSystem, | 499 base::Bind(&FileSystemContext::DeleteFileSystem, |
| 498 file_system_context_, | 500 file_system_context_, |
| 499 origin_, | 501 origin_, |
| 500 type_)); | 502 type_)); |
| 501 } | 503 } |
| 502 | 504 |
| 503 quota::QuotaStatusCode CannedSyncableFileSystem::GetUsageAndQuota( | 505 storage::QuotaStatusCode CannedSyncableFileSystem::GetUsageAndQuota( |
| 504 int64* usage, int64* quota) { | 506 int64* usage, |
| 505 return RunOnThread<quota::QuotaStatusCode>( | 507 int64* quota) { |
| 508 return RunOnThread<storage::QuotaStatusCode>( |
| 506 io_task_runner_, | 509 io_task_runner_, |
| 507 FROM_HERE, | 510 FROM_HERE, |
| 508 base::Bind(&CannedSyncableFileSystem::DoGetUsageAndQuota, | 511 base::Bind(&CannedSyncableFileSystem::DoGetUsageAndQuota, |
| 509 base::Unretained(this), | 512 base::Unretained(this), |
| 510 usage, | 513 usage, |
| 511 quota)); | 514 quota)); |
| 512 } | 515 } |
| 513 | 516 |
| 514 void CannedSyncableFileSystem::GetChangedURLsInTracker( | 517 void CannedSyncableFileSystem::GetChangedURLsInTracker( |
| 515 FileSystemURLSet* urls) { | 518 FileSystemURLSet* urls) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 void CannedSyncableFileSystem::OnWriteEnabled(const FileSystemURL& url) { | 561 void CannedSyncableFileSystem::OnWriteEnabled(const FileSystemURL& url) { |
| 559 sync_status_observers_->Notify(&LocalFileSyncStatus::Observer::OnWriteEnabled, | 562 sync_status_observers_->Notify(&LocalFileSyncStatus::Observer::OnWriteEnabled, |
| 560 url); | 563 url); |
| 561 } | 564 } |
| 562 | 565 |
| 563 void CannedSyncableFileSystem::DoOpenFileSystem( | 566 void CannedSyncableFileSystem::DoOpenFileSystem( |
| 564 const OpenFileSystemCallback& callback) { | 567 const OpenFileSystemCallback& callback) { |
| 565 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 568 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 566 EXPECT_FALSE(is_filesystem_opened_); | 569 EXPECT_FALSE(is_filesystem_opened_); |
| 567 file_system_context_->OpenFileSystem( | 570 file_system_context_->OpenFileSystem( |
| 568 origin_, type_, | 571 origin_, |
| 569 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 572 type_, |
| 573 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
| 570 callback); | 574 callback); |
| 571 } | 575 } |
| 572 | 576 |
| 573 void CannedSyncableFileSystem::DoCreateDirectory( | 577 void CannedSyncableFileSystem::DoCreateDirectory( |
| 574 const FileSystemURL& url, | 578 const FileSystemURL& url, |
| 575 const StatusCallback& callback) { | 579 const StatusCallback& callback) { |
| 576 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 580 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 577 EXPECT_TRUE(is_filesystem_opened_); | 581 EXPECT_TRUE(is_filesystem_opened_); |
| 578 operation_runner()->CreateDirectory( | 582 operation_runner()->CreateDirectory( |
| 579 url, false /* exclusive */, false /* recursive */, callback); | 583 url, false /* exclusive */, false /* recursive */, callback); |
| 580 } | 584 } |
| 581 | 585 |
| 582 void CannedSyncableFileSystem::DoCreateFile( | 586 void CannedSyncableFileSystem::DoCreateFile( |
| 583 const FileSystemURL& url, | 587 const FileSystemURL& url, |
| 584 const StatusCallback& callback) { | 588 const StatusCallback& callback) { |
| 585 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 589 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 586 EXPECT_TRUE(is_filesystem_opened_); | 590 EXPECT_TRUE(is_filesystem_opened_); |
| 587 operation_runner()->CreateFile(url, false /* exclusive */, callback); | 591 operation_runner()->CreateFile(url, false /* exclusive */, callback); |
| 588 } | 592 } |
| 589 | 593 |
| 590 void CannedSyncableFileSystem::DoCopy( | 594 void CannedSyncableFileSystem::DoCopy( |
| 591 const FileSystemURL& src_url, | 595 const FileSystemURL& src_url, |
| 592 const FileSystemURL& dest_url, | 596 const FileSystemURL& dest_url, |
| 593 const StatusCallback& callback) { | 597 const StatusCallback& callback) { |
| 594 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 598 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 595 EXPECT_TRUE(is_filesystem_opened_); | 599 EXPECT_TRUE(is_filesystem_opened_); |
| 596 operation_runner()->Copy( | 600 operation_runner()->Copy( |
| 597 src_url, dest_url, | 601 src_url, |
| 598 fileapi::FileSystemOperation::OPTION_NONE, | 602 dest_url, |
| 599 fileapi::FileSystemOperationRunner::CopyProgressCallback(), callback); | 603 storage::FileSystemOperation::OPTION_NONE, |
| 604 storage::FileSystemOperationRunner::CopyProgressCallback(), |
| 605 callback); |
| 600 } | 606 } |
| 601 | 607 |
| 602 void CannedSyncableFileSystem::DoMove( | 608 void CannedSyncableFileSystem::DoMove( |
| 603 const FileSystemURL& src_url, | 609 const FileSystemURL& src_url, |
| 604 const FileSystemURL& dest_url, | 610 const FileSystemURL& dest_url, |
| 605 const StatusCallback& callback) { | 611 const StatusCallback& callback) { |
| 606 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 612 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 607 EXPECT_TRUE(is_filesystem_opened_); | 613 EXPECT_TRUE(is_filesystem_opened_); |
| 608 operation_runner()->Move( | 614 operation_runner()->Move( |
| 609 src_url, dest_url, fileapi::FileSystemOperation::OPTION_NONE, callback); | 615 src_url, dest_url, storage::FileSystemOperation::OPTION_NONE, callback); |
| 610 } | 616 } |
| 611 | 617 |
| 612 void CannedSyncableFileSystem::DoTruncateFile( | 618 void CannedSyncableFileSystem::DoTruncateFile( |
| 613 const FileSystemURL& url, int64 size, | 619 const FileSystemURL& url, int64 size, |
| 614 const StatusCallback& callback) { | 620 const StatusCallback& callback) { |
| 615 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 621 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 616 EXPECT_TRUE(is_filesystem_opened_); | 622 EXPECT_TRUE(is_filesystem_opened_); |
| 617 operation_runner()->Truncate(url, size, callback); | 623 operation_runner()->Truncate(url, size, callback); |
| 618 } | 624 } |
| 619 | 625 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 const StatusCallback& callback) { | 684 const StatusCallback& callback) { |
| 679 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 685 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 680 EXPECT_TRUE(is_filesystem_opened_); | 686 EXPECT_TRUE(is_filesystem_opened_); |
| 681 operation_runner()->ReadDirectory( | 687 operation_runner()->ReadDirectory( |
| 682 url, base::Bind(&OnReadDirectory, entries, callback)); | 688 url, base::Bind(&OnReadDirectory, entries, callback)); |
| 683 } | 689 } |
| 684 | 690 |
| 685 void CannedSyncableFileSystem::DoWrite( | 691 void CannedSyncableFileSystem::DoWrite( |
| 686 net::URLRequestContext* url_request_context, | 692 net::URLRequestContext* url_request_context, |
| 687 const FileSystemURL& url, | 693 const FileSystemURL& url, |
| 688 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle, | 694 scoped_ptr<storage::BlobDataHandle> blob_data_handle, |
| 689 const WriteCallback& callback) { | 695 const WriteCallback& callback) { |
| 690 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 696 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 691 EXPECT_TRUE(is_filesystem_opened_); | 697 EXPECT_TRUE(is_filesystem_opened_); |
| 692 WriteHelper* helper = new WriteHelper; | 698 WriteHelper* helper = new WriteHelper; |
| 693 operation_runner()->Write(url_request_context, url, | 699 operation_runner()->Write(url_request_context, url, |
| 694 blob_data_handle.Pass(), 0, | 700 blob_data_handle.Pass(), 0, |
| 695 base::Bind(&WriteHelper::DidWrite, | 701 base::Bind(&WriteHelper::DidWrite, |
| 696 base::Owned(helper), callback)); | 702 base::Owned(helper), callback)); |
| 697 } | 703 } |
| 698 | 704 |
| 699 void CannedSyncableFileSystem::DoWriteString( | 705 void CannedSyncableFileSystem::DoWriteString( |
| 700 const FileSystemURL& url, | 706 const FileSystemURL& url, |
| 701 const std::string& data, | 707 const std::string& data, |
| 702 const WriteCallback& callback) { | 708 const WriteCallback& callback) { |
| 703 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 709 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 704 EXPECT_TRUE(is_filesystem_opened_); | 710 EXPECT_TRUE(is_filesystem_opened_); |
| 705 MockBlobURLRequestContext* url_request_context( | 711 MockBlobURLRequestContext* url_request_context( |
| 706 new MockBlobURLRequestContext(file_system_context_.get())); | 712 new MockBlobURLRequestContext(file_system_context_.get())); |
| 707 WriteHelper* helper = new WriteHelper(url_request_context, data); | 713 WriteHelper* helper = new WriteHelper(url_request_context, data); |
| 708 operation_runner()->Write(url_request_context, url, | 714 operation_runner()->Write(url_request_context, url, |
| 709 helper->scoped_text_blob()->GetBlobDataHandle(), 0, | 715 helper->scoped_text_blob()->GetBlobDataHandle(), 0, |
| 710 base::Bind(&WriteHelper::DidWrite, | 716 base::Bind(&WriteHelper::DidWrite, |
| 711 base::Owned(helper), callback)); | 717 base::Owned(helper), callback)); |
| 712 } | 718 } |
| 713 | 719 |
| 714 void CannedSyncableFileSystem::DoGetUsageAndQuota( | 720 void CannedSyncableFileSystem::DoGetUsageAndQuota( |
| 715 int64* usage, | 721 int64* usage, |
| 716 int64* quota, | 722 int64* quota, |
| 717 const quota::StatusCallback& callback) { | 723 const storage::StatusCallback& callback) { |
| 718 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 724 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 719 EXPECT_TRUE(is_filesystem_opened_); | 725 EXPECT_TRUE(is_filesystem_opened_); |
| 720 DCHECK(quota_manager_); | 726 DCHECK(quota_manager_); |
| 721 quota_manager_->GetUsageAndQuota( | 727 quota_manager_->GetUsageAndQuota( |
| 722 origin_, storage_type(), | 728 origin_, storage_type(), |
| 723 base::Bind(&DidGetUsageAndQuota, callback, usage, quota)); | 729 base::Bind(&DidGetUsageAndQuota, callback, usage, quota)); |
| 724 } | 730 } |
| 725 | 731 |
| 726 void CannedSyncableFileSystem::DidOpenFileSystem( | 732 void CannedSyncableFileSystem::DidOpenFileSystem( |
| 727 base::SingleThreadTaskRunner* original_task_runner, | 733 base::SingleThreadTaskRunner* original_task_runner, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 755 sync_status_ = status; | 761 sync_status_ = status; |
| 756 quit_closure.Run(); | 762 quit_closure.Run(); |
| 757 } | 763 } |
| 758 | 764 |
| 759 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { | 765 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { |
| 760 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 766 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 761 backend()->sync_context()->sync_status()->AddObserver(this); | 767 backend()->sync_context()->sync_status()->AddObserver(this); |
| 762 } | 768 } |
| 763 | 769 |
| 764 } // namespace sync_file_system | 770 } // namespace sync_file_system |
| OLD | NEW |