| 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 "storage/browser/fileapi/file_system_operation_runner.h" | 5 #include "storage/browser/fileapi/file_system_operation_runner.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 operation->Truncate( | 299 operation->Truncate( |
| 300 url, length, | 300 url, length, |
| 301 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), | 301 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), |
| 302 handle, callback)); | 302 handle, callback)); |
| 303 return handle.id; | 303 return handle.id; |
| 304 } | 304 } |
| 305 | 305 |
| 306 void FileSystemOperationRunner::Cancel( | 306 void FileSystemOperationRunner::Cancel( |
| 307 OperationID id, | 307 OperationID id, |
| 308 const StatusCallback& callback) { | 308 const StatusCallback& callback) { |
| 309 if (ContainsKey(finished_operations_, id)) { | 309 if (base::ContainsKey(finished_operations_, id)) { |
| 310 DCHECK(!ContainsKey(stray_cancel_callbacks_, id)); | 310 DCHECK(!base::ContainsKey(stray_cancel_callbacks_, id)); |
| 311 stray_cancel_callbacks_[id] = callback; | 311 stray_cancel_callbacks_[id] = callback; |
| 312 return; | 312 return; |
| 313 } | 313 } |
| 314 FileSystemOperation* operation = operations_.Lookup(id); | 314 FileSystemOperation* operation = operations_.Lookup(id); |
| 315 if (!operation) { | 315 if (!operation) { |
| 316 // There is no operation with |id|. | 316 // There is no operation with |id|. |
| 317 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 317 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 318 return; | 318 return; |
| 319 } | 319 } |
| 320 operation->Cancel(callback); | 320 operation->Cancel(callback); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 stray_cancel_callbacks_.find(id); | 688 stray_cancel_callbacks_.find(id); |
| 689 if (found_cancel != stray_cancel_callbacks_.end()) { | 689 if (found_cancel != stray_cancel_callbacks_.end()) { |
| 690 // This cancel has been requested after the operation has finished, | 690 // This cancel has been requested after the operation has finished, |
| 691 // so report that we failed to stop it. | 691 // so report that we failed to stop it. |
| 692 found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 692 found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 693 stray_cancel_callbacks_.erase(found_cancel); | 693 stray_cancel_callbacks_.erase(found_cancel); |
| 694 } | 694 } |
| 695 } | 695 } |
| 696 | 696 |
| 697 } // namespace storage | 697 } // namespace storage |
| OLD | NEW |