| 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 #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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "webkit/fileapi/webfilewriter_base.h" | 10 #include "webkit/fileapi/webfilewriter_base.h" |
| 11 | 11 |
| 12 namespace net { | |
| 13 class URLRequestContext; | |
| 14 } // namespace net | |
| 15 | |
| 16 namespace fileapi { | 12 namespace fileapi { |
| 17 class FileSystemContext; | 13 class FileSystemContext; |
| 18 } | 14 } |
| 15 namespace net { |
| 16 class URLRequestContext; |
| 17 } |
| 18 namespace webkit_blob { |
| 19 class BlobStorageContext; |
| 20 } |
| 21 |
| 19 | 22 |
| 20 // An implementation of WebFileWriter for use in test_shell and DRT. | 23 // An implementation of WebFileWriter for use in test_shell and DRT. |
| 21 class SimpleFileWriter : public fileapi::WebFileWriterBase, | 24 class SimpleFileWriter : public fileapi::WebFileWriterBase, |
| 22 public base::SupportsWeakPtr<SimpleFileWriter> { | 25 public base::SupportsWeakPtr<SimpleFileWriter> { |
| 23 public: | 26 public: |
| 24 SimpleFileWriter( | 27 SimpleFileWriter( |
| 25 const GURL& path, | 28 const GURL& path, |
| 26 WebKit::WebFileWriterClient* client, | 29 WebKit::WebFileWriterClient* client, |
| 27 fileapi::FileSystemContext* file_system_context); | 30 fileapi::FileSystemContext* file_system_context); |
| 28 virtual ~SimpleFileWriter(); | 31 virtual ~SimpleFileWriter(); |
| 29 | 32 |
| 30 // Called by SimpleResourceLoaderBridge when the context is | 33 // Called by SimpleResourceLoaderBridge when the context is |
| 31 // created and destroyed. | 34 // created and destroyed. |
| 32 static void InitializeOnIOThread(net::URLRequestContext* request_context) { | 35 static void InitializeOnIOThread(net::URLRequestContext* request_context, |
| 36 webkit_blob::BlobStorageContext* bsc) { |
| 33 request_context_ = request_context; | 37 request_context_ = request_context; |
| 38 blob_storage_context_ = bsc; |
| 34 } | 39 } |
| 35 static void CleanupOnIOThread() { | 40 static void CleanupOnIOThread() { |
| 36 request_context_ = NULL; | 41 request_context_ = NULL; |
| 42 blob_storage_context_ = NULL; |
| 37 } | 43 } |
| 38 | 44 |
| 39 protected: | 45 protected: |
| 40 // WebFileWriterBase overrides | 46 // WebFileWriterBase overrides |
| 41 virtual void DoTruncate(const GURL& path, int64 offset) OVERRIDE; | 47 virtual void DoTruncate(const GURL& path, int64 offset) OVERRIDE; |
| 42 virtual void DoWrite(const GURL& path, const GURL& blob_url, | 48 virtual void DoWrite(const GURL& path, const std::string& blob_uuid, |
| 43 int64 offset) OVERRIDE; | 49 int64 offset) OVERRIDE; |
| 44 virtual void DoCancel() OVERRIDE; | 50 virtual void DoCancel() OVERRIDE; |
| 45 | 51 |
| 46 private: | 52 private: |
| 47 class IOThreadProxy; | 53 class IOThreadProxy; |
| 48 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 54 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
| 49 scoped_refptr<IOThreadProxy> io_thread_proxy_; | 55 scoped_refptr<IOThreadProxy> io_thread_proxy_; |
| 50 static net::URLRequestContext* request_context_; | 56 static net::URLRequestContext* request_context_; |
| 57 static webkit_blob::BlobStorageContext* blob_storage_context_; |
| 51 }; | 58 }; |
| 52 | 59 |
| 53 #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_FILE_WRITER_H_ | 60 #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_FILE_WRITER_H_ |
| OLD | NEW |