OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_BLOB_READER_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_BLOB_READER_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "content/browser/service_worker/service_worker_url_request_job.h" |
| 11 #include "net/base/io_buffer.h" |
| 12 #include "net/url_request/url_request.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 // Reads a blob response for ServiceWorkerURLRequestJob. |
| 17 // Owned by ServiceWorkerURLRequestJob. |
| 18 class ServiceWorkerBlobReader : public net::URLRequest::Delegate { |
| 19 public: |
| 20 explicit ServiceWorkerBlobReader(ServiceWorkerURLRequestJob* owner); |
| 21 ~ServiceWorkerBlobReader() override; |
| 22 |
| 23 // Starts reading the blob. owner_->OnResponseStarted will be called when the |
| 24 // response starts. |
| 25 void Start(std::unique_ptr<storage::BlobDataHandle> blob_data_handle, |
| 26 const net::URLRequestContext* request_context); |
| 27 |
| 28 scoped_refptr<net::IOBufferWithSize> response_metadata() { |
| 29 return blob_request_->response_info().metadata; |
| 30 } |
| 31 |
| 32 // Same as URLRequestJob::ReadRawData. If ERR_IO_PENDING is returned, |
| 33 // owner_->OnReadRawDataComplete will be called when the read completes. |
| 34 int ReadRawData(net::IOBuffer* buf, int buf_size); |
| 35 |
| 36 // net::URLRequest::Delegate overrides |
| 37 void OnReceivedRedirect(net::URLRequest* request, |
| 38 const net::RedirectInfo& redirect_info, |
| 39 bool* defer_redirect) override; |
| 40 void OnAuthRequired(net::URLRequest* request, |
| 41 net::AuthChallengeInfo* auth_info) override; |
| 42 void OnCertificateRequested( |
| 43 net::URLRequest* request, |
| 44 net::SSLCertRequestInfo* cert_request_info) override; |
| 45 void OnSSLCertificateError(net::URLRequest* request, |
| 46 const net::SSLInfo& ssl_info, |
| 47 bool fatal) override; |
| 48 void OnResponseStarted(net::URLRequest* request) override; |
| 49 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
| 50 |
| 51 private: |
| 52 ServiceWorkerURLRequestJob* owner_; |
| 53 std::unique_ptr<net::URLRequest> blob_request_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerBlobReader); |
| 56 }; |
| 57 |
| 58 } // namespace content |
| 59 |
| 60 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_BLOB_READER_H_ |
OLD | NEW |