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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 225 } |
226 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 226 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
227 LocalFileSystemOperation* operation = CreateFileSystemOperationForSync( | 227 LocalFileSystemOperation* operation = CreateFileSystemOperationForSync( |
228 file_system_context); | 228 file_system_context); |
229 DCHECK(operation); | 229 DCHECK(operation); |
230 operation->GetMetadata( | 230 operation->GetMetadata( |
231 url, base::Bind(&LocalFileSyncContext::DidGetFileMetadata, | 231 url, base::Bind(&LocalFileSyncContext::DidGetFileMetadata, |
232 this, callback)); | 232 this, callback)); |
233 } | 233 } |
234 | 234 |
| 235 void LocalFileSyncContext::HasPendingLocalChanges( |
| 236 FileSystemContext* file_system_context, |
| 237 const FileSystemURL& url, |
| 238 const HasPendingLocalChangeCallback& callback) { |
| 239 // This gets called on UI thread and relays the task on FILE thread. |
| 240 DCHECK(file_system_context); |
| 241 if (!file_system_context->task_runners()->file_task_runner()-> |
| 242 RunsTasksOnCurrentThread()) { |
| 243 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 244 file_system_context->task_runners()->file_task_runner()->PostTask( |
| 245 FROM_HERE, |
| 246 base::Bind(&LocalFileSyncContext::HasPendingLocalChanges, |
| 247 this, make_scoped_refptr(file_system_context), |
| 248 url, callback)); |
| 249 return; |
| 250 } |
| 251 |
| 252 DCHECK(file_system_context->change_tracker()); |
| 253 FileChangeList changes; |
| 254 file_system_context->change_tracker()->GetChangesForURL(url, &changes); |
| 255 |
| 256 // Fire the callback on UI thread. |
| 257 ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, !changes.empty())); |
| 258 } |
| 259 |
235 void LocalFileSyncContext::AddOriginChangeObserver( | 260 void LocalFileSyncContext::AddOriginChangeObserver( |
236 LocalOriginChangeObserver* observer) { | 261 LocalOriginChangeObserver* observer) { |
237 origin_change_observers_.AddObserver(observer); | 262 origin_change_observers_.AddObserver(observer); |
238 } | 263 } |
239 | 264 |
240 void LocalFileSyncContext::RemoveOriginChangeObserver( | 265 void LocalFileSyncContext::RemoveOriginChangeObserver( |
241 LocalOriginChangeObserver* observer) { | 266 LocalOriginChangeObserver* observer) { |
242 origin_change_observers_.RemoveObserver(observer); | 267 origin_change_observers_.RemoveObserver(observer); |
243 } | 268 } |
244 | 269 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 metadata)); | 583 metadata)); |
559 } | 584 } |
560 | 585 |
561 base::TimeDelta LocalFileSyncContext::NotifyChangesDuration() { | 586 base::TimeDelta LocalFileSyncContext::NotifyChangesDuration() { |
562 if (mock_notify_changes_duration_in_sec_ >= 0) | 587 if (mock_notify_changes_duration_in_sec_ >= 0) |
563 return base::TimeDelta::FromSeconds(mock_notify_changes_duration_in_sec_); | 588 return base::TimeDelta::FromSeconds(mock_notify_changes_duration_in_sec_); |
564 return base::TimeDelta::FromSeconds(kNotifyChangesDurationInSec); | 589 return base::TimeDelta::FromSeconds(kNotifyChangesDurationInSec); |
565 } | 590 } |
566 | 591 |
567 } // namespace fileapi | 592 } // namespace fileapi |
OLD | NEW |