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/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
13 #include "chrome/browser/sync_file_system/file_change.h" | 13 #include "chrome/browser/sync_file_system/file_change.h" |
14 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" | 14 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
15 #include "chrome/browser/sync_file_system/local/local_origin_change_observer.h" | 15 #include "chrome/browser/sync_file_system/local/local_origin_change_observer.h" |
16 #include "chrome/browser/sync_file_system/local/root_delete_helper.h" | 16 #include "chrome/browser/sync_file_system/local/root_delete_helper.h" |
17 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 17 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
18 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h
" | 18 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h
" |
19 #include "chrome/browser/sync_file_system/logger.h" | 19 #include "chrome/browser/sync_file_system/logger.h" |
20 #include "chrome/browser/sync_file_system/sync_file_metadata.h" | 20 #include "chrome/browser/sync_file_system/sync_file_metadata.h" |
21 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 21 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
22 #include "webkit/browser/fileapi/file_system_context.h" | 22 #include "storage/browser/fileapi/file_system_context.h" |
23 #include "webkit/browser/fileapi/file_system_file_util.h" | 23 #include "storage/browser/fileapi/file_system_file_util.h" |
24 #include "webkit/browser/fileapi/file_system_operation_context.h" | 24 #include "storage/browser/fileapi/file_system_operation_context.h" |
25 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 25 #include "storage/browser/fileapi/file_system_operation_runner.h" |
26 #include "webkit/common/blob/scoped_file.h" | 26 #include "storage/common/blob/scoped_file.h" |
27 #include "webkit/common/fileapi/file_system_util.h" | 27 #include "storage/common/fileapi/file_system_util.h" |
28 | 28 |
29 using fileapi::FileSystemContext; | 29 using storage::FileSystemContext; |
30 using fileapi::FileSystemFileUtil; | 30 using storage::FileSystemFileUtil; |
31 using fileapi::FileSystemOperation; | 31 using storage::FileSystemOperation; |
32 using fileapi::FileSystemOperationContext; | 32 using storage::FileSystemOperationContext; |
33 using fileapi::FileSystemURL; | 33 using storage::FileSystemURL; |
34 | 34 |
35 namespace sync_file_system { | 35 namespace sync_file_system { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 const int kMaxConcurrentSyncableOperation = 3; | 39 const int kMaxConcurrentSyncableOperation = 3; |
40 const int kNotifyChangesDurationInSec = 1; | 40 const int kNotifyChangesDurationInSec = 1; |
41 const int kMaxURLsToFetchForLocalSync = 5; | 41 const int kMaxURLsToFetchForLocalSync = 5; |
42 | 42 |
43 const base::FilePath::CharType kSnapshotDir[] = FILE_PATH_LITERAL("snapshots"); | 43 const base::FilePath::CharType kSnapshotDir[] = FILE_PATH_LITERAL("snapshots"); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 StatusCallbackQueue& callback_queue = | 75 StatusCallbackQueue& callback_queue = |
76 pending_initialize_callbacks_[file_system_context]; | 76 pending_initialize_callbacks_[file_system_context]; |
77 callback_queue.push_back(callback); | 77 callback_queue.push_back(callback); |
78 if (callback_queue.size() > 1) | 78 if (callback_queue.size() > 1) |
79 return; | 79 return; |
80 | 80 |
81 // The sync service always expects the origin (app) is initialized | 81 // The sync service always expects the origin (app) is initialized |
82 // for writable way (even when MaybeInitializeFileSystemContext is called | 82 // for writable way (even when MaybeInitializeFileSystemContext is called |
83 // from read-only OpenFileSystem), so open the filesystem with | 83 // from read-only OpenFileSystem), so open the filesystem with |
84 // CREATE_IF_NONEXISTENT here. | 84 // CREATE_IF_NONEXISTENT here. |
85 fileapi::FileSystemBackend::OpenFileSystemCallback open_filesystem_callback = | 85 storage::FileSystemBackend::OpenFileSystemCallback open_filesystem_callback = |
86 base::Bind(&LocalFileSyncContext::InitializeFileSystemContextOnIOThread, | 86 base::Bind(&LocalFileSyncContext::InitializeFileSystemContextOnIOThread, |
87 this, source_url, make_scoped_refptr(file_system_context)); | 87 this, |
| 88 source_url, |
| 89 make_scoped_refptr(file_system_context)); |
88 io_task_runner_->PostTask( | 90 io_task_runner_->PostTask( |
89 FROM_HERE, | 91 FROM_HERE, |
90 base::Bind(&fileapi::SandboxFileSystemBackendDelegate::OpenFileSystem, | 92 base::Bind(&storage::SandboxFileSystemBackendDelegate::OpenFileSystem, |
91 base::Unretained(file_system_context->sandbox_delegate()), | 93 base::Unretained(file_system_context->sandbox_delegate()), |
92 source_url, fileapi::kFileSystemTypeSyncable, | 94 source_url, |
93 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 95 storage::kFileSystemTypeSyncable, |
94 open_filesystem_callback, GURL())); | 96 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
| 97 open_filesystem_callback, |
| 98 GURL())); |
95 } | 99 } |
96 | 100 |
97 void LocalFileSyncContext::ShutdownOnUIThread() { | 101 void LocalFileSyncContext::ShutdownOnUIThread() { |
98 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 102 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
99 shutdown_on_ui_ = true; | 103 shutdown_on_ui_ = true; |
100 io_task_runner_->PostTask( | 104 io_task_runner_->PostTask( |
101 FROM_HERE, | 105 FROM_HERE, |
102 base::Bind(&LocalFileSyncContext::ShutdownOnIOThread, this)); | 106 base::Bind(&LocalFileSyncContext::ShutdownOnIOThread, this)); |
103 } | 107 } |
104 | 108 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 SyncFileSystemBackend::GetBackend(file_system_context); | 142 SyncFileSystemBackend::GetBackend(file_system_context); |
139 DCHECK(backend); | 143 DCHECK(backend); |
140 DCHECK(backend->change_tracker()); | 144 DCHECK(backend->change_tracker()); |
141 backend->change_tracker()->ClearChangesForURL(url); | 145 backend->change_tracker()->ClearChangesForURL(url); |
142 | 146 |
143 // Call the completion callback on UI thread. | 147 // Call the completion callback on UI thread. |
144 ui_task_runner_->PostTask(FROM_HERE, done_callback); | 148 ui_task_runner_->PostTask(FROM_HERE, done_callback); |
145 } | 149 } |
146 | 150 |
147 void LocalFileSyncContext::FinalizeSnapshotSync( | 151 void LocalFileSyncContext::FinalizeSnapshotSync( |
148 fileapi::FileSystemContext* file_system_context, | 152 storage::FileSystemContext* file_system_context, |
149 const fileapi::FileSystemURL& url, | 153 const storage::FileSystemURL& url, |
150 SyncStatusCode sync_finish_status, | 154 SyncStatusCode sync_finish_status, |
151 const base::Closure& done_callback) { | 155 const base::Closure& done_callback) { |
152 DCHECK(file_system_context); | 156 DCHECK(file_system_context); |
153 DCHECK(url.is_valid()); | 157 DCHECK(url.is_valid()); |
154 if (!file_system_context->default_file_task_runner()-> | 158 if (!file_system_context->default_file_task_runner()-> |
155 RunsTasksOnCurrentThread()) { | 159 RunsTasksOnCurrentThread()) { |
156 file_system_context->default_file_task_runner()->PostTask( | 160 file_system_context->default_file_task_runner()->PostTask( |
157 FROM_HERE, | 161 FROM_HERE, |
158 base::Bind(&LocalFileSyncContext::FinalizeSnapshotSync, | 162 base::Bind(&LocalFileSyncContext::FinalizeSnapshotSync, |
159 this, make_scoped_refptr(file_system_context), | 163 this, make_scoped_refptr(file_system_context), |
(...skipping 19 matching lines...) Expand all Loading... |
179 // to unblock sync activities. | 183 // to unblock sync activities. |
180 io_task_runner_->PostTask( | 184 io_task_runner_->PostTask( |
181 FROM_HERE, base::Bind( | 185 FROM_HERE, base::Bind( |
182 &LocalFileSyncContext::FinalizeSnapshotSyncOnIOThread, this, url)); | 186 &LocalFileSyncContext::FinalizeSnapshotSyncOnIOThread, this, url)); |
183 | 187 |
184 // Call the completion callback on UI thread. | 188 // Call the completion callback on UI thread. |
185 ui_task_runner_->PostTask(FROM_HERE, done_callback); | 189 ui_task_runner_->PostTask(FROM_HERE, done_callback); |
186 } | 190 } |
187 | 191 |
188 void LocalFileSyncContext::FinalizeExclusiveSync( | 192 void LocalFileSyncContext::FinalizeExclusiveSync( |
189 fileapi::FileSystemContext* file_system_context, | 193 storage::FileSystemContext* file_system_context, |
190 const fileapi::FileSystemURL& url, | 194 const storage::FileSystemURL& url, |
191 bool clear_local_changes, | 195 bool clear_local_changes, |
192 const base::Closure& done_callback) { | 196 const base::Closure& done_callback) { |
193 DCHECK(file_system_context); | 197 DCHECK(file_system_context); |
194 if (!url.is_valid()) { | 198 if (!url.is_valid()) { |
195 done_callback.Run(); | 199 done_callback.Run(); |
196 return; | 200 return; |
197 } | 201 } |
198 | 202 |
199 if (clear_local_changes) { | 203 if (clear_local_changes) { |
200 ClearChangesForURL(file_system_context, url, | 204 ClearChangesForURL(file_system_context, url, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 303 } |
300 | 304 |
301 void LocalFileSyncContext::HandleRemoteDelete( | 305 void LocalFileSyncContext::HandleRemoteDelete( |
302 FileSystemContext* file_system_context, | 306 FileSystemContext* file_system_context, |
303 const FileSystemURL& url, | 307 const FileSystemURL& url, |
304 const SyncStatusCallback& callback) { | 308 const SyncStatusCallback& callback) { |
305 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( | 309 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( |
306 file_system_context, url); | 310 file_system_context, url); |
307 | 311 |
308 // Handle root directory case differently. | 312 // Handle root directory case differently. |
309 if (fileapi::VirtualPath::IsRootPath(url.path())) { | 313 if (storage::VirtualPath::IsRootPath(url.path())) { |
310 DCHECK(!root_delete_helper_); | 314 DCHECK(!root_delete_helper_); |
311 root_delete_helper_.reset(new RootDeleteHelper( | 315 root_delete_helper_.reset(new RootDeleteHelper( |
312 file_system_context, sync_status(), url, | 316 file_system_context, sync_status(), url, |
313 base::Bind(&LocalFileSyncContext::DidApplyRemoteChange, | 317 base::Bind(&LocalFileSyncContext::DidApplyRemoteChange, |
314 this, url, callback))); | 318 this, url, callback))); |
315 root_delete_helper_->Run(); | 319 root_delete_helper_->Run(); |
316 return; | 320 return; |
317 } | 321 } |
318 | 322 |
319 file_system_context->operation_runner()->Remove( | 323 file_system_context->operation_runner()->Remove( |
320 url_for_sync, true /* recursive */, | 324 url_for_sync, true /* recursive */, |
321 base::Bind(&LocalFileSyncContext::DidApplyRemoteChange, | 325 base::Bind(&LocalFileSyncContext::DidApplyRemoteChange, |
322 this, url, callback)); | 326 this, url, callback)); |
323 } | 327 } |
324 | 328 |
325 void LocalFileSyncContext::HandleRemoteAddOrUpdate( | 329 void LocalFileSyncContext::HandleRemoteAddOrUpdate( |
326 FileSystemContext* file_system_context, | 330 FileSystemContext* file_system_context, |
327 const FileChange& change, | 331 const FileChange& change, |
328 const base::FilePath& local_path, | 332 const base::FilePath& local_path, |
329 const FileSystemURL& url, | 333 const FileSystemURL& url, |
330 const SyncStatusCallback& callback) { | 334 const SyncStatusCallback& callback) { |
331 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( | 335 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( |
332 file_system_context, url); | 336 file_system_context, url); |
333 | 337 |
334 if (fileapi::VirtualPath::IsRootPath(url.path())) { | 338 if (storage::VirtualPath::IsRootPath(url.path())) { |
335 DidApplyRemoteChange(url, callback, base::File::FILE_OK); | 339 DidApplyRemoteChange(url, callback, base::File::FILE_OK); |
336 return; | 340 return; |
337 } | 341 } |
338 | 342 |
339 file_system_context->operation_runner()->Remove( | 343 file_system_context->operation_runner()->Remove( |
340 url_for_sync, true /* recursive */, | 344 url_for_sync, true /* recursive */, |
341 base::Bind( | 345 base::Bind( |
342 &LocalFileSyncContext::DidRemoveExistingEntryForRemoteAddOrUpdate, | 346 &LocalFileSyncContext::DidRemoveExistingEntryForRemoteAddOrUpdate, |
343 this, | 347 this, |
344 make_scoped_refptr(file_system_context), | 348 make_scoped_refptr(file_system_context), |
(...skipping 24 matching lines...) Expand all Loading... |
369 | 373 |
370 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( | 374 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( |
371 file_system_context, url); | 375 file_system_context, url); |
372 FileSystemOperation::StatusCallback operation_callback = base::Bind( | 376 FileSystemOperation::StatusCallback operation_callback = base::Bind( |
373 &LocalFileSyncContext::DidApplyRemoteChange, this, url, callback); | 377 &LocalFileSyncContext::DidApplyRemoteChange, this, url, callback); |
374 | 378 |
375 DCHECK_EQ(FileChange::FILE_CHANGE_ADD_OR_UPDATE, change.change()); | 379 DCHECK_EQ(FileChange::FILE_CHANGE_ADD_OR_UPDATE, change.change()); |
376 switch (change.file_type()) { | 380 switch (change.file_type()) { |
377 case SYNC_FILE_TYPE_FILE: { | 381 case SYNC_FILE_TYPE_FILE: { |
378 DCHECK(!local_path.empty()); | 382 DCHECK(!local_path.empty()); |
379 base::FilePath dir_path = fileapi::VirtualPath::DirName(url.path()); | 383 base::FilePath dir_path = storage::VirtualPath::DirName(url.path()); |
380 if (dir_path.empty() || | 384 if (dir_path.empty() || |
381 fileapi::VirtualPath::DirName(dir_path) == dir_path) { | 385 storage::VirtualPath::DirName(dir_path) == dir_path) { |
382 // Copying into the root directory. | 386 // Copying into the root directory. |
383 file_system_context->operation_runner()->CopyInForeignFile( | 387 file_system_context->operation_runner()->CopyInForeignFile( |
384 local_path, url_for_sync, operation_callback); | 388 local_path, url_for_sync, operation_callback); |
385 } else { | 389 } else { |
386 FileSystemURL dir_url = file_system_context->CreateCrackedFileSystemURL( | 390 FileSystemURL dir_url = file_system_context->CreateCrackedFileSystemURL( |
387 url_for_sync.origin(), | 391 url_for_sync.origin(), |
388 url_for_sync.mount_type(), | 392 url_for_sync.mount_type(), |
389 fileapi::VirtualPath::DirName(url_for_sync.virtual_path())); | 393 storage::VirtualPath::DirName(url_for_sync.virtual_path())); |
390 file_system_context->operation_runner()->CreateDirectory( | 394 file_system_context->operation_runner()->CreateDirectory( |
391 dir_url, | 395 dir_url, |
392 false /* exclusive */, | 396 false /* exclusive */, |
393 true /* recursive */, | 397 true /* recursive */, |
394 base::Bind(&LocalFileSyncContext::DidCreateDirectoryForCopyIn, | 398 base::Bind(&LocalFileSyncContext::DidCreateDirectoryForCopyIn, |
395 this, | 399 this, |
396 make_scoped_refptr(file_system_context), | 400 make_scoped_refptr(file_system_context), |
397 local_path, | 401 local_path, |
398 url, | 402 url, |
399 operation_callback)); | 403 operation_callback)); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 493 |
490 // Fire the callback on UI thread. | 494 // Fire the callback on UI thread. |
491 ui_task_runner_->PostTask(FROM_HERE, | 495 ui_task_runner_->PostTask(FROM_HERE, |
492 base::Bind(callback, | 496 base::Bind(callback, |
493 SYNC_STATUS_OK, | 497 SYNC_STATUS_OK, |
494 !changes.empty())); | 498 !changes.empty())); |
495 } | 499 } |
496 | 500 |
497 void LocalFileSyncContext::PromoteDemotedChanges( | 501 void LocalFileSyncContext::PromoteDemotedChanges( |
498 const GURL& origin, | 502 const GURL& origin, |
499 fileapi::FileSystemContext* file_system_context, | 503 storage::FileSystemContext* file_system_context, |
500 const base::Closure& callback) { | 504 const base::Closure& callback) { |
501 // This is initially called on UI thread and to be relayed to FILE thread. | 505 // This is initially called on UI thread and to be relayed to FILE thread. |
502 DCHECK(file_system_context); | 506 DCHECK(file_system_context); |
503 if (!file_system_context->default_file_task_runner()-> | 507 if (!file_system_context->default_file_task_runner()-> |
504 RunsTasksOnCurrentThread()) { | 508 RunsTasksOnCurrentThread()) { |
505 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 509 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
506 file_system_context->default_file_task_runner()->PostTask( | 510 file_system_context->default_file_task_runner()->PostTask( |
507 FROM_HERE, | 511 FROM_HERE, |
508 base::Bind(&LocalFileSyncContext::PromoteDemotedChanges, | 512 base::Bind(&LocalFileSyncContext::PromoteDemotedChanges, |
509 this, origin, make_scoped_refptr(file_system_context), | 513 this, origin, make_scoped_refptr(file_system_context), |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 } | 795 } |
792 | 796 |
793 void LocalFileSyncContext::TryPrepareForLocalSync( | 797 void LocalFileSyncContext::TryPrepareForLocalSync( |
794 FileSystemContext* file_system_context, | 798 FileSystemContext* file_system_context, |
795 const LocalFileSyncInfoCallback& callback, | 799 const LocalFileSyncInfoCallback& callback, |
796 scoped_ptr<FileSystemURLQueue> urls) { | 800 scoped_ptr<FileSystemURLQueue> urls) { |
797 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 801 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
798 DCHECK(urls); | 802 DCHECK(urls); |
799 | 803 |
800 if (shutdown_on_ui_) { | 804 if (shutdown_on_ui_) { |
801 callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo(), | 805 callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo(), storage::ScopedFile()); |
802 webkit_blob::ScopedFile()); | |
803 return; | 806 return; |
804 } | 807 } |
805 | 808 |
806 if (urls->empty()) { | 809 if (urls->empty()) { |
807 callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC, LocalFileSyncInfo(), | 810 callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC, |
808 webkit_blob::ScopedFile()); | 811 LocalFileSyncInfo(), |
| 812 storage::ScopedFile()); |
809 return; | 813 return; |
810 } | 814 } |
811 | 815 |
812 const FileSystemURL url = urls->front(); | 816 const FileSystemURL url = urls->front(); |
813 urls->pop_front(); | 817 urls->pop_front(); |
814 | 818 |
815 PrepareForSync( | 819 PrepareForSync( |
816 file_system_context, url, SYNC_SNAPSHOT, | 820 file_system_context, url, SYNC_SNAPSHOT, |
817 base::Bind(&LocalFileSyncContext::DidTryPrepareForLocalSync, | 821 base::Bind(&LocalFileSyncContext::DidTryPrepareForLocalSync, |
818 this, make_scoped_refptr(file_system_context), | 822 this, make_scoped_refptr(file_system_context), |
819 base::Passed(&urls), callback)); | 823 base::Passed(&urls), callback)); |
820 } | 824 } |
821 | 825 |
822 void LocalFileSyncContext::DidTryPrepareForLocalSync( | 826 void LocalFileSyncContext::DidTryPrepareForLocalSync( |
823 FileSystemContext* file_system_context, | 827 FileSystemContext* file_system_context, |
824 scoped_ptr<FileSystemURLQueue> remaining_urls, | 828 scoped_ptr<FileSystemURLQueue> remaining_urls, |
825 const LocalFileSyncInfoCallback& callback, | 829 const LocalFileSyncInfoCallback& callback, |
826 SyncStatusCode status, | 830 SyncStatusCode status, |
827 const LocalFileSyncInfo& sync_file_info, | 831 const LocalFileSyncInfo& sync_file_info, |
828 webkit_blob::ScopedFile snapshot) { | 832 storage::ScopedFile snapshot) { |
829 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 833 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
830 if (status != SYNC_STATUS_FILE_BUSY) { | 834 if (status != SYNC_STATUS_FILE_BUSY) { |
831 PromoteDemotedChangesForURLs(file_system_context, | 835 PromoteDemotedChangesForURLs(file_system_context, |
832 remaining_urls.Pass()); | 836 remaining_urls.Pass()); |
833 callback.Run(status, sync_file_info, snapshot.Pass()); | 837 callback.Run(status, sync_file_info, snapshot.Pass()); |
834 return; | 838 return; |
835 } | 839 } |
836 | 840 |
837 PromoteDemotedChangesForURL(file_system_context, sync_file_info.url); | 841 PromoteDemotedChangesForURL(file_system_context, sync_file_info.url); |
838 | 842 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 SyncStatusCode status, | 894 SyncStatusCode status, |
891 const FileSystemURL& url, | 895 const FileSystemURL& url, |
892 SyncMode sync_mode, | 896 SyncMode sync_mode, |
893 const LocalFileSyncInfoCallback& callback) { | 897 const LocalFileSyncInfoCallback& callback) { |
894 // This gets called on UI thread and relays the task on FILE thread. | 898 // This gets called on UI thread and relays the task on FILE thread. |
895 DCHECK(file_system_context); | 899 DCHECK(file_system_context); |
896 if (!file_system_context->default_file_task_runner()-> | 900 if (!file_system_context->default_file_task_runner()-> |
897 RunsTasksOnCurrentThread()) { | 901 RunsTasksOnCurrentThread()) { |
898 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 902 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
899 if (shutdown_on_ui_) { | 903 if (shutdown_on_ui_) { |
900 callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo(), | 904 callback.Run( |
901 webkit_blob::ScopedFile()); | 905 SYNC_STATUS_ABORT, LocalFileSyncInfo(), storage::ScopedFile()); |
902 return; | 906 return; |
903 } | 907 } |
904 file_system_context->default_file_task_runner()->PostTask( | 908 file_system_context->default_file_task_runner()->PostTask( |
905 FROM_HERE, | 909 FROM_HERE, |
906 base::Bind(&LocalFileSyncContext::DidGetWritingStatusForSync, | 910 base::Bind(&LocalFileSyncContext::DidGetWritingStatusForSync, |
907 this, make_scoped_refptr(file_system_context), | 911 this, make_scoped_refptr(file_system_context), |
908 status, url, sync_mode, callback)); | 912 status, url, sync_mode, callback)); |
909 return; | 913 return; |
910 } | 914 } |
911 | 915 |
(...skipping 10 matching lines...) Expand all Loading... |
922 file_system_context->sandbox_delegate()->sync_file_util(); | 926 file_system_context->sandbox_delegate()->sync_file_util(); |
923 DCHECK(file_util); | 927 DCHECK(file_util); |
924 | 928 |
925 base::File::Error file_error = file_util->GetFileInfo( | 929 base::File::Error file_error = file_util->GetFileInfo( |
926 make_scoped_ptr( | 930 make_scoped_ptr( |
927 new FileSystemOperationContext(file_system_context)).get(), | 931 new FileSystemOperationContext(file_system_context)).get(), |
928 url, | 932 url, |
929 &file_info, | 933 &file_info, |
930 &platform_path); | 934 &platform_path); |
931 | 935 |
932 webkit_blob::ScopedFile snapshot; | 936 storage::ScopedFile snapshot; |
933 if (file_error == base::File::FILE_OK && sync_mode == SYNC_SNAPSHOT) { | 937 if (file_error == base::File::FILE_OK && sync_mode == SYNC_SNAPSHOT) { |
934 base::FilePath snapshot_path; | 938 base::FilePath snapshot_path; |
935 base::CreateTemporaryFileInDir(local_base_path_.Append(kSnapshotDir), | 939 base::CreateTemporaryFileInDir(local_base_path_.Append(kSnapshotDir), |
936 &snapshot_path); | 940 &snapshot_path); |
937 if (base::CopyFile(platform_path, snapshot_path)) { | 941 if (base::CopyFile(platform_path, snapshot_path)) { |
938 platform_path = snapshot_path; | 942 platform_path = snapshot_path; |
939 snapshot = webkit_blob::ScopedFile( | 943 snapshot = |
940 snapshot_path, | 944 storage::ScopedFile(snapshot_path, |
941 webkit_blob::ScopedFile::DELETE_ON_SCOPE_OUT, | 945 storage::ScopedFile::DELETE_ON_SCOPE_OUT, |
942 file_system_context->default_file_task_runner()); | 946 file_system_context->default_file_task_runner()); |
943 } | 947 } |
944 } | 948 } |
945 | 949 |
946 if (status == SYNC_STATUS_OK && | 950 if (status == SYNC_STATUS_OK && |
947 file_error != base::File::FILE_OK && | 951 file_error != base::File::FILE_OK && |
948 file_error != base::File::FILE_ERROR_NOT_FOUND) { | 952 file_error != base::File::FILE_ERROR_NOT_FOUND) { |
949 status = FileErrorToSyncStatusCode(file_error); | 953 status = FileErrorToSyncStatusCode(file_error); |
950 } | 954 } |
951 | 955 |
952 DCHECK(!file_info.is_symbolic_link); | 956 DCHECK(!file_info.is_symbolic_link); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 return; | 1065 return; |
1062 } | 1066 } |
1063 | 1067 |
1064 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( | 1068 FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync( |
1065 file_system_context, dest_url); | 1069 file_system_context, dest_url); |
1066 file_system_context->operation_runner()->CopyInForeignFile( | 1070 file_system_context->operation_runner()->CopyInForeignFile( |
1067 local_path, url_for_sync, callback); | 1071 local_path, url_for_sync, callback); |
1068 } | 1072 } |
1069 | 1073 |
1070 } // namespace sync_file_system | 1074 } // namespace sync_file_system |
OLD | NEW |