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

Side by Side Diff: storage/browser/blob/blob_url_request_job.h

Issue 2906543002: Add support for reading blobs when using the network service. (Closed)
Patch Set: kinuko comment Created 3 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
OLDNEW
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 STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_ 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_
6 #define STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_ 6 #define STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "net/http/http_byte_range.h" 16 #include "net/http/http_byte_range.h"
17 #include "net/http/http_status_code.h" 17 #include "net/http/http_status_code.h"
18 #include "net/url_request/url_request_job.h" 18 #include "net/url_request/url_request_job.h"
19 #include "storage/browser/blob/blob_reader.h" 19 #include "storage/browser/blob/blob_reader.h"
20 #include "storage/browser/storage_browser_export.h" 20 #include "storage/browser/storage_browser_export.h"
21 21
22 namespace base { 22 namespace base {
23 class SingleThreadTaskRunner; 23 class SingleThreadTaskRunner;
24 } 24 }
25 25
26 namespace net { 26 namespace net {
27 class HttpResponseHeaders;
27 class IOBuffer; 28 class IOBuffer;
28 } 29 }
29 30
30 namespace storage { 31 namespace storage {
31 32
32 class BlobDataHandle; 33 class BlobDataHandle;
33 class FileStreamReader; 34 class FileStreamReader;
34 class FileSystemContext; 35 class FileSystemContext;
35 36
36 // A request job that handles reading blob URLs. 37 // A request job that handles reading blob URLs.
37 class STORAGE_EXPORT BlobURLRequestJob 38 class STORAGE_EXPORT BlobURLRequestJob
38 : public net::URLRequestJob { 39 : public net::URLRequestJob {
39 public: 40 public:
40 BlobURLRequestJob(net::URLRequest* request, 41 BlobURLRequestJob(net::URLRequest* request,
41 net::NetworkDelegate* network_delegate, 42 net::NetworkDelegate* network_delegate,
42 BlobDataHandle* blob_handle, 43 BlobDataHandle* blob_handle,
43 storage::FileSystemContext* file_system_context, 44 storage::FileSystemContext* file_system_context,
44 base::SingleThreadTaskRunner* resolving_thread_task_runner); 45 base::SingleThreadTaskRunner* resolving_thread_task_runner);
45 46
46 // net::URLRequestJob methods. 47 // net::URLRequestJob methods.
47 void Start() override; 48 void Start() override;
48 void Kill() override; 49 void Kill() override;
49 int ReadRawData(net::IOBuffer* buf, int buf_size) override; 50 int ReadRawData(net::IOBuffer* buf, int buf_size) override;
50 bool GetMimeType(std::string* mime_type) const override; 51 bool GetMimeType(std::string* mime_type) const override;
51 void GetResponseInfo(net::HttpResponseInfo* info) override; 52 void GetResponseInfo(net::HttpResponseInfo* info) override;
52 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; 53 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override;
53 54
55 // Helper method to create the HTTP headers for the response.
56 static scoped_refptr<net::HttpResponseHeaders> GenerateHeaders(
57 net::HttpStatusCode status_code,
58 BlobDataHandle* blob_handle,
59 BlobReader* blob_reader,
60 net::HttpByteRange* byte_range,
61 int64_t* content_size);
62
54 protected: 63 protected:
55 ~BlobURLRequestJob() override; 64 ~BlobURLRequestJob() override;
56 65
57 private: 66 private:
58 typedef std::map<size_t, FileStreamReader*> IndexToReaderMap; 67 typedef std::map<size_t, FileStreamReader*> IndexToReaderMap;
59 68
60 // For preparing for read: get the size, apply the range and perform seek. 69 // For preparing for read: get the size, apply the range and perform seek.
61 void DidStart(); 70 void DidStart();
62 void DidCalculateSize(int result); 71 void DidCalculateSize(int result);
63 void DidReadMetadata(BlobReader::Status result); 72 void DidReadMetadata(BlobReader::Status result);
(...skipping 13 matching lines...) Expand all
77 std::unique_ptr<net::HttpResponseInfo> response_info_; 86 std::unique_ptr<net::HttpResponseInfo> response_info_;
78 87
79 base::WeakPtrFactory<BlobURLRequestJob> weak_factory_; 88 base::WeakPtrFactory<BlobURLRequestJob> weak_factory_;
80 89
81 DISALLOW_COPY_AND_ASSIGN(BlobURLRequestJob); 90 DISALLOW_COPY_AND_ASSIGN(BlobURLRequestJob);
82 }; 91 };
83 92
84 } // namespace storage 93 } // namespace storage
85 94
86 #endif // STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_ 95 #endif // STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698