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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 mock_notify_changes_duration_in_sec_(-1) { | 61 mock_notify_changes_duration_in_sec_(-1) { |
62 DCHECK(base_path.IsAbsolute()); | 62 DCHECK(base_path.IsAbsolute()); |
63 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 63 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
64 } | 64 } |
65 | 65 |
66 void LocalFileSyncContext::MaybeInitializeFileSystemContext( | 66 void LocalFileSyncContext::MaybeInitializeFileSystemContext( |
67 const GURL& source_url, | 67 const GURL& source_url, |
68 FileSystemContext* file_system_context, | 68 FileSystemContext* file_system_context, |
69 const SyncStatusCallback& callback) { | 69 const SyncStatusCallback& callback) { |
70 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 70 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
71 if (ContainsKey(file_system_contexts_, file_system_context)) { | 71 if (base::ContainsKey(file_system_contexts_, file_system_context)) { |
72 // The context has been already initialized. Just dispatch the callback | 72 // The context has been already initialized. Just dispatch the callback |
73 // with SYNC_STATUS_OK. | 73 // with SYNC_STATUS_OK. |
74 ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, SYNC_STATUS_OK)); | 74 ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, SYNC_STATUS_OK)); |
75 return; | 75 return; |
76 } | 76 } |
77 | 77 |
78 StatusCallbackQueue& callback_queue = | 78 StatusCallbackQueue& callback_queue = |
79 pending_initialize_callbacks_[file_system_context]; | 79 pending_initialize_callbacks_[file_system_context]; |
80 callback_queue.push_back(callback); | 80 callback_queue.push_back(callback); |
81 if (callback_queue.size() > 1) | 81 if (callback_queue.size() > 1) |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 FileSystemContext* file_system_context, | 734 FileSystemContext* file_system_context, |
735 SyncStatusCode status) { | 735 SyncStatusCode status) { |
736 if (!ui_task_runner_->RunsTasksOnCurrentThread()) { | 736 if (!ui_task_runner_->RunsTasksOnCurrentThread()) { |
737 ui_task_runner_->PostTask( | 737 ui_task_runner_->PostTask( |
738 FROM_HERE, | 738 FROM_HERE, |
739 base::Bind(&LocalFileSyncContext::DidInitialize, this, source_url, | 739 base::Bind(&LocalFileSyncContext::DidInitialize, this, source_url, |
740 base::RetainedRef(file_system_context), status)); | 740 base::RetainedRef(file_system_context), status)); |
741 return; | 741 return; |
742 } | 742 } |
743 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 743 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
744 DCHECK(!ContainsKey(file_system_contexts_, file_system_context)); | 744 DCHECK(!base::ContainsKey(file_system_contexts_, file_system_context)); |
745 DCHECK(ContainsKey(pending_initialize_callbacks_, file_system_context)); | 745 DCHECK(base::ContainsKey(pending_initialize_callbacks_, file_system_context)); |
746 | 746 |
747 SyncFileSystemBackend* backend = | 747 SyncFileSystemBackend* backend = |
748 SyncFileSystemBackend::GetBackend(file_system_context); | 748 SyncFileSystemBackend::GetBackend(file_system_context); |
749 DCHECK(backend); | 749 DCHECK(backend); |
750 DCHECK(backend->change_tracker()); | 750 DCHECK(backend->change_tracker()); |
751 | 751 |
752 file_system_contexts_.insert(file_system_context); | 752 file_system_contexts_.insert(file_system_context); |
753 | 753 |
754 StatusCallbackQueue& callback_queue = | 754 StatusCallbackQueue& callback_queue = |
755 pending_initialize_callbacks_[file_system_context]; | 755 pending_initialize_callbacks_[file_system_context]; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 return; | 1048 return; |
1049 } | 1049 } |
1050 | 1050 |
1051 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( | 1051 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( |
1052 file_system_context, dest_url); | 1052 file_system_context, dest_url); |
1053 file_system_context->operation_runner()->CopyInForeignFile( | 1053 file_system_context->operation_runner()->CopyInForeignFile( |
1054 local_path, url_for_sync, callback); | 1054 local_path, url_for_sync, callback); |
1055 } | 1055 } |
1056 | 1056 |
1057 } // namespace sync_file_system | 1057 } // namespace sync_file_system |
OLD | NEW |