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 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void ForwardToServiceWorker(); | 53 void ForwardToServiceWorker(); |
54 | 54 |
55 bool ShouldFallbackToNetwork() const { | 55 bool ShouldFallbackToNetwork() const { |
56 return response_type_ == FALLBACK_TO_NETWORK; | 56 return response_type_ == FALLBACK_TO_NETWORK; |
57 } | 57 } |
58 bool ShouldForwardToServiceWorker() const { | 58 bool ShouldForwardToServiceWorker() const { |
59 return response_type_ == FORWARD_TO_SERVICE_WORKER; | 59 return response_type_ == FORWARD_TO_SERVICE_WORKER; |
60 } | 60 } |
61 | 61 |
62 // net::URLRequestJob overrides: | 62 // net::URLRequestJob overrides: |
63 virtual void Start() override; | 63 void Start() override; |
64 virtual void Kill() override; | 64 void Kill() override; |
65 virtual net::LoadState GetLoadState() const override; | 65 net::LoadState GetLoadState() const override; |
66 virtual bool GetCharset(std::string* charset) override; | 66 bool GetCharset(std::string* charset) override; |
67 virtual bool GetMimeType(std::string* mime_type) const override; | 67 bool GetMimeType(std::string* mime_type) const override; |
68 virtual void GetResponseInfo(net::HttpResponseInfo* info) override; | 68 void GetResponseInfo(net::HttpResponseInfo* info) override; |
69 virtual void GetLoadTimingInfo( | 69 void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override; |
70 net::LoadTimingInfo* load_timing_info) const override; | 70 int GetResponseCode() const override; |
71 virtual int GetResponseCode() const override; | 71 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; |
72 virtual void SetExtraRequestHeaders( | 72 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override; |
73 const net::HttpRequestHeaders& headers) override; | |
74 virtual bool ReadRawData(net::IOBuffer* buf, | |
75 int buf_size, | |
76 int *bytes_read) override; | |
77 | 73 |
78 // net::URLRequest::Delegate overrides that read the blob from the | 74 // net::URLRequest::Delegate overrides that read the blob from the |
79 // ServiceWorkerFetchResponse. | 75 // ServiceWorkerFetchResponse. |
80 virtual void OnReceivedRedirect(net::URLRequest* request, | 76 void OnReceivedRedirect(net::URLRequest* request, |
81 const net::RedirectInfo& redirect_info, | 77 const net::RedirectInfo& redirect_info, |
82 bool* defer_redirect) override; | 78 bool* defer_redirect) override; |
83 virtual void OnAuthRequired(net::URLRequest* request, | 79 void OnAuthRequired(net::URLRequest* request, |
84 net::AuthChallengeInfo* auth_info) override; | 80 net::AuthChallengeInfo* auth_info) override; |
85 virtual void OnCertificateRequested( | 81 void OnCertificateRequested( |
86 net::URLRequest* request, | 82 net::URLRequest* request, |
87 net::SSLCertRequestInfo* cert_request_info) override; | 83 net::SSLCertRequestInfo* cert_request_info) override; |
88 virtual void OnSSLCertificateError(net::URLRequest* request, | 84 void OnSSLCertificateError(net::URLRequest* request, |
89 const net::SSLInfo& ssl_info, | 85 const net::SSLInfo& ssl_info, |
90 bool fatal) override; | 86 bool fatal) override; |
91 virtual void OnBeforeNetworkStart(net::URLRequest* request, | 87 void OnBeforeNetworkStart(net::URLRequest* request, bool* defer) override; |
92 bool* defer) override; | 88 void OnResponseStarted(net::URLRequest* request) override; |
93 virtual void OnResponseStarted(net::URLRequest* request) override; | 89 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
94 virtual void OnReadCompleted(net::URLRequest* request, | |
95 int bytes_read) override; | |
96 | 90 |
97 const net::HttpResponseInfo* http_info() const; | 91 const net::HttpResponseInfo* http_info() const; |
98 | 92 |
99 void GetExtraResponseInfo( | 93 void GetExtraResponseInfo( |
100 bool* was_fetched_via_service_worker, | 94 bool* was_fetched_via_service_worker, |
101 bool* was_fallback_required_by_service_worker, | 95 bool* was_fallback_required_by_service_worker, |
102 GURL* original_url_via_service_worker, | 96 GURL* original_url_via_service_worker, |
103 blink::WebServiceWorkerResponseType* response_type_via_service_worker, | 97 blink::WebServiceWorkerResponseType* response_type_via_service_worker, |
104 base::TimeTicks* fetch_start_time, | 98 base::TimeTicks* fetch_start_time, |
105 base::TimeTicks* fetch_ready_time, | 99 base::TimeTicks* fetch_ready_time, |
106 base::TimeTicks* fetch_end_time) const; | 100 base::TimeTicks* fetch_end_time) const; |
107 | 101 |
108 protected: | 102 protected: |
109 virtual ~ServiceWorkerURLRequestJob(); | 103 ~ServiceWorkerURLRequestJob() override; |
110 | 104 |
111 private: | 105 private: |
112 enum ResponseType { | 106 enum ResponseType { |
113 NOT_DETERMINED, | 107 NOT_DETERMINED, |
114 FALLBACK_TO_NETWORK, | 108 FALLBACK_TO_NETWORK, |
115 FORWARD_TO_SERVICE_WORKER, | 109 FORWARD_TO_SERVICE_WORKER, |
116 }; | 110 }; |
117 | 111 |
118 // We start processing the request if Start() is called AND response_type_ | 112 // We start processing the request if Start() is called AND response_type_ |
119 // is determined. | 113 // is determined. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 scoped_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; | 175 scoped_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; |
182 | 176 |
183 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; | 177 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; |
184 | 178 |
185 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); | 179 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); |
186 }; | 180 }; |
187 | 181 |
188 } // namespace content | 182 } // namespace content |
189 | 183 |
190 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 184 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
OLD | NEW |