| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/tools/test_shell/simple_file_writer.h" | 5 #include "webkit/tools/test_shell/simple_file_writer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "net/url_request/url_request_context.h" | 10 #include "net/url_request/url_request_context.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 if (!io_thread_->BelongsToCurrentThread()) { | 73 if (!io_thread_->BelongsToCurrentThread()) { |
| 74 io_thread_->PostTask( | 74 io_thread_->PostTask( |
| 75 FROM_HERE, | 75 FROM_HERE, |
| 76 base::Bind(&IOThreadProxy::Cancel, this)); | 76 base::Bind(&IOThreadProxy::Cancel, this)); |
| 77 return; | 77 return; |
| 78 } | 78 } |
| 79 if (!operation_) { | 79 if (!operation_) { |
| 80 DidFail(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 80 DidFail(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 operation_->Cancel(GetNewOperation()); | 83 operation_->Cancel(new CallbackDispatcher(this)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 // Inner class to receive callbacks from FileSystemOperation. | 87 // Inner class to receive callbacks from FileSystemOperation. |
| 88 class CallbackDispatcher : public FileSystemCallbackDispatcher { | 88 class CallbackDispatcher : public FileSystemCallbackDispatcher { |
| 89 public: | 89 public: |
| 90 explicit CallbackDispatcher(IOThreadProxy* proxy) : proxy_(proxy) { | 90 explicit CallbackDispatcher(IOThreadProxy* proxy) : proxy_(proxy) { |
| 91 } | 91 } |
| 92 | 92 |
| 93 ~CallbackDispatcher() { | 93 ~CallbackDispatcher() { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 } | 200 } |
| 201 | 201 |
| 202 void SimpleFileWriter::DoWrite( | 202 void SimpleFileWriter::DoWrite( |
| 203 const GURL& path, const GURL& blob_url, int64 offset) { | 203 const GURL& path, const GURL& blob_url, int64 offset) { |
| 204 io_thread_proxy_->Write(path, blob_url, offset); | 204 io_thread_proxy_->Write(path, blob_url, offset); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void SimpleFileWriter::DoCancel() { | 207 void SimpleFileWriter::DoCancel() { |
| 208 io_thread_proxy_->Cancel(); | 208 io_thread_proxy_->Cancel(); |
| 209 } | 209 } |
| OLD | NEW |