Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: chrome/browser/sync_file_system/local/syncable_file_system_operation.cc

Issue 2129083002: Explicitly check various sync_file_system classes live on the IO thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests, remove unneeded check Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/sync_file_system/local/syncable_file_system_operation.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/syncable_file_system_operation.h " 5 #include "chrome/browser/sync_file_system/local/syncable_file_system_operation.h "
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" 11 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h"
12 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" 12 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
13 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h " 13 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h "
14 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" 14 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
15 #include "content/public/browser/browser_thread.h"
15 #include "net/url_request/url_request.h" 16 #include "net/url_request/url_request.h"
16 #include "storage/browser/blob/shareable_file_reference.h" 17 #include "storage/browser/blob/shareable_file_reference.h"
17 #include "storage/browser/fileapi/file_system_context.h" 18 #include "storage/browser/fileapi/file_system_context.h"
18 #include "storage/browser/fileapi/file_system_operation.h" 19 #include "storage/browser/fileapi/file_system_operation.h"
19 #include "storage/browser/fileapi/file_system_operation_context.h" 20 #include "storage/browser/fileapi/file_system_operation_context.h"
20 #include "storage/browser/fileapi/file_system_url.h" 21 #include "storage/browser/fileapi/file_system_url.h"
21 #include "storage/browser/fileapi/file_writer_delegate.h" 22 #include "storage/browser/fileapi/file_writer_delegate.h"
22 23
23 using storage::FileSystemURL; 24 using storage::FileSystemURL;
24 25
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 operation_.reset(); 62 operation_.reset();
62 } 63 }
63 64
64 const std::vector<FileSystemURL>& target_paths() const override { 65 const std::vector<FileSystemURL>& target_paths() const override {
65 return target_paths_; 66 return target_paths_;
66 } 67 }
67 68
68 private: 69 private:
69 base::WeakPtr<SyncableFileSystemOperation> operation_; 70 base::WeakPtr<SyncableFileSystemOperation> operation_;
70 base::Closure task_; 71 base::Closure task_;
71 std::vector<FileSystemURL> target_paths_; 72 const std::vector<FileSystemURL> target_paths_;
72 DISALLOW_COPY_AND_ASSIGN(QueueableTask); 73 DISALLOW_COPY_AND_ASSIGN(QueueableTask);
73 }; 74 };
74 75
75 SyncableFileSystemOperation::~SyncableFileSystemOperation() {} 76 SyncableFileSystemOperation::~SyncableFileSystemOperation() {}
76 77
77 void SyncableFileSystemOperation::CreateFile( 78 void SyncableFileSystemOperation::CreateFile(
78 const FileSystemURL& url, 79 const FileSystemURL& url,
79 bool exclusive, 80 bool exclusive,
80 const StatusCallback& callback) { 81 const StatusCallback& callback) {
81 DCHECK(CalledOnValidThread()); 82 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
82 if (!operation_runner_.get()) { 83 if (!operation_runner_.get()) {
83 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 84 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
84 return; 85 return;
85 } 86 }
86 DCHECK(operation_runner_.get()); 87 DCHECK(operation_runner_.get());
87 target_paths_.push_back(url); 88 target_paths_.push_back(url);
88 completion_callback_ = callback; 89 completion_callback_ = callback;
89 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( 90 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask(
90 weak_factory_.GetWeakPtr(), 91 weak_factory_.GetWeakPtr(),
91 base::Bind(&FileSystemOperation::CreateFile, 92 base::Bind(&FileSystemOperation::CreateFile,
92 base::Unretained(impl_.get()), url, exclusive, 93 base::Unretained(impl_.get()), url, exclusive,
93 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); 94 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr()))));
94 operation_runner_->PostOperationTask(std::move(task)); 95 operation_runner_->PostOperationTask(std::move(task));
95 } 96 }
96 97
97 void SyncableFileSystemOperation::CreateDirectory( 98 void SyncableFileSystemOperation::CreateDirectory(
98 const FileSystemURL& url, 99 const FileSystemURL& url,
99 bool exclusive, 100 bool exclusive,
100 bool recursive, 101 bool recursive,
101 const StatusCallback& callback) { 102 const StatusCallback& callback) {
102 DCHECK(CalledOnValidThread()); 103 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
103 if (!operation_runner_.get()) { 104 if (!operation_runner_.get()) {
104 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 105 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
105 return; 106 return;
106 } 107 }
107 DCHECK(operation_runner_.get()); 108 DCHECK(operation_runner_.get());
108 target_paths_.push_back(url); 109 target_paths_.push_back(url);
109 completion_callback_ = callback; 110 completion_callback_ = callback;
110 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( 111 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask(
111 weak_factory_.GetWeakPtr(), 112 weak_factory_.GetWeakPtr(),
112 base::Bind(&FileSystemOperation::CreateDirectory, 113 base::Bind(&FileSystemOperation::CreateDirectory,
113 base::Unretained(impl_.get()), url, exclusive, recursive, 114 base::Unretained(impl_.get()), url, exclusive, recursive,
114 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); 115 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr()))));
115 operation_runner_->PostOperationTask(std::move(task)); 116 operation_runner_->PostOperationTask(std::move(task));
116 } 117 }
117 118
118 void SyncableFileSystemOperation::Copy( 119 void SyncableFileSystemOperation::Copy(
119 const FileSystemURL& src_url, 120 const FileSystemURL& src_url,
120 const FileSystemURL& dest_url, 121 const FileSystemURL& dest_url,
121 CopyOrMoveOption option, 122 CopyOrMoveOption option,
122 ErrorBehavior error_behavior, 123 ErrorBehavior error_behavior,
123 const CopyProgressCallback& progress_callback, 124 const CopyProgressCallback& progress_callback,
124 const StatusCallback& callback) { 125 const StatusCallback& callback) {
125 DCHECK(CalledOnValidThread()); 126 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
126 if (!operation_runner_.get()) { 127 if (!operation_runner_.get()) {
127 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 128 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
128 return; 129 return;
129 } 130 }
130 DCHECK(operation_runner_.get()); 131 DCHECK(operation_runner_.get());
131 target_paths_.push_back(dest_url); 132 target_paths_.push_back(dest_url);
132 completion_callback_ = callback; 133 completion_callback_ = callback;
133 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( 134 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask(
134 weak_factory_.GetWeakPtr(), 135 weak_factory_.GetWeakPtr(),
135 base::Bind(&FileSystemOperation::Copy, base::Unretained(impl_.get()), 136 base::Bind(&FileSystemOperation::Copy, base::Unretained(impl_.get()),
136 src_url, dest_url, option, error_behavior, progress_callback, 137 src_url, dest_url, option, error_behavior, progress_callback,
137 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); 138 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr()))));
138 operation_runner_->PostOperationTask(std::move(task)); 139 operation_runner_->PostOperationTask(std::move(task));
139 } 140 }
140 141
141 void SyncableFileSystemOperation::Move( 142 void SyncableFileSystemOperation::Move(
142 const FileSystemURL& src_url, 143 const FileSystemURL& src_url,
143 const FileSystemURL& dest_url, 144 const FileSystemURL& dest_url,
144 CopyOrMoveOption option, 145 CopyOrMoveOption option,
145 const StatusCallback& callback) { 146 const StatusCallback& callback) {
146 DCHECK(CalledOnValidThread()); 147 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
147 if (!operation_runner_.get()) { 148 if (!operation_runner_.get()) {
148 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 149 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
149 return; 150 return;
150 } 151 }
151 DCHECK(operation_runner_.get()); 152 DCHECK(operation_runner_.get());
152 target_paths_.push_back(src_url); 153 target_paths_.push_back(src_url);
153 target_paths_.push_back(dest_url); 154 target_paths_.push_back(dest_url);
154 completion_callback_ = callback; 155 completion_callback_ = callback;
155 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( 156 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask(
156 weak_factory_.GetWeakPtr(), 157 weak_factory_.GetWeakPtr(),
157 base::Bind(&FileSystemOperation::Move, base::Unretained(impl_.get()), 158 base::Bind(&FileSystemOperation::Move, base::Unretained(impl_.get()),
158 src_url, dest_url, option, 159 src_url, dest_url, option,
159 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); 160 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr()))));
160 operation_runner_->PostOperationTask(std::move(task)); 161 operation_runner_->PostOperationTask(std::move(task));
161 } 162 }
162 163
163 void SyncableFileSystemOperation::DirectoryExists( 164 void SyncableFileSystemOperation::DirectoryExists(
164 const FileSystemURL& url, 165 const FileSystemURL& url,
165 const StatusCallback& callback) { 166 const StatusCallback& callback) {
166 DCHECK(CalledOnValidThread()); 167 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
167 impl_->DirectoryExists(url, callback); 168 impl_->DirectoryExists(url, callback);
168 } 169 }
169 170
170 void SyncableFileSystemOperation::FileExists( 171 void SyncableFileSystemOperation::FileExists(
171 const FileSystemURL& url, 172 const FileSystemURL& url,
172 const StatusCallback& callback) { 173 const StatusCallback& callback) {
173 DCHECK(CalledOnValidThread()); 174 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
174 impl_->FileExists(url, callback); 175 impl_->FileExists(url, callback);
175 } 176 }
176 177
177 void SyncableFileSystemOperation::GetMetadata( 178 void SyncableFileSystemOperation::GetMetadata(
178 const FileSystemURL& url, 179 const FileSystemURL& url,
179 int fields, 180 int fields,
180 const GetMetadataCallback& callback) { 181 const GetMetadataCallback& callback) {
181 DCHECK(CalledOnValidThread()); 182 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
182 impl_->GetMetadata(url, fields, callback); 183 impl_->GetMetadata(url, fields, callback);
183 } 184 }
184 185
185 void SyncableFileSystemOperation::ReadDirectory( 186 void SyncableFileSystemOperation::ReadDirectory(
186 const FileSystemURL& url, 187 const FileSystemURL& url,
187 const ReadDirectoryCallback& callback) { 188 const ReadDirectoryCallback& callback) {
188 DCHECK(CalledOnValidThread()); 189 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
189 // This is a read operation and there'd be no hard to let it go even if 190 // This is a read operation and there'd be no hard to let it go even if
190 // directory operation is disabled. (And we should allow this if it's made 191 // directory operation is disabled. (And we should allow this if it's made
191 // on the root directory) 192 // on the root directory)
192 impl_->ReadDirectory(url, callback); 193 impl_->ReadDirectory(url, callback);
193 } 194 }
194 195
195 void SyncableFileSystemOperation::Remove( 196 void SyncableFileSystemOperation::Remove(
196 const FileSystemURL& url, bool recursive, 197 const FileSystemURL& url, bool recursive,
197 const StatusCallback& callback) { 198 const StatusCallback& callback) {
198 DCHECK(CalledOnValidThread()); 199 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
199 if (!operation_runner_.get()) { 200 if (!operation_runner_.get()) {
200 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 201 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
201 return; 202 return;
202 } 203 }
203 DCHECK(operation_runner_.get()); 204 DCHECK(operation_runner_.get());
204 target_paths_.push_back(url); 205 target_paths_.push_back(url);
205 completion_callback_ = callback; 206 completion_callback_ = callback;
206 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( 207 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask(
207 weak_factory_.GetWeakPtr(), 208 weak_factory_.GetWeakPtr(),
208 base::Bind(&FileSystemOperation::Remove, base::Unretained(impl_.get()), 209 base::Bind(&FileSystemOperation::Remove, base::Unretained(impl_.get()),
209 url, recursive, 210 url, recursive,
210 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); 211 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr()))));
211 operation_runner_->PostOperationTask(std::move(task)); 212 operation_runner_->PostOperationTask(std::move(task));
212 } 213 }
213 214
214 void SyncableFileSystemOperation::Write( 215 void SyncableFileSystemOperation::Write(
215 const FileSystemURL& url, 216 const FileSystemURL& url,
216 std::unique_ptr<storage::FileWriterDelegate> writer_delegate, 217 std::unique_ptr<storage::FileWriterDelegate> writer_delegate,
217 std::unique_ptr<net::URLRequest> blob_request, 218 std::unique_ptr<net::URLRequest> blob_request,
218 const WriteCallback& callback) { 219 const WriteCallback& callback) {
219 DCHECK(CalledOnValidThread()); 220 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
220 if (!operation_runner_.get()) { 221 if (!operation_runner_.get()) {
221 callback.Run(base::File::FILE_ERROR_NOT_FOUND, 0, true); 222 callback.Run(base::File::FILE_ERROR_NOT_FOUND, 0, true);
222 return; 223 return;
223 } 224 }
224 DCHECK(operation_runner_.get()); 225 DCHECK(operation_runner_.get());
225 target_paths_.push_back(url); 226 target_paths_.push_back(url);
226 completion_callback_ = base::Bind(&WriteCallbackAdapter, callback); 227 completion_callback_ = base::Bind(&WriteCallbackAdapter, callback);
227 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( 228 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask(
228 weak_factory_.GetWeakPtr(), 229 weak_factory_.GetWeakPtr(),
229 base::Bind( 230 base::Bind(
230 &FileSystemOperation::Write, base::Unretained(impl_.get()), url, 231 &FileSystemOperation::Write, base::Unretained(impl_.get()), url,
231 base::Passed(&writer_delegate), base::Passed(&blob_request), 232 base::Passed(&writer_delegate), base::Passed(&blob_request),
232 base::Bind(&self::DidWrite, weak_factory_.GetWeakPtr(), callback)))); 233 base::Bind(&self::DidWrite, weak_factory_.GetWeakPtr(), callback))));
233 operation_runner_->PostOperationTask(std::move(task)); 234 operation_runner_->PostOperationTask(std::move(task));
234 } 235 }
235 236
236 void SyncableFileSystemOperation::Truncate(const FileSystemURL& url, 237 void SyncableFileSystemOperation::Truncate(const FileSystemURL& url,
237 int64_t length, 238 int64_t length,
238 const StatusCallback& callback) { 239 const StatusCallback& callback) {
239 DCHECK(CalledOnValidThread()); 240 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
240 if (!operation_runner_.get()) { 241 if (!operation_runner_.get()) {
241 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 242 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
242 return; 243 return;
243 } 244 }
244 DCHECK(operation_runner_.get()); 245 DCHECK(operation_runner_.get());
245 target_paths_.push_back(url); 246 target_paths_.push_back(url);
246 completion_callback_ = callback; 247 completion_callback_ = callback;
247 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( 248 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask(
248 weak_factory_.GetWeakPtr(), 249 weak_factory_.GetWeakPtr(),
249 base::Bind(&FileSystemOperation::Truncate, base::Unretained(impl_.get()), 250 base::Bind(&FileSystemOperation::Truncate, base::Unretained(impl_.get()),
250 url, length, 251 url, length,
251 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); 252 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr()))));
252 operation_runner_->PostOperationTask(std::move(task)); 253 operation_runner_->PostOperationTask(std::move(task));
253 } 254 }
254 255
255 void SyncableFileSystemOperation::TouchFile( 256 void SyncableFileSystemOperation::TouchFile(
256 const FileSystemURL& url, 257 const FileSystemURL& url,
257 const base::Time& last_access_time, 258 const base::Time& last_access_time,
258 const base::Time& last_modified_time, 259 const base::Time& last_modified_time,
259 const StatusCallback& callback) { 260 const StatusCallback& callback) {
260 DCHECK(CalledOnValidThread()); 261 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
261 impl_->TouchFile(url, last_access_time, last_modified_time, callback); 262 impl_->TouchFile(url, last_access_time, last_modified_time, callback);
262 } 263 }
263 264
264 void SyncableFileSystemOperation::OpenFile( 265 void SyncableFileSystemOperation::OpenFile(
265 const FileSystemURL& url, 266 const FileSystemURL& url,
266 int file_flags, 267 int file_flags,
267 const OpenFileCallback& callback) { 268 const OpenFileCallback& callback) {
268 NOTREACHED(); 269 NOTREACHED();
269 } 270 }
270 271
271 void SyncableFileSystemOperation::Cancel( 272 void SyncableFileSystemOperation::Cancel(
272 const StatusCallback& cancel_callback) { 273 const StatusCallback& cancel_callback) {
273 DCHECK(CalledOnValidThread()); 274 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
274 impl_->Cancel(cancel_callback); 275 impl_->Cancel(cancel_callback);
275 } 276 }
276 277
277 void SyncableFileSystemOperation::CreateSnapshotFile( 278 void SyncableFileSystemOperation::CreateSnapshotFile(
278 const FileSystemURL& path, 279 const FileSystemURL& path,
279 const SnapshotFileCallback& callback) { 280 const SnapshotFileCallback& callback) {
280 DCHECK(CalledOnValidThread()); 281 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
281 impl_->CreateSnapshotFile(path, callback); 282 impl_->CreateSnapshotFile(path, callback);
282 } 283 }
283 284
284 void SyncableFileSystemOperation::CopyInForeignFile( 285 void SyncableFileSystemOperation::CopyInForeignFile(
285 const base::FilePath& src_local_disk_path, 286 const base::FilePath& src_local_disk_path,
286 const FileSystemURL& dest_url, 287 const FileSystemURL& dest_url,
287 const StatusCallback& callback) { 288 const StatusCallback& callback) {
288 DCHECK(CalledOnValidThread()); 289 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
289 if (!operation_runner_.get()) { 290 if (!operation_runner_.get()) {
290 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 291 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
291 return; 292 return;
292 } 293 }
293 DCHECK(operation_runner_.get()); 294 DCHECK(operation_runner_.get());
294 target_paths_.push_back(dest_url); 295 target_paths_.push_back(dest_url);
295 completion_callback_ = callback; 296 completion_callback_ = callback;
296 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( 297 std::unique_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask(
297 weak_factory_.GetWeakPtr(), 298 weak_factory_.GetWeakPtr(),
298 base::Bind(&FileSystemOperation::CopyInForeignFile, 299 base::Bind(&FileSystemOperation::CopyInForeignFile,
299 base::Unretained(impl_.get()), src_local_disk_path, dest_url, 300 base::Unretained(impl_.get()), src_local_disk_path, dest_url,
300 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); 301 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr()))));
301 operation_runner_->PostOperationTask(std::move(task)); 302 operation_runner_->PostOperationTask(std::move(task));
302 } 303 }
303 304
304 void SyncableFileSystemOperation::RemoveFile( 305 void SyncableFileSystemOperation::RemoveFile(
305 const FileSystemURL& url, 306 const FileSystemURL& url,
306 const StatusCallback& callback) { 307 const StatusCallback& callback) {
307 DCHECK(CalledOnValidThread()); 308 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
308 impl_->RemoveFile(url, callback); 309 impl_->RemoveFile(url, callback);
309 } 310 }
310 311
311 void SyncableFileSystemOperation::RemoveDirectory( 312 void SyncableFileSystemOperation::RemoveDirectory(
312 const FileSystemURL& url, 313 const FileSystemURL& url,
313 const StatusCallback& callback) { 314 const StatusCallback& callback) {
314 DCHECK(CalledOnValidThread()); 315 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
315 impl_->RemoveDirectory(url, callback); 316 impl_->RemoveDirectory(url, callback);
316 } 317 }
317 318
318 void SyncableFileSystemOperation::CopyFileLocal( 319 void SyncableFileSystemOperation::CopyFileLocal(
319 const FileSystemURL& src_url, 320 const FileSystemURL& src_url,
320 const FileSystemURL& dest_url, 321 const FileSystemURL& dest_url,
321 CopyOrMoveOption option, 322 CopyOrMoveOption option,
322 const CopyFileProgressCallback& progress_callback, 323 const CopyFileProgressCallback& progress_callback,
323 const StatusCallback& callback) { 324 const StatusCallback& callback) {
324 DCHECK(CalledOnValidThread()); 325 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
325 impl_->CopyFileLocal(src_url, dest_url, option, progress_callback, callback); 326 impl_->CopyFileLocal(src_url, dest_url, option, progress_callback, callback);
326 } 327 }
327 328
328 void SyncableFileSystemOperation::MoveFileLocal( 329 void SyncableFileSystemOperation::MoveFileLocal(
329 const FileSystemURL& src_url, 330 const FileSystemURL& src_url,
330 const FileSystemURL& dest_url, 331 const FileSystemURL& dest_url,
331 CopyOrMoveOption option, 332 CopyOrMoveOption option,
332 const StatusCallback& callback) { 333 const StatusCallback& callback) {
333 DCHECK(CalledOnValidThread()); 334 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
334 impl_->MoveFileLocal(src_url, dest_url, option, callback); 335 impl_->MoveFileLocal(src_url, dest_url, option, callback);
335 } 336 }
336 337
337 base::File::Error SyncableFileSystemOperation::SyncGetPlatformPath( 338 base::File::Error SyncableFileSystemOperation::SyncGetPlatformPath(
338 const FileSystemURL& url, 339 const FileSystemURL& url,
339 base::FilePath* platform_path) { 340 base::FilePath* platform_path) {
340 return impl_->SyncGetPlatformPath(url, platform_path); 341 return impl_->SyncGetPlatformPath(url, platform_path);
341 } 342 }
342 343
343 SyncableFileSystemOperation::SyncableFileSystemOperation( 344 SyncableFileSystemOperation::SyncableFileSystemOperation(
(...skipping 10 matching lines...) Expand all
354 // support (or is not initialized for) the API. 355 // support (or is not initialized for) the API.
355 // Returning here to leave operation_runner_ as NULL. 356 // Returning here to leave operation_runner_ as NULL.
356 return; 357 return;
357 } 358 }
358 impl_.reset(storage::FileSystemOperation::Create( 359 impl_.reset(storage::FileSystemOperation::Create(
359 url_, file_system_context, std::move(operation_context))); 360 url_, file_system_context, std::move(operation_context)));
360 operation_runner_ = backend->sync_context()->operation_runner(); 361 operation_runner_ = backend->sync_context()->operation_runner();
361 } 362 }
362 363
363 void SyncableFileSystemOperation::DidFinish(base::File::Error status) { 364 void SyncableFileSystemOperation::DidFinish(base::File::Error status) {
364 DCHECK(CalledOnValidThread()); 365 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
365 DCHECK(!completion_callback_.is_null()); 366 DCHECK(!completion_callback_.is_null());
366 if (operation_runner_.get()) 367 if (operation_runner_.get())
367 operation_runner_->OnOperationCompleted(target_paths_); 368 operation_runner_->OnOperationCompleted(target_paths_);
368 completion_callback_.Run(status); 369 completion_callback_.Run(status);
369 } 370 }
370 371
371 void SyncableFileSystemOperation::DidWrite(const WriteCallback& callback, 372 void SyncableFileSystemOperation::DidWrite(const WriteCallback& callback,
372 base::File::Error result, 373 base::File::Error result,
373 int64_t bytes, 374 int64_t bytes,
374 bool complete) { 375 bool complete) {
375 DCHECK(CalledOnValidThread()); 376 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
376 if (!complete) { 377 if (!complete) {
377 callback.Run(result, bytes, complete); 378 callback.Run(result, bytes, complete);
378 return; 379 return;
379 } 380 }
380 if (operation_runner_.get()) 381 if (operation_runner_.get())
381 operation_runner_->OnOperationCompleted(target_paths_); 382 operation_runner_->OnOperationCompleted(target_paths_);
382 callback.Run(result, bytes, complete); 383 callback.Run(result, bytes, complete);
383 } 384 }
384 385
385 void SyncableFileSystemOperation::OnCancelled() { 386 void SyncableFileSystemOperation::OnCancelled() {
386 DCHECK(!completion_callback_.is_null()); 387 DCHECK(!completion_callback_.is_null());
387 completion_callback_.Run(base::File::FILE_ERROR_ABORT); 388 completion_callback_.Run(base::File::FILE_ERROR_ABORT);
388 } 389 }
389 390
390 } // namespace sync_file_system 391 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/local/syncable_file_system_operation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698