| 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" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/guid.h" | 13 #include "base/guid.h" |
| 14 #include "base/message_loop/message_loop_proxy.h" | 14 #include "base/message_loop/message_loop_proxy.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/task_runner_util.h" | 17 #include "base/task_runner_util.h" |
| 18 #include "chrome/browser/sync_file_system/file_change.h" |
| 18 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" | 19 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
| 19 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 20 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
| 20 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 21 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
| 21 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 22 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "webkit/browser/blob/mock_blob_url_request_context.h" | 24 #include "webkit/browser/blob/mock_blob_url_request_context.h" |
| 24 #include "webkit/browser/fileapi/external_mount_points.h" | 25 #include "webkit/browser/fileapi/external_mount_points.h" |
| 25 #include "webkit/browser/fileapi/file_system_backend.h" | 26 #include "webkit/browser/fileapi/file_system_backend.h" |
| 26 #include "webkit/browser/fileapi/file_system_context.h" | 27 #include "webkit/browser/fileapi/file_system_context.h" |
| 27 #include "webkit/browser/fileapi/file_system_operation_context.h" | 28 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 io_task_runner_.get(), | 492 io_task_runner_.get(), |
| 492 FROM_HERE, | 493 FROM_HERE, |
| 493 base::Bind(&CannedSyncableFileSystem::DoGetUsageAndQuota, | 494 base::Bind(&CannedSyncableFileSystem::DoGetUsageAndQuota, |
| 494 base::Unretained(this), | 495 base::Unretained(this), |
| 495 usage, | 496 usage, |
| 496 quota)); | 497 quota)); |
| 497 } | 498 } |
| 498 | 499 |
| 499 void CannedSyncableFileSystem::GetChangedURLsInTracker( | 500 void CannedSyncableFileSystem::GetChangedURLsInTracker( |
| 500 FileSystemURLSet* urls) { | 501 FileSystemURLSet* urls) { |
| 501 return RunOnThread( | 502 RunOnThread( |
| 502 file_task_runner_.get(), | 503 file_task_runner_.get(), |
| 503 FROM_HERE, | 504 FROM_HERE, |
| 504 base::Bind(&LocalFileChangeTracker::GetAllChangedURLs, | 505 base::Bind(&LocalFileChangeTracker::GetAllChangedURLs, |
| 505 base::Unretained(backend()->change_tracker()), | 506 base::Unretained(backend()->change_tracker()), |
| 506 urls)); | 507 urls)); |
| 507 } | 508 } |
| 508 | 509 |
| 509 void CannedSyncableFileSystem::ClearChangeForURLInTracker( | 510 void CannedSyncableFileSystem::ClearChangeForURLInTracker( |
| 510 const FileSystemURL& url) { | 511 const FileSystemURL& url) { |
| 511 return RunOnThread( | 512 RunOnThread( |
| 512 file_task_runner_.get(), | 513 file_task_runner_.get(), |
| 513 FROM_HERE, | 514 FROM_HERE, |
| 514 base::Bind(&LocalFileChangeTracker::ClearChangesForURL, | 515 base::Bind(&LocalFileChangeTracker::ClearChangesForURL, |
| 515 base::Unretained(backend()->change_tracker()), | 516 base::Unretained(backend()->change_tracker()), |
| 516 url)); | 517 url)); |
| 517 } | 518 } |
| 518 | 519 |
| 520 void CannedSyncableFileSystem::GetChangesForURLInTracker( |
| 521 const FileSystemURL& url, |
| 522 FileChangeList* changes) { |
| 523 RunOnThread( |
| 524 file_task_runner_.get(), |
| 525 FROM_HERE, |
| 526 base::Bind(&LocalFileChangeTracker::GetChangesForURL, |
| 527 base::Unretained(backend()->change_tracker()), |
| 528 url, changes)); |
| 529 } |
| 530 |
| 519 SyncFileSystemBackend* CannedSyncableFileSystem::backend() { | 531 SyncFileSystemBackend* CannedSyncableFileSystem::backend() { |
| 520 return SyncFileSystemBackend::GetBackend(file_system_context_); | 532 return SyncFileSystemBackend::GetBackend(file_system_context_); |
| 521 } | 533 } |
| 522 | 534 |
| 523 FileSystemOperationRunner* CannedSyncableFileSystem::operation_runner() { | 535 FileSystemOperationRunner* CannedSyncableFileSystem::operation_runner() { |
| 524 return file_system_context_->operation_runner(); | 536 return file_system_context_->operation_runner(); |
| 525 } | 537 } |
| 526 | 538 |
| 527 void CannedSyncableFileSystem::OnSyncEnabled(const FileSystemURL& url) { | 539 void CannedSyncableFileSystem::OnSyncEnabled(const FileSystemURL& url) { |
| 528 sync_status_observers_->Notify(&LocalFileSyncStatus::Observer::OnSyncEnabled, | 540 sync_status_observers_->Notify(&LocalFileSyncStatus::Observer::OnSyncEnabled, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 sync_status_ = status; | 692 sync_status_ = status; |
| 681 base::MessageLoop::current()->Quit(); | 693 base::MessageLoop::current()->Quit(); |
| 682 } | 694 } |
| 683 | 695 |
| 684 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { | 696 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { |
| 685 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 697 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 686 backend()->sync_context()->sync_status()->AddObserver(this); | 698 backend()->sync_context()->sync_status()->AddObserver(this); |
| 687 } | 699 } |
| 688 | 700 |
| 689 } // namespace sync_file_system | 701 } // namespace sync_file_system |
| OLD | NEW |