| 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 "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 8 #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" | 9 #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
" | 10 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h
" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 class SyncableFileSystemOperation::QueueableTask | 34 class SyncableFileSystemOperation::QueueableTask |
| 35 : public SyncableFileOperationRunner::Task { | 35 : public SyncableFileOperationRunner::Task { |
| 36 public: | 36 public: |
| 37 QueueableTask(base::WeakPtr<SyncableFileSystemOperation> operation, | 37 QueueableTask(base::WeakPtr<SyncableFileSystemOperation> operation, |
| 38 const base::Closure& task) | 38 const base::Closure& task) |
| 39 : operation_(operation), | 39 : operation_(operation), |
| 40 task_(task), | 40 task_(task), |
| 41 target_paths_(operation->target_paths_) {} | 41 target_paths_(operation->target_paths_) {} |
| 42 | 42 |
| 43 virtual ~QueueableTask() { | 43 ~QueueableTask() override { DCHECK(!operation_); } |
| 44 DCHECK(!operation_); | |
| 45 } | |
| 46 | 44 |
| 47 virtual void Run() override { | 45 void Run() override { |
| 48 if (!operation_) | 46 if (!operation_) |
| 49 return; | 47 return; |
| 50 DCHECK(!task_.is_null()); | 48 DCHECK(!task_.is_null()); |
| 51 task_.Run(); | 49 task_.Run(); |
| 52 operation_.reset(); | 50 operation_.reset(); |
| 53 } | 51 } |
| 54 | 52 |
| 55 virtual void Cancel() override { | 53 void Cancel() override { |
| 56 DCHECK(!task_.is_null()); | 54 DCHECK(!task_.is_null()); |
| 57 if (operation_) | 55 if (operation_) |
| 58 operation_->OnCancelled(); | 56 operation_->OnCancelled(); |
| 59 task_.Reset(); | 57 task_.Reset(); |
| 60 operation_.reset(); | 58 operation_.reset(); |
| 61 } | 59 } |
| 62 | 60 |
| 63 virtual const std::vector<FileSystemURL>& target_paths() const override { | 61 const std::vector<FileSystemURL>& target_paths() const override { |
| 64 return target_paths_; | 62 return target_paths_; |
| 65 } | 63 } |
| 66 | 64 |
| 67 private: | 65 private: |
| 68 base::WeakPtr<SyncableFileSystemOperation> operation_; | 66 base::WeakPtr<SyncableFileSystemOperation> operation_; |
| 69 base::Closure task_; | 67 base::Closure task_; |
| 70 std::vector<FileSystemURL> target_paths_; | 68 std::vector<FileSystemURL> target_paths_; |
| 71 DISALLOW_COPY_AND_ASSIGN(QueueableTask); | 69 DISALLOW_COPY_AND_ASSIGN(QueueableTask); |
| 72 }; | 70 }; |
| 73 | 71 |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 operation_runner_->OnOperationCompleted(target_paths_); | 387 operation_runner_->OnOperationCompleted(target_paths_); |
| 390 callback.Run(result, bytes, complete); | 388 callback.Run(result, bytes, complete); |
| 391 } | 389 } |
| 392 | 390 |
| 393 void SyncableFileSystemOperation::OnCancelled() { | 391 void SyncableFileSystemOperation::OnCancelled() { |
| 394 DCHECK(!completion_callback_.is_null()); | 392 DCHECK(!completion_callback_.is_null()); |
| 395 completion_callback_.Run(base::File::FILE_ERROR_ABORT); | 393 completion_callback_.Run(base::File::FILE_ERROR_ABORT); |
| 396 } | 394 } |
| 397 | 395 |
| 398 } // namespace sync_file_system | 396 } // namespace sync_file_system |
| OLD | NEW |