OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/drive_backend/remote_change_processor_
on_worker.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/remote_change_processor_
on_worker.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/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 const storage::FileSystemURL& url, | 34 const storage::FileSystemURL& url, |
35 const PrepareChangeCallback& callback) { | 35 const PrepareChangeCallback& callback) { |
36 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 36 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
37 | 37 |
38 ui_task_runner_->PostTask( | 38 ui_task_runner_->PostTask( |
39 FROM_HERE, | 39 FROM_HERE, |
40 base::Bind(&RemoteChangeProcessorWrapper::PrepareForProcessRemoteChange, | 40 base::Bind(&RemoteChangeProcessorWrapper::PrepareForProcessRemoteChange, |
41 wrapper_, | 41 wrapper_, |
42 url, | 42 url, |
43 RelayCallbackToTaskRunner( | 43 RelayCallbackToTaskRunner( |
44 worker_task_runner_, | 44 worker_task_runner_.get(), FROM_HERE, callback))); |
45 FROM_HERE, | |
46 callback))); | |
47 } | 45 } |
48 | 46 |
49 void RemoteChangeProcessorOnWorker::ApplyRemoteChange( | 47 void RemoteChangeProcessorOnWorker::ApplyRemoteChange( |
50 const FileChange& change, | 48 const FileChange& change, |
51 const base::FilePath& local_path, | 49 const base::FilePath& local_path, |
52 const storage::FileSystemURL& url, | 50 const storage::FileSystemURL& url, |
53 const SyncStatusCallback& callback) { | 51 const SyncStatusCallback& callback) { |
54 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 52 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
55 | 53 |
56 ui_task_runner_->PostTask( | 54 ui_task_runner_->PostTask( |
57 FROM_HERE, | 55 FROM_HERE, |
58 base::Bind(&RemoteChangeProcessorWrapper::ApplyRemoteChange, | 56 base::Bind(&RemoteChangeProcessorWrapper::ApplyRemoteChange, |
59 wrapper_, | 57 wrapper_, |
60 change, | 58 change, |
61 local_path, | 59 local_path, |
62 url, | 60 url, |
63 RelayCallbackToTaskRunner( | 61 RelayCallbackToTaskRunner( |
64 worker_task_runner_, | 62 worker_task_runner_.get(), FROM_HERE, callback))); |
65 FROM_HERE, | |
66 callback))); | |
67 } | 63 } |
68 | 64 |
69 void RemoteChangeProcessorOnWorker::FinalizeRemoteSync( | 65 void RemoteChangeProcessorOnWorker::FinalizeRemoteSync( |
70 const storage::FileSystemURL& url, | 66 const storage::FileSystemURL& url, |
71 bool clear_local_changes, | 67 bool clear_local_changes, |
72 const base::Closure& completion_callback) { | 68 const base::Closure& completion_callback) { |
73 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 69 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
74 | 70 |
75 ui_task_runner_->PostTask( | 71 ui_task_runner_->PostTask( |
76 FROM_HERE, | 72 FROM_HERE, |
77 base::Bind(&RemoteChangeProcessorWrapper::FinalizeRemoteSync, | 73 base::Bind( |
78 wrapper_, | 74 &RemoteChangeProcessorWrapper::FinalizeRemoteSync, |
79 url, | 75 wrapper_, |
80 clear_local_changes, | 76 url, |
81 RelayCallbackToTaskRunner( | 77 clear_local_changes, |
82 worker_task_runner_, | 78 RelayCallbackToTaskRunner( |
83 FROM_HERE, | 79 worker_task_runner_.get(), FROM_HERE, completion_callback))); |
84 completion_callback))); | |
85 } | 80 } |
86 | 81 |
87 void RemoteChangeProcessorOnWorker::RecordFakeLocalChange( | 82 void RemoteChangeProcessorOnWorker::RecordFakeLocalChange( |
88 const storage::FileSystemURL& url, | 83 const storage::FileSystemURL& url, |
89 const FileChange& change, | 84 const FileChange& change, |
90 const SyncStatusCallback& callback) { | 85 const SyncStatusCallback& callback) { |
91 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 86 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
92 | 87 |
93 ui_task_runner_->PostTask( | 88 ui_task_runner_->PostTask( |
94 FROM_HERE, | 89 FROM_HERE, |
95 base::Bind(&RemoteChangeProcessorWrapper::RecordFakeLocalChange, | 90 base::Bind(&RemoteChangeProcessorWrapper::RecordFakeLocalChange, |
96 wrapper_, | 91 wrapper_, |
97 url, | 92 url, |
98 change, | 93 change, |
99 RelayCallbackToTaskRunner( | 94 RelayCallbackToTaskRunner( |
100 worker_task_runner_, | 95 worker_task_runner_.get(), FROM_HERE, callback))); |
101 FROM_HERE, | |
102 callback))); | |
103 } | 96 } |
104 | 97 |
105 void RemoteChangeProcessorOnWorker::DetachFromSequence() { | 98 void RemoteChangeProcessorOnWorker::DetachFromSequence() { |
106 sequence_checker_.DetachFromSequence(); | 99 sequence_checker_.DetachFromSequence(); |
107 } | 100 } |
108 | 101 |
109 } // namespace drive_backend | 102 } // namespace drive_backend |
110 } // namespace sync_file_system | 103 } // namespace sync_file_system |
OLD | NEW |