OLD | NEW |
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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" |
8 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 9 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
9 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 10 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
10 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h
" | 11 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h
" |
11 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 12 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
12 #include "net/url_request/url_request.h" | 13 #include "net/url_request/url_request.h" |
13 #include "storage/browser/blob/shareable_file_reference.h" | 14 #include "storage/browser/blob/shareable_file_reference.h" |
14 #include "storage/browser/fileapi/file_system_context.h" | 15 #include "storage/browser/fileapi/file_system_context.h" |
15 #include "storage/browser/fileapi/file_system_operation.h" | 16 #include "storage/browser/fileapi/file_system_operation.h" |
16 #include "storage/browser/fileapi/file_system_operation_context.h" | 17 #include "storage/browser/fileapi/file_system_operation_context.h" |
17 #include "storage/browser/fileapi/file_system_url.h" | 18 #include "storage/browser/fileapi/file_system_url.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 base::Bind(&FileSystemOperation::Write, | 231 base::Bind(&FileSystemOperation::Write, |
231 base::Unretained(impl_.get()), | 232 base::Unretained(impl_.get()), |
232 url, | 233 url, |
233 base::Passed(&writer_delegate), | 234 base::Passed(&writer_delegate), |
234 base::Passed(&blob_request), | 235 base::Passed(&blob_request), |
235 base::Bind(&self::DidWrite, weak_factory_.GetWeakPtr(), | 236 base::Bind(&self::DidWrite, weak_factory_.GetWeakPtr(), |
236 callback)))); | 237 callback)))); |
237 operation_runner_->PostOperationTask(task.Pass()); | 238 operation_runner_->PostOperationTask(task.Pass()); |
238 } | 239 } |
239 | 240 |
240 void SyncableFileSystemOperation::Truncate( | 241 void SyncableFileSystemOperation::Truncate(const FileSystemURL& url, |
241 const FileSystemURL& url, int64 length, | 242 int64_t length, |
242 const StatusCallback& callback) { | 243 const StatusCallback& callback) { |
243 DCHECK(CalledOnValidThread()); | 244 DCHECK(CalledOnValidThread()); |
244 if (!operation_runner_.get()) { | 245 if (!operation_runner_.get()) { |
245 callback.Run(base::File::FILE_ERROR_NOT_FOUND); | 246 callback.Run(base::File::FILE_ERROR_NOT_FOUND); |
246 return; | 247 return; |
247 } | 248 } |
248 DCHECK(operation_runner_.get()); | 249 DCHECK(operation_runner_.get()); |
249 target_paths_.push_back(url); | 250 target_paths_.push_back(url); |
250 completion_callback_ = callback; | 251 completion_callback_ = callback; |
251 scoped_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( | 252 scoped_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( |
252 weak_factory_.GetWeakPtr(), | 253 weak_factory_.GetWeakPtr(), |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 368 } |
368 | 369 |
369 void SyncableFileSystemOperation::DidFinish(base::File::Error status) { | 370 void SyncableFileSystemOperation::DidFinish(base::File::Error status) { |
370 DCHECK(CalledOnValidThread()); | 371 DCHECK(CalledOnValidThread()); |
371 DCHECK(!completion_callback_.is_null()); | 372 DCHECK(!completion_callback_.is_null()); |
372 if (operation_runner_.get()) | 373 if (operation_runner_.get()) |
373 operation_runner_->OnOperationCompleted(target_paths_); | 374 operation_runner_->OnOperationCompleted(target_paths_); |
374 completion_callback_.Run(status); | 375 completion_callback_.Run(status); |
375 } | 376 } |
376 | 377 |
377 void SyncableFileSystemOperation::DidWrite( | 378 void SyncableFileSystemOperation::DidWrite(const WriteCallback& callback, |
378 const WriteCallback& callback, | 379 base::File::Error result, |
379 base::File::Error result, | 380 int64_t bytes, |
380 int64 bytes, | 381 bool complete) { |
381 bool complete) { | |
382 DCHECK(CalledOnValidThread()); | 382 DCHECK(CalledOnValidThread()); |
383 if (!complete) { | 383 if (!complete) { |
384 callback.Run(result, bytes, complete); | 384 callback.Run(result, bytes, complete); |
385 return; | 385 return; |
386 } | 386 } |
387 if (operation_runner_.get()) | 387 if (operation_runner_.get()) |
388 operation_runner_->OnOperationCompleted(target_paths_); | 388 operation_runner_->OnOperationCompleted(target_paths_); |
389 callback.Run(result, bytes, complete); | 389 callback.Run(result, bytes, complete); |
390 } | 390 } |
391 | 391 |
392 void SyncableFileSystemOperation::OnCancelled() { | 392 void SyncableFileSystemOperation::OnCancelled() { |
393 DCHECK(!completion_callback_.is_null()); | 393 DCHECK(!completion_callback_.is_null()); |
394 completion_callback_.Run(base::File::FILE_ERROR_ABORT); | 394 completion_callback_.Run(base::File::FILE_ERROR_ABORT); |
395 } | 395 } |
396 | 396 |
397 } // namespace sync_file_system | 397 } // namespace sync_file_system |
OLD | NEW |