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 "webkit/browser/fileapi/syncable/canned_syncable_file_system.h" | 5 #include "webkit/browser/fileapi/syncable/canned_syncable_file_system.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 io_task_runner_.get(), | 225 io_task_runner_.get(), |
226 base::MessageLoopProxy::current().get(), | 226 base::MessageLoopProxy::current().get(), |
227 storage_policy.get()); | 227 storage_policy.get()); |
228 | 228 |
229 std::vector<std::string> additional_allowed_schemes; | 229 std::vector<std::string> additional_allowed_schemes; |
230 additional_allowed_schemes.push_back(origin_.scheme()); | 230 additional_allowed_schemes.push_back(origin_.scheme()); |
231 fileapi::FileSystemOptions options( | 231 fileapi::FileSystemOptions options( |
232 fileapi::FileSystemOptions::PROFILE_MODE_NORMAL, | 232 fileapi::FileSystemOptions::PROFILE_MODE_NORMAL, |
233 additional_allowed_schemes); | 233 additional_allowed_schemes); |
234 | 234 |
| 235 ScopedVector<fileapi::FileSystemMountPointProvider> additional_providers; |
| 236 additional_providers.push_back(new SyncableSandboxMountPointProvider( |
| 237 quota_manager_->proxy(), |
| 238 file_task_runner_.get(), |
| 239 data_dir_.path(), |
| 240 options, |
| 241 storage_policy)); |
| 242 |
235 file_system_context_ = new FileSystemContext( | 243 file_system_context_ = new FileSystemContext( |
236 make_scoped_ptr( | 244 make_scoped_ptr( |
237 new fileapi::FileSystemTaskRunners(io_task_runner_.get(), | 245 new fileapi::FileSystemTaskRunners(io_task_runner_.get(), |
238 file_task_runner_.get())), | 246 file_task_runner_.get())), |
239 fileapi::ExternalMountPoints::CreateRefCounted().get(), | 247 fileapi::ExternalMountPoints::CreateRefCounted().get(), |
240 storage_policy.get(), | 248 storage_policy.get(), |
241 quota_manager_->proxy(), | 249 quota_manager_->proxy(), |
242 ScopedVector<fileapi::FileSystemMountPointProvider>(), | 250 additional_providers.Pass(), |
243 data_dir_.path(), options); | 251 data_dir_.path(), options); |
244 | 252 |
245 is_filesystem_set_up_ = true; | 253 is_filesystem_set_up_ = true; |
246 } | 254 } |
247 | 255 |
248 void CannedSyncableFileSystem::TearDown() { | 256 void CannedSyncableFileSystem::TearDown() { |
249 quota_manager_ = NULL; | 257 quota_manager_ = NULL; |
250 file_system_context_ = NULL; | 258 file_system_context_ = NULL; |
251 | 259 |
252 // Make sure we give some more time to finish tasks on other threads. | 260 // Make sure we give some more time to finish tasks on other threads. |
(...skipping 11 matching lines...) Expand all Loading... |
264 | 272 |
265 PlatformFileError CannedSyncableFileSystem::OpenFileSystem() { | 273 PlatformFileError CannedSyncableFileSystem::OpenFileSystem() { |
266 EXPECT_TRUE(is_filesystem_set_up_); | 274 EXPECT_TRUE(is_filesystem_set_up_); |
267 EXPECT_FALSE(is_filesystem_opened_); | 275 EXPECT_FALSE(is_filesystem_opened_); |
268 file_system_context_->OpenFileSystem( | 276 file_system_context_->OpenFileSystem( |
269 origin_, type_, | 277 origin_, type_, |
270 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 278 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
271 base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, | 279 base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, |
272 base::Unretained(this))); | 280 base::Unretained(this))); |
273 base::MessageLoop::current()->Run(); | 281 base::MessageLoop::current()->Run(); |
274 if (file_system_context_->sync_context()) { | 282 if (mount_provider()->sync_context()) { |
275 // Register 'this' as a sync status observer. | 283 // Register 'this' as a sync status observer. |
276 RunOnThread( | 284 RunOnThread( |
277 io_task_runner_.get(), | 285 io_task_runner_.get(), |
278 FROM_HERE, | 286 FROM_HERE, |
279 base::Bind(&CannedSyncableFileSystem::InitializeSyncStatusObserver, | 287 base::Bind(&CannedSyncableFileSystem::InitializeSyncStatusObserver, |
280 base::Unretained(this))); | 288 base::Unretained(this))); |
281 } | 289 } |
282 return result_; | 290 return result_; |
283 } | 291 } |
284 | 292 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 usage, | 494 usage, |
487 quota)); | 495 quota)); |
488 } | 496 } |
489 | 497 |
490 void CannedSyncableFileSystem::GetChangedURLsInTracker( | 498 void CannedSyncableFileSystem::GetChangedURLsInTracker( |
491 FileSystemURLSet* urls) { | 499 FileSystemURLSet* urls) { |
492 return RunOnThread( | 500 return RunOnThread( |
493 file_task_runner_.get(), | 501 file_task_runner_.get(), |
494 FROM_HERE, | 502 FROM_HERE, |
495 base::Bind(&LocalFileChangeTracker::GetAllChangedURLs, | 503 base::Bind(&LocalFileChangeTracker::GetAllChangedURLs, |
496 base::Unretained(file_system_context_->change_tracker()), | 504 base::Unretained(mount_provider()->change_tracker()), |
497 urls)); | 505 urls)); |
498 } | 506 } |
499 | 507 |
500 void CannedSyncableFileSystem::ClearChangeForURLInTracker( | 508 void CannedSyncableFileSystem::ClearChangeForURLInTracker( |
501 const FileSystemURL& url) { | 509 const FileSystemURL& url) { |
502 return RunOnThread( | 510 return RunOnThread( |
503 file_task_runner_.get(), | 511 file_task_runner_.get(), |
504 FROM_HERE, | 512 FROM_HERE, |
505 base::Bind(&LocalFileChangeTracker::ClearChangesForURL, | 513 base::Bind(&LocalFileChangeTracker::ClearChangesForURL, |
506 base::Unretained(file_system_context_->change_tracker()), | 514 base::Unretained(mount_provider()->change_tracker()), |
507 url)); | 515 url)); |
508 } | 516 } |
509 | 517 |
| 518 SyncableSandboxMountPointProvider* CannedSyncableFileSystem::mount_provider() { |
| 519 return SyncableSandboxMountPointProvider::GetProvider(file_system_context_); |
| 520 } |
| 521 |
510 FileSystemOperationRunner* CannedSyncableFileSystem::operation_runner() { | 522 FileSystemOperationRunner* CannedSyncableFileSystem::operation_runner() { |
511 return file_system_context_->operation_runner(); | 523 return file_system_context_->operation_runner(); |
512 } | 524 } |
513 | 525 |
514 void CannedSyncableFileSystem::OnSyncEnabled(const FileSystemURL& url) { | 526 void CannedSyncableFileSystem::OnSyncEnabled(const FileSystemURL& url) { |
515 sync_status_observers_->Notify(&LocalFileSyncStatus::Observer::OnSyncEnabled, | 527 sync_status_observers_->Notify(&LocalFileSyncStatus::Observer::OnSyncEnabled, |
516 url); | 528 url); |
517 } | 529 } |
518 | 530 |
519 void CannedSyncableFileSystem::OnWriteEnabled(const FileSystemURL& url) { | 531 void CannedSyncableFileSystem::OnWriteEnabled(const FileSystemURL& url) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 } | 671 } |
660 | 672 |
661 void CannedSyncableFileSystem::DidInitializeFileSystemContext( | 673 void CannedSyncableFileSystem::DidInitializeFileSystemContext( |
662 SyncStatusCode status) { | 674 SyncStatusCode status) { |
663 sync_status_ = status; | 675 sync_status_ = status; |
664 base::MessageLoop::current()->Quit(); | 676 base::MessageLoop::current()->Quit(); |
665 } | 677 } |
666 | 678 |
667 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { | 679 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { |
668 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 680 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
669 file_system_context_->sync_context()->sync_status()->AddObserver(this); | 681 mount_provider()->sync_context()->sync_status()->AddObserver(this); |
670 } | 682 } |
671 | 683 |
672 } // namespace sync_file_system | 684 } // namespace sync_file_system |
OLD | NEW |