Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: webkit/blob/blob_url_request_job.h

Issue 15746017: Move webkit/blob to new locations. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/blob/blob_storage_host.cc ('k') | webkit/blob/blob_url_request_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_BLOB_BLOB_URL_REQUEST_JOB_H_
6 #define WEBKIT_BLOB_BLOB_URL_REQUEST_JOB_H_
7
8 #include <map>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/platform_file.h"
13 #include "net/http/http_byte_range.h"
14 #include "net/url_request/url_request_job.h"
15 #include "webkit/blob/blob_data.h"
16 #include "webkit/storage/webkit_storage_export.h"
17
18 namespace base {
19 class MessageLoopProxy;
20 struct PlatformFileInfo;
21 }
22
23 namespace fileapi {
24 class FileSystemContext;
25 }
26
27 namespace net {
28 class DrainableIOBuffer;
29 class IOBuffer;
30 }
31
32 namespace webkit_blob {
33
34 class FileStreamReader;
35
36 // A request job that handles reading blob URLs.
37 class WEBKIT_STORAGE_EXPORT BlobURLRequestJob : public net::URLRequestJob {
38 public:
39 BlobURLRequestJob(net::URLRequest* request,
40 net::NetworkDelegate* network_delegate,
41 BlobData* blob_data,
42 fileapi::FileSystemContext* file_system_context,
43 base::MessageLoopProxy* resolving_message_loop_proxy);
44
45 // net::URLRequestJob methods.
46 virtual void Start() OVERRIDE;
47 virtual void Kill() OVERRIDE;
48 virtual bool ReadRawData(net::IOBuffer* buf,
49 int buf_size,
50 int* bytes_read) OVERRIDE;
51 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
52 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE;
53 virtual int GetResponseCode() const OVERRIDE;
54 virtual void SetExtraRequestHeaders(
55 const net::HttpRequestHeaders& headers) OVERRIDE;
56
57 protected:
58 virtual ~BlobURLRequestJob();
59
60 private:
61 typedef std::map<size_t, FileStreamReader*> IndexToReaderMap;
62
63 // For preparing for read: get the size, apply the range and perform seek.
64 void DidStart();
65 bool AddItemLength(size_t index, int64 item_length);
66 void CountSize();
67 void DidCountSize(int error);
68 void DidGetFileItemLength(size_t index, int64 result);
69 void Seek(int64 offset);
70
71 // For reading the blob.
72 bool ReadLoop(int* bytes_read);
73 bool ReadItem();
74 void AdvanceItem();
75 void AdvanceBytesRead(int result);
76 bool ReadBytesItem(const BlobData::Item& item, int bytes_to_read);
77 bool ReadFileItem(FileStreamReader* reader, int bytes_to_read);
78
79 void DidReadFile(int result);
80 void DeleteCurrentFileReader();
81
82 int ComputeBytesToRead() const;
83 int BytesReadCompleted();
84
85 void NotifySuccess();
86 void NotifyFailure(int);
87 void HeadersCompleted(int status_code, const std::string& status_txt);
88
89 // Returns a FileStreamReader for a blob item at |index|.
90 // If the item at |index| is not of file this returns NULL.
91 FileStreamReader* GetFileStreamReader(size_t index);
92
93 // Creates a FileStreamReader for the item at |index| with additional_offset.
94 void CreateFileStreamReader(size_t index, int64 additional_offset);
95
96 base::WeakPtrFactory<BlobURLRequestJob> weak_factory_;
97 scoped_refptr<BlobData> blob_data_;
98 scoped_refptr<fileapi::FileSystemContext> file_system_context_;
99 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_;
100 std::vector<int64> item_length_list_;
101 int64 total_size_;
102 int64 remaining_bytes_;
103 int pending_get_file_info_count_;
104 IndexToReaderMap index_to_reader_;
105 size_t current_item_index_;
106 int64 current_item_offset_;
107 scoped_refptr<net::DrainableIOBuffer> read_buf_;
108 bool error_;
109 bool headers_set_;
110 bool byte_range_set_;
111 net::HttpByteRange byte_range_;
112 scoped_ptr<net::HttpResponseInfo> response_info_;
113
114 DISALLOW_COPY_AND_ASSIGN(BlobURLRequestJob);
115 };
116
117 } // namespace webkit_blob
118
119 #endif // WEBKIT_BLOB_BLOB_URL_REQUEST_JOB_H_
OLDNEW
« no previous file with comments | « webkit/blob/blob_storage_host.cc ('k') | webkit/blob/blob_url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698