OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/time/time.h" |
12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
13 #include "content/common/service_worker/service_worker_status_code.h" | 14 #include "content/common/service_worker/service_worker_status_code.h" |
14 #include "content/common/service_worker/service_worker_types.h" | 15 #include "content/common/service_worker/service_worker_types.h" |
15 #include "net/http/http_byte_range.h" | 16 #include "net/http/http_byte_range.h" |
16 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
17 #include "net/url_request/url_request_job.h" | 18 #include "net/url_request/url_request_job.h" |
18 | 19 |
19 namespace storage { | 20 namespace storage { |
20 class BlobDataHandle; | 21 class BlobDataHandle; |
21 class BlobStorageContext; | 22 class BlobStorageContext; |
(...skipping 28 matching lines...) Expand all Loading... |
50 return response_type_ == FORWARD_TO_SERVICE_WORKER; | 51 return response_type_ == FORWARD_TO_SERVICE_WORKER; |
51 } | 52 } |
52 | 53 |
53 // net::URLRequestJob overrides: | 54 // net::URLRequestJob overrides: |
54 virtual void Start() OVERRIDE; | 55 virtual void Start() OVERRIDE; |
55 virtual void Kill() OVERRIDE; | 56 virtual void Kill() OVERRIDE; |
56 virtual net::LoadState GetLoadState() const OVERRIDE; | 57 virtual net::LoadState GetLoadState() const OVERRIDE; |
57 virtual bool GetCharset(std::string* charset) OVERRIDE; | 58 virtual bool GetCharset(std::string* charset) OVERRIDE; |
58 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 59 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
59 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; | 60 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; |
| 61 virtual void GetLoadTimingInfo( |
| 62 net::LoadTimingInfo* load_timing_info) const OVERRIDE; |
60 virtual int GetResponseCode() const OVERRIDE; | 63 virtual int GetResponseCode() const OVERRIDE; |
61 virtual void SetExtraRequestHeaders( | 64 virtual void SetExtraRequestHeaders( |
62 const net::HttpRequestHeaders& headers) OVERRIDE; | 65 const net::HttpRequestHeaders& headers) OVERRIDE; |
63 virtual bool ReadRawData(net::IOBuffer* buf, | 66 virtual bool ReadRawData(net::IOBuffer* buf, |
64 int buf_size, | 67 int buf_size, |
65 int *bytes_read) OVERRIDE; | 68 int *bytes_read) OVERRIDE; |
66 | 69 |
67 // net::URLRequest::Delegate overrides that read the blob from the | 70 // net::URLRequest::Delegate overrides that read the blob from the |
68 // ServiceWorkerFetchResponse. | 71 // ServiceWorkerFetchResponse. |
69 virtual void OnReceivedRedirect(net::URLRequest* request, | 72 virtual void OnReceivedRedirect(net::URLRequest* request, |
70 const net::RedirectInfo& redirect_info, | 73 const net::RedirectInfo& redirect_info, |
71 bool* defer_redirect) OVERRIDE; | 74 bool* defer_redirect) OVERRIDE; |
72 virtual void OnAuthRequired(net::URLRequest* request, | 75 virtual void OnAuthRequired(net::URLRequest* request, |
73 net::AuthChallengeInfo* auth_info) OVERRIDE; | 76 net::AuthChallengeInfo* auth_info) OVERRIDE; |
74 virtual void OnCertificateRequested( | 77 virtual void OnCertificateRequested( |
75 net::URLRequest* request, | 78 net::URLRequest* request, |
76 net::SSLCertRequestInfo* cert_request_info) OVERRIDE; | 79 net::SSLCertRequestInfo* cert_request_info) OVERRIDE; |
77 virtual void OnSSLCertificateError(net::URLRequest* request, | 80 virtual void OnSSLCertificateError(net::URLRequest* request, |
78 const net::SSLInfo& ssl_info, | 81 const net::SSLInfo& ssl_info, |
79 bool fatal) OVERRIDE; | 82 bool fatal) OVERRIDE; |
80 virtual void OnBeforeNetworkStart(net::URLRequest* request, | 83 virtual void OnBeforeNetworkStart(net::URLRequest* request, |
81 bool* defer) OVERRIDE; | 84 bool* defer) OVERRIDE; |
82 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; | 85 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; |
83 virtual void OnReadCompleted(net::URLRequest* request, | 86 virtual void OnReadCompleted(net::URLRequest* request, |
84 int bytes_read) OVERRIDE; | 87 int bytes_read) OVERRIDE; |
85 | 88 |
86 const net::HttpResponseInfo* http_info() const; | 89 const net::HttpResponseInfo* http_info() const; |
87 | 90 |
88 void GetExtraResponseInfo(bool* was_fetched_via_service_worker, | 91 void GetExtraResponseInfo(bool* was_fetched_via_service_worker, |
89 GURL* original_url_via_service_worker) const; | 92 GURL* original_url_via_service_worker, |
| 93 base::TimeTicks* fetch_start_time, |
| 94 base::TimeTicks* fetch_ready_time, |
| 95 base::TimeTicks* fetch_end_time) const; |
90 | 96 |
91 protected: | 97 protected: |
92 virtual ~ServiceWorkerURLRequestJob(); | 98 virtual ~ServiceWorkerURLRequestJob(); |
93 | 99 |
94 private: | 100 private: |
95 enum ResponseType { | 101 enum ResponseType { |
96 NOT_DETERMINED, | 102 NOT_DETERMINED, |
97 FALLBACK_TO_NETWORK, | 103 FALLBACK_TO_NETWORK, |
98 FORWARD_TO_SERVICE_WORKER, | 104 FORWARD_TO_SERVICE_WORKER, |
99 }; | 105 }; |
(...skipping 24 matching lines...) Expand all Loading... |
124 | 130 |
125 // Creates |http_response_info_| using |http_response_headers_| and calls | 131 // Creates |http_response_info_| using |http_response_headers_| and calls |
126 // NotifyHeadersComplete. | 132 // NotifyHeadersComplete. |
127 void CommitResponseHeader(); | 133 void CommitResponseHeader(); |
128 | 134 |
129 // Creates and commits a response header indicating error. | 135 // Creates and commits a response header indicating error. |
130 void DeliverErrorResponse(); | 136 void DeliverErrorResponse(); |
131 | 137 |
132 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; | 138 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; |
133 | 139 |
| 140 // Timing info to show on the popup in Devtools' Network tab. |
| 141 net::LoadTimingInfo load_timing_info_; |
| 142 base::TimeTicks fetch_start_time_; |
| 143 base::TimeTicks fetch_ready_time_; |
| 144 base::TimeTicks fetch_end_time_; |
| 145 base::Time response_time_; |
| 146 |
134 ResponseType response_type_; | 147 ResponseType response_type_; |
135 bool is_started_; | 148 bool is_started_; |
136 | 149 |
137 net::HttpByteRange byte_range_; | 150 net::HttpByteRange byte_range_; |
138 scoped_ptr<net::HttpResponseInfo> range_response_info_; | 151 scoped_ptr<net::HttpResponseInfo> range_response_info_; |
139 scoped_ptr<net::HttpResponseInfo> http_response_info_; | 152 scoped_ptr<net::HttpResponseInfo> http_response_info_; |
140 // Headers that have not yet been committed to |http_response_info_|. | 153 // Headers that have not yet been committed to |http_response_info_|. |
141 scoped_refptr<net::HttpResponseHeaders> http_response_headers_; | 154 scoped_refptr<net::HttpResponseHeaders> http_response_headers_; |
142 GURL response_url_; | 155 GURL response_url_; |
143 | 156 |
144 // Used when response type is FORWARD_TO_SERVICE_WORKER. | 157 // Used when response type is FORWARD_TO_SERVICE_WORKER. |
145 scoped_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; | 158 scoped_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; |
146 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | 159 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
147 scoped_ptr<net::URLRequest> blob_request_; | 160 scoped_ptr<net::URLRequest> blob_request_; |
148 // ResourceRequestBody has a collection of BlobDataHandles attached to it | 161 // ResourceRequestBody has a collection of BlobDataHandles attached to it |
149 // using the userdata mechanism. So we have to keep it not to free the blobs. | 162 // using the userdata mechanism. So we have to keep it not to free the blobs. |
150 scoped_refptr<ResourceRequestBody> body_; | 163 scoped_refptr<ResourceRequestBody> body_; |
151 scoped_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; | 164 scoped_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; |
152 | 165 |
153 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; | 166 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; |
154 | 167 |
155 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); | 168 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); |
156 }; | 169 }; |
157 | 170 |
158 } // namespace content | 171 } // namespace content |
159 | 172 |
160 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 173 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
OLD | NEW |