| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_ | 5 #ifndef WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_ |
| 6 #define WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_ | 6 #define WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "net/http/http_byte_range.h" | 12 #include "net/http/http_byte_range.h" |
| 13 #include "net/http/http_status_code.h" | 13 #include "net/http/http_status_code.h" |
| 14 #include "net/url_request/url_request_job.h" | 14 #include "net/url_request/url_request_job.h" |
| 15 #include "webkit/browser/webkit_storage_browser_export.h" | 15 #include "storage/common/storage_export.h" |
| 16 #include "webkit/common/blob/blob_data.h" | 16 #include "storage/common/blob/blob_data.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class MessageLoopProxy; | 19 class MessageLoopProxy; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace fileapi { | 22 namespace storage { |
| 23 class FileSystemContext; | 23 class FileSystemContext; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace net { | 26 namespace net { |
| 27 class DrainableIOBuffer; | 27 class DrainableIOBuffer; |
| 28 class IOBuffer; | 28 class IOBuffer; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace webkit_blob { | 31 namespace storage { |
| 32 | 32 |
| 33 class FileStreamReader; | 33 class FileStreamReader; |
| 34 | 34 |
| 35 // A request job that handles reading blob URLs. | 35 // A request job that handles reading blob URLs. |
| 36 class WEBKIT_STORAGE_BROWSER_EXPORT BlobURLRequestJob | 36 class STORAGE_EXPORT BlobURLRequestJob : public net::URLRequestJob { |
| 37 : public net::URLRequestJob { | |
| 38 public: | 37 public: |
| 39 BlobURLRequestJob(net::URLRequest* request, | 38 BlobURLRequestJob(net::URLRequest* request, |
| 40 net::NetworkDelegate* network_delegate, | 39 net::NetworkDelegate* network_delegate, |
| 41 BlobData* blob_data, | 40 BlobData* blob_data, |
| 42 fileapi::FileSystemContext* file_system_context, | 41 storage::FileSystemContext* file_system_context, |
| 43 base::MessageLoopProxy* resolving_message_loop_proxy); | 42 base::MessageLoopProxy* resolving_message_loop_proxy); |
| 44 | 43 |
| 45 // net::URLRequestJob methods. | 44 // net::URLRequestJob methods. |
| 46 virtual void Start() OVERRIDE; | 45 virtual void Start() OVERRIDE; |
| 47 virtual void Kill() OVERRIDE; | 46 virtual void Kill() OVERRIDE; |
| 48 virtual bool ReadRawData(net::IOBuffer* buf, | 47 virtual bool ReadRawData(net::IOBuffer* buf, |
| 49 int buf_size, | 48 int buf_size, |
| 50 int* bytes_read) OVERRIDE; | 49 int* bytes_read) OVERRIDE; |
| 51 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 50 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 52 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; | 51 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // Returns a FileStreamReader for a blob item at |index|. | 90 // Returns a FileStreamReader for a blob item at |index|. |
| 92 // If the item at |index| is not of file this returns NULL. | 91 // If the item at |index| is not of file this returns NULL. |
| 93 FileStreamReader* GetFileStreamReader(size_t index); | 92 FileStreamReader* GetFileStreamReader(size_t index); |
| 94 | 93 |
| 95 // Creates a FileStreamReader for the item at |index| with additional_offset. | 94 // Creates a FileStreamReader for the item at |index| with additional_offset. |
| 96 void CreateFileStreamReader(size_t index, int64 additional_offset); | 95 void CreateFileStreamReader(size_t index, int64 additional_offset); |
| 97 | 96 |
| 98 scoped_refptr<BlobData> blob_data_; | 97 scoped_refptr<BlobData> blob_data_; |
| 99 | 98 |
| 100 // Variables for controlling read from |blob_data_|. | 99 // Variables for controlling read from |blob_data_|. |
| 101 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 100 scoped_refptr<storage::FileSystemContext> file_system_context_; |
| 102 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; | 101 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; |
| 103 std::vector<int64> item_length_list_; | 102 std::vector<int64> item_length_list_; |
| 104 int64 total_size_; | 103 int64 total_size_; |
| 105 int64 remaining_bytes_; | 104 int64 remaining_bytes_; |
| 106 int pending_get_file_info_count_; | 105 int pending_get_file_info_count_; |
| 107 IndexToReaderMap index_to_reader_; | 106 IndexToReaderMap index_to_reader_; |
| 108 size_t current_item_index_; | 107 size_t current_item_index_; |
| 109 int64 current_item_offset_; | 108 int64 current_item_offset_; |
| 110 | 109 |
| 111 // Holds the buffer for read data with the IOBuffer interface. | 110 // Holds the buffer for read data with the IOBuffer interface. |
| 112 scoped_refptr<net::DrainableIOBuffer> read_buf_; | 111 scoped_refptr<net::DrainableIOBuffer> read_buf_; |
| 113 | 112 |
| 114 // Is set when NotifyFailure() is called and reset when DidStart is called. | 113 // Is set when NotifyFailure() is called and reset when DidStart is called. |
| 115 bool error_; | 114 bool error_; |
| 116 | 115 |
| 117 bool byte_range_set_; | 116 bool byte_range_set_; |
| 118 net::HttpByteRange byte_range_; | 117 net::HttpByteRange byte_range_; |
| 119 | 118 |
| 120 scoped_ptr<net::HttpResponseInfo> response_info_; | 119 scoped_ptr<net::HttpResponseInfo> response_info_; |
| 121 | 120 |
| 122 base::WeakPtrFactory<BlobURLRequestJob> weak_factory_; | 121 base::WeakPtrFactory<BlobURLRequestJob> weak_factory_; |
| 123 | 122 |
| 124 DISALLOW_COPY_AND_ASSIGN(BlobURLRequestJob); | 123 DISALLOW_COPY_AND_ASSIGN(BlobURLRequestJob); |
| 125 }; | 124 }; |
| 126 | 125 |
| 127 } // namespace webkit_blob | 126 } // namespace storage |
| 128 | 127 |
| 129 #endif // WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_ | 128 #endif // WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_ |
| OLD | NEW |