| OLD | NEW |
| 1 // Copyright (c) 2010 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "net/url_request/url_request_context.h" | 9 #include "net/url_request/url_request_context.h" |
| 10 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 10 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 11 #include "webkit/fileapi/file_system_operation.h" | 11 #include "webkit/fileapi/file_system_operation.h" |
| 12 #include "webkit/glue/webkit_glue.h" | 12 #include "webkit/glue/webkit_glue.h" |
| 13 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 13 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 14 | 14 |
| 15 using fileapi::FileSystemOperation; | 15 using fileapi::FileSystemOperation; |
| 16 using fileapi::FileSystemCallbackDispatcher; | 16 using fileapi::FileSystemCallbackDispatcher; |
| 17 using fileapi::WebFileWriterBase; | 17 using fileapi::WebFileWriterBase; |
| 18 using WebKit::WebFileWriterClient; | 18 using WebKit::WebFileWriterClient; |
| 19 using WebKit::WebString; | 19 using WebKit::WebString; |
| 20 using WebKit::WebURL; | 20 using WebKit::WebURL; |
| 21 | 21 |
| 22 URLRequestContext* SimpleFileWriter::request_context_ = NULL; | 22 net::URLRequestContext* SimpleFileWriter::request_context_ = NULL; |
| 23 | 23 |
| 24 // Helper class to proxy to write and truncate calls to the IO thread, | 24 // Helper class to proxy to write and truncate calls to the IO thread, |
| 25 // and to proxy the results back to the main thead. There is a one-to-one | 25 // and to proxy the results back to the main thead. There is a one-to-one |
| 26 // relationship between SimpleFileWriters and IOThreadBackends. | 26 // relationship between SimpleFileWriters and IOThreadBackends. |
| 27 class SimpleFileWriter::IOThreadProxy | 27 class SimpleFileWriter::IOThreadProxy |
| 28 : public base::RefCountedThreadSafe<SimpleFileWriter::IOThreadProxy> { | 28 : public base::RefCountedThreadSafe<SimpleFileWriter::IOThreadProxy> { |
| 29 public: | 29 public: |
| 30 explicit IOThreadProxy(const base::WeakPtr<SimpleFileWriter>& simple_writer) | 30 explicit IOThreadProxy(const base::WeakPtr<SimpleFileWriter>& simple_writer) |
| 31 : simple_writer_(simple_writer), | 31 : simple_writer_(simple_writer), |
| 32 operation_(NULL) { | 32 operation_(NULL) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 181 } |
| 182 | 182 |
| 183 void SimpleFileWriter::DoWrite( | 183 void SimpleFileWriter::DoWrite( |
| 184 const FilePath& path, const GURL& blob_url, int64 offset) { | 184 const FilePath& path, const GURL& blob_url, int64 offset) { |
| 185 io_thread_proxy_->Write(path, blob_url, offset); | 185 io_thread_proxy_->Write(path, blob_url, offset); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void SimpleFileWriter::DoCancel() { | 188 void SimpleFileWriter::DoCancel() { |
| 189 io_thread_proxy_->Cancel(); | 189 io_thread_proxy_->Cancel(); |
| 190 } | 190 } |
| OLD | NEW |