OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/fileapi/syncable/local_file_sync_context.h" | 5 #include "webkit/fileapi/syncable/local_file_sync_context.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 file_system_context->task_runners()->file_task_runner()->PostTaskAndReply( | 85 file_system_context->task_runners()->file_task_runner()->PostTaskAndReply( |
86 FROM_HERE, | 86 FROM_HERE, |
87 base::Bind(&LocalFileSyncContext::GetNextURLsForSyncOnFileThread, | 87 base::Bind(&LocalFileSyncContext::GetNextURLsForSyncOnFileThread, |
88 this, make_scoped_refptr(file_system_context), | 88 this, make_scoped_refptr(file_system_context), |
89 base::Unretained(urls)), | 89 base::Unretained(urls)), |
90 base::Bind(&LocalFileSyncContext::TryPrepareForLocalSync, | 90 base::Bind(&LocalFileSyncContext::TryPrepareForLocalSync, |
91 this, make_scoped_refptr(file_system_context), | 91 this, make_scoped_refptr(file_system_context), |
92 base::Owned(urls), callback)); | 92 base::Owned(urls), callback)); |
93 } | 93 } |
94 | 94 |
95 void LocalFileSyncContext::FinalizeSyncForURL( | 95 void LocalFileSyncContext::ClearChangesForURL( |
96 FileSystemContext* file_system_context, | 96 FileSystemContext* file_system_context, |
97 const FileSystemURL& url) { | 97 const FileSystemURL& url, |
| 98 const base::Closure& done_callback) { |
98 // This is initially called on UI thread and to be relayed to FILE thread. | 99 // This is initially called on UI thread and to be relayed to FILE thread. |
99 DCHECK(file_system_context); | 100 DCHECK(file_system_context); |
100 if (!file_system_context->task_runners()->file_task_runner()-> | 101 if (!file_system_context->task_runners()->file_task_runner()-> |
101 RunsTasksOnCurrentThread()) { | 102 RunsTasksOnCurrentThread()) { |
102 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 103 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
103 file_system_context->task_runners()->file_task_runner()->PostTask( | 104 file_system_context->task_runners()->file_task_runner()->PostTask( |
104 FROM_HERE, | 105 FROM_HERE, |
105 base::Bind(&LocalFileSyncContext::FinalizeSyncForURL, | 106 base::Bind(&LocalFileSyncContext::ClearChangesForURL, |
106 this, make_scoped_refptr(file_system_context), url)); | 107 this, make_scoped_refptr(file_system_context), |
| 108 url, done_callback)); |
107 return; | 109 return; |
108 } | 110 } |
109 DCHECK(file_system_context->change_tracker()); | 111 DCHECK(file_system_context->change_tracker()); |
110 file_system_context->change_tracker()->ClearChangesForURL(url); | 112 file_system_context->change_tracker()->ClearChangesForURL(url); |
111 | 113 |
112 // Call out to the IO thread to re-enable writing. | 114 // Call the completion callback on UI thread. |
| 115 ui_task_runner_->PostTask(FROM_HERE, done_callback); |
| 116 } |
| 117 |
| 118 void LocalFileSyncContext::ClearSyncFlagForURL(const FileSystemURL& url) { |
| 119 // This is initially called on UI thread and to be relayed to IO thread. |
113 io_task_runner_->PostTask( | 120 io_task_runner_->PostTask( |
114 FROM_HERE, | 121 FROM_HERE, |
115 base::Bind(&LocalFileSyncContext::EnableWritingOnIOThread, | 122 base::Bind(&LocalFileSyncContext::EnableWritingOnIOThread, |
116 this, url)); | 123 this, url)); |
117 } | 124 } |
118 | 125 |
119 void LocalFileSyncContext::PrepareForSync( | 126 void LocalFileSyncContext::PrepareForSync( |
120 FileSystemContext* file_system_context, | 127 FileSystemContext* file_system_context, |
121 const FileSystemURL& url, | 128 const FileSystemURL& url, |
122 const LocalFileSyncInfoCallback& callback) { | 129 const LocalFileSyncInfoCallback& callback) { |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 metadata)); | 590 metadata)); |
584 } | 591 } |
585 | 592 |
586 base::TimeDelta LocalFileSyncContext::NotifyChangesDuration() { | 593 base::TimeDelta LocalFileSyncContext::NotifyChangesDuration() { |
587 if (mock_notify_changes_duration_in_sec_ >= 0) | 594 if (mock_notify_changes_duration_in_sec_ >= 0) |
588 return base::TimeDelta::FromSeconds(mock_notify_changes_duration_in_sec_); | 595 return base::TimeDelta::FromSeconds(mock_notify_changes_duration_in_sec_); |
589 return base::TimeDelta::FromSeconds(kNotifyChangesDurationInSec); | 596 return base::TimeDelta::FromSeconds(kNotifyChangesDurationInSec); |
590 } | 597 } |
591 | 598 |
592 } // namespace fileapi | 599 } // namespace fileapi |
OLD | NEW |