| 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/local_file_sync_context.h" | 5 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 const int kMaxConcurrentSyncableOperation = 3; | 40 const int kMaxConcurrentSyncableOperation = 3; |
| 41 const int kNotifyChangesDurationInSec = 1; | 41 const int kNotifyChangesDurationInSec = 1; |
| 42 const int kMaxURLsToFetchForLocalSync = 5; | 42 const int kMaxURLsToFetchForLocalSync = 5; |
| 43 | 43 |
| 44 const base::FilePath::CharType kSnapshotDir[] = FILE_PATH_LITERAL("snapshots"); | 44 const base::FilePath::CharType kSnapshotDir[] = FILE_PATH_LITERAL("snapshots"); |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 LocalFileSyncContext::LocalFileSyncContext( | 48 LocalFileSyncContext::LocalFileSyncContext( |
| 49 const base::FilePath& base_path, | 49 const base::FilePath& base_path, |
| 50 leveldb::Env* env_override, |
| 50 base::SingleThreadTaskRunner* ui_task_runner, | 51 base::SingleThreadTaskRunner* ui_task_runner, |
| 51 base::SingleThreadTaskRunner* io_task_runner) | 52 base::SingleThreadTaskRunner* io_task_runner) |
| 52 : local_base_path_(base_path.Append(FILE_PATH_LITERAL("local"))), | 53 : local_base_path_(base_path.Append(FILE_PATH_LITERAL("local"))), |
| 54 env_override_(env_override), |
| 53 ui_task_runner_(ui_task_runner), | 55 ui_task_runner_(ui_task_runner), |
| 54 io_task_runner_(io_task_runner), | 56 io_task_runner_(io_task_runner), |
| 55 shutdown_on_ui_(false), | 57 shutdown_on_ui_(false), |
| 56 shutdown_on_io_(false), | 58 shutdown_on_io_(false), |
| 57 mock_notify_changes_duration_in_sec_(-1) { | 59 mock_notify_changes_duration_in_sec_(-1) { |
| 58 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 60 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 59 } | 61 } |
| 60 | 62 |
| 61 void LocalFileSyncContext::MaybeInitializeFileSystemContext( | 63 void LocalFileSyncContext::MaybeInitializeFileSystemContext( |
| 62 const GURL& source_url, | 64 const GURL& source_url, |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 | 674 |
| 673 SyncStatusCode LocalFileSyncContext::InitializeChangeTrackerOnFileThread( | 675 SyncStatusCode LocalFileSyncContext::InitializeChangeTrackerOnFileThread( |
| 674 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, | 676 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, |
| 675 FileSystemContext* file_system_context, | 677 FileSystemContext* file_system_context, |
| 676 std::set<GURL>* origins_with_changes) { | 678 std::set<GURL>* origins_with_changes) { |
| 677 DCHECK(file_system_context); | 679 DCHECK(file_system_context); |
| 678 DCHECK(tracker_ptr); | 680 DCHECK(tracker_ptr); |
| 679 DCHECK(origins_with_changes); | 681 DCHECK(origins_with_changes); |
| 680 tracker_ptr->reset(new LocalFileChangeTracker( | 682 tracker_ptr->reset(new LocalFileChangeTracker( |
| 681 file_system_context->partition_path(), | 683 file_system_context->partition_path(), |
| 684 env_override_, |
| 682 file_system_context->default_file_task_runner())); | 685 file_system_context->default_file_task_runner())); |
| 683 const SyncStatusCode status = (*tracker_ptr)->Initialize(file_system_context); | 686 const SyncStatusCode status = (*tracker_ptr)->Initialize(file_system_context); |
| 684 if (status != SYNC_STATUS_OK) | 687 if (status != SYNC_STATUS_OK) |
| 685 return status; | 688 return status; |
| 686 | 689 |
| 687 // Get all origins that have pending changes. | 690 // Get all origins that have pending changes. |
| 688 std::deque<FileSystemURL> urls; | 691 std::deque<FileSystemURL> urls; |
| 689 (*tracker_ptr)->GetNextChangedURLs(&urls, 0); | 692 (*tracker_ptr)->GetNextChangedURLs(&urls, 0); |
| 690 for (std::deque<FileSystemURL>::iterator iter = urls.begin(); | 693 for (std::deque<FileSystemURL>::iterator iter = urls.begin(); |
| 691 iter != urls.end(); ++iter) { | 694 iter != urls.end(); ++iter) { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 return; | 1000 return; |
| 998 } | 1001 } |
| 999 | 1002 |
| 1000 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( | 1003 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( |
| 1001 file_system_context, dest_url); | 1004 file_system_context, dest_url); |
| 1002 file_system_context->operation_runner()->CopyInForeignFile( | 1005 file_system_context->operation_runner()->CopyInForeignFile( |
| 1003 local_path, url_for_sync, callback); | 1006 local_path, url_for_sync, callback); |
| 1004 } | 1007 } |
| 1005 | 1008 |
| 1006 } // namespace sync_file_system | 1009 } // namespace sync_file_system |
| OLD | NEW |