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 #ifndef WEBKIT_TOOLS_TEST_SHELL_SIMPLE_FILE_WRITER_H_ | 5 #ifndef WEBKIT_TOOLS_TEST_SHELL_SIMPLE_FILE_WRITER_H_ |
6 #define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_FILE_WRITER_H_ | 6 #define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_FILE_WRITER_H_ |
7 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/weak_ptr.h" | 9 #include "base/weak_ptr.h" |
10 #include "webkit/fileapi/webfilewriter_base.h" | 10 #include "webkit/fileapi/webfilewriter_base.h" |
11 | 11 |
| 12 namespace net { |
12 class URLRequestContext; | 13 class URLRequestContext; |
13 | 14 } // namespace net |
14 | 15 |
15 // An implementation of WebFileWriter for use in test_shell and DRT. | 16 // An implementation of WebFileWriter for use in test_shell and DRT. |
16 class SimpleFileWriter : public fileapi::WebFileWriterBase, | 17 class SimpleFileWriter : public fileapi::WebFileWriterBase, |
17 public base::SupportsWeakPtr<SimpleFileWriter> { | 18 public base::SupportsWeakPtr<SimpleFileWriter> { |
18 public: | 19 public: |
19 SimpleFileWriter( | 20 SimpleFileWriter( |
20 const WebKit::WebString& path, WebKit::WebFileWriterClient* client); | 21 const WebKit::WebString& path, WebKit::WebFileWriterClient* client); |
21 virtual ~SimpleFileWriter(); | 22 virtual ~SimpleFileWriter(); |
22 | 23 |
23 // Called by SimpleResourceLoaderBridge when the context is | 24 // Called by SimpleResourceLoaderBridge when the context is |
24 // created and destroyed. | 25 // created and destroyed. |
25 static void InitializeOnIOThread(URLRequestContext* request_context) { | 26 static void InitializeOnIOThread(net::URLRequestContext* request_context) { |
26 request_context_ = request_context; | 27 request_context_ = request_context; |
27 } | 28 } |
28 static void CleanupOnIOThread() { | 29 static void CleanupOnIOThread() { |
29 request_context_ = NULL; | 30 request_context_ = NULL; |
30 } | 31 } |
31 | 32 |
32 protected: | 33 protected: |
33 // WebFileWriterBase overrides | 34 // WebFileWriterBase overrides |
34 virtual void DoTruncate(const FilePath& path, int64 offset); | 35 virtual void DoTruncate(const FilePath& path, int64 offset); |
35 virtual void DoWrite(const FilePath& path, const GURL& blob_url, | 36 virtual void DoWrite(const FilePath& path, const GURL& blob_url, |
36 int64 offset); | 37 int64 offset); |
37 virtual void DoCancel(); | 38 virtual void DoCancel(); |
38 | 39 |
39 private: | 40 private: |
40 class IOThreadProxy; | 41 class IOThreadProxy; |
41 scoped_refptr<IOThreadProxy> io_thread_proxy_; | 42 scoped_refptr<IOThreadProxy> io_thread_proxy_; |
42 static URLRequestContext* request_context_; | 43 static net::URLRequestContext* request_context_; |
43 }; | 44 }; |
44 | 45 |
45 #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_FILE_WRITER_H_ | 46 #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_FILE_WRITER_H_ |
OLD | NEW |