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 13 matching lines...) Expand all Loading... |
24 ui_task_runner_(ui_task_runner), | 24 ui_task_runner_(ui_task_runner), |
25 worker_task_runner_(worker_task_runner) { | 25 worker_task_runner_(worker_task_runner) { |
26 sequence_checker_.DetachFromSequence(); | 26 sequence_checker_.DetachFromSequence(); |
27 } | 27 } |
28 | 28 |
29 RemoteChangeProcessorOnWorker::~RemoteChangeProcessorOnWorker() { | 29 RemoteChangeProcessorOnWorker::~RemoteChangeProcessorOnWorker() { |
30 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 30 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
31 } | 31 } |
32 | 32 |
33 void RemoteChangeProcessorOnWorker::PrepareForProcessRemoteChange( | 33 void RemoteChangeProcessorOnWorker::PrepareForProcessRemoteChange( |
34 const fileapi::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_, |
45 FROM_HERE, | 45 FROM_HERE, |
46 callback))); | 46 callback))); |
47 } | 47 } |
48 | 48 |
49 void RemoteChangeProcessorOnWorker::ApplyRemoteChange( | 49 void RemoteChangeProcessorOnWorker::ApplyRemoteChange( |
50 const FileChange& change, | 50 const FileChange& change, |
51 const base::FilePath& local_path, | 51 const base::FilePath& local_path, |
52 const fileapi::FileSystemURL& url, | 52 const storage::FileSystemURL& url, |
53 const SyncStatusCallback& callback) { | 53 const SyncStatusCallback& callback) { |
54 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 54 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
55 | 55 |
56 ui_task_runner_->PostTask( | 56 ui_task_runner_->PostTask( |
57 FROM_HERE, | 57 FROM_HERE, |
58 base::Bind(&RemoteChangeProcessorWrapper::ApplyRemoteChange, | 58 base::Bind(&RemoteChangeProcessorWrapper::ApplyRemoteChange, |
59 wrapper_, | 59 wrapper_, |
60 change, | 60 change, |
61 local_path, | 61 local_path, |
62 url, | 62 url, |
63 RelayCallbackToTaskRunner( | 63 RelayCallbackToTaskRunner( |
64 worker_task_runner_, | 64 worker_task_runner_, |
65 FROM_HERE, | 65 FROM_HERE, |
66 callback))); | 66 callback))); |
67 } | 67 } |
68 | 68 |
69 void RemoteChangeProcessorOnWorker::FinalizeRemoteSync( | 69 void RemoteChangeProcessorOnWorker::FinalizeRemoteSync( |
70 const fileapi::FileSystemURL& url, | 70 const storage::FileSystemURL& url, |
71 bool clear_local_changes, | 71 bool clear_local_changes, |
72 const base::Closure& completion_callback) { | 72 const base::Closure& completion_callback) { |
73 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 73 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
74 | 74 |
75 ui_task_runner_->PostTask( | 75 ui_task_runner_->PostTask( |
76 FROM_HERE, | 76 FROM_HERE, |
77 base::Bind(&RemoteChangeProcessorWrapper::FinalizeRemoteSync, | 77 base::Bind(&RemoteChangeProcessorWrapper::FinalizeRemoteSync, |
78 wrapper_, | 78 wrapper_, |
79 url, | 79 url, |
80 clear_local_changes, | 80 clear_local_changes, |
81 RelayCallbackToTaskRunner( | 81 RelayCallbackToTaskRunner( |
82 worker_task_runner_, | 82 worker_task_runner_, |
83 FROM_HERE, | 83 FROM_HERE, |
84 completion_callback))); | 84 completion_callback))); |
85 } | 85 } |
86 | 86 |
87 void RemoteChangeProcessorOnWorker::RecordFakeLocalChange( | 87 void RemoteChangeProcessorOnWorker::RecordFakeLocalChange( |
88 const fileapi::FileSystemURL& url, | 88 const storage::FileSystemURL& url, |
89 const FileChange& change, | 89 const FileChange& change, |
90 const SyncStatusCallback& callback) { | 90 const SyncStatusCallback& callback) { |
91 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 91 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
92 | 92 |
93 ui_task_runner_->PostTask( | 93 ui_task_runner_->PostTask( |
94 FROM_HERE, | 94 FROM_HERE, |
95 base::Bind(&RemoteChangeProcessorWrapper::RecordFakeLocalChange, | 95 base::Bind(&RemoteChangeProcessorWrapper::RecordFakeLocalChange, |
96 wrapper_, | 96 wrapper_, |
97 url, | 97 url, |
98 change, | 98 change, |
99 RelayCallbackToTaskRunner( | 99 RelayCallbackToTaskRunner( |
100 worker_task_runner_, | 100 worker_task_runner_, |
101 FROM_HERE, | 101 FROM_HERE, |
102 callback))); | 102 callback))); |
103 } | 103 } |
104 | 104 |
105 void RemoteChangeProcessorOnWorker::DetachFromSequence() { | 105 void RemoteChangeProcessorOnWorker::DetachFromSequence() { |
106 sequence_checker_.DetachFromSequence(); | 106 sequence_checker_.DetachFromSequence(); |
107 } | 107 } |
108 | 108 |
109 } // namespace drive_backend | 109 } // namespace drive_backend |
110 } // namespace sync_file_system | 110 } // namespace sync_file_system |
OLD | NEW |