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 #include "content/renderer/service_worker/service_worker_script_context.h" | 5 #include "content/renderer/service_worker/service_worker_script_context.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "content/child/thread_safe_sender.h" | 10 #include "content/child/thread_safe_sender.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 FetchRequestMode mode) { | 38 FetchRequestMode mode) { |
39 return static_cast<blink::WebURLRequest::FetchRequestMode>(mode); | 39 return static_cast<blink::WebURLRequest::FetchRequestMode>(mode); |
40 } | 40 } |
41 | 41 |
42 blink::WebURLRequest::FetchCredentialsMode GetBlinkFetchCredentialsMode( | 42 blink::WebURLRequest::FetchCredentialsMode GetBlinkFetchCredentialsMode( |
43 FetchCredentialsMode credentials_mode) { | 43 FetchCredentialsMode credentials_mode) { |
44 return static_cast<blink::WebURLRequest::FetchCredentialsMode>( | 44 return static_cast<blink::WebURLRequest::FetchCredentialsMode>( |
45 credentials_mode); | 45 credentials_mode); |
46 } | 46 } |
47 | 47 |
| 48 blink::WebURLRequest::RequestContext GetBlinkRequestContext( |
| 49 RequestContextType request_context_type) { |
| 50 return static_cast<blink::WebURLRequest::RequestContext>( |
| 51 request_context_type); |
| 52 } |
| 53 |
| 54 blink::WebURLRequest::FrameType GetBlinkFrameType( |
| 55 RequestContextFrameType frame_type) { |
| 56 return static_cast<blink::WebURLRequest::FrameType>(frame_type); |
| 57 } |
| 58 |
48 } // namespace | 59 } // namespace |
49 | 60 |
50 ServiceWorkerScriptContext::ServiceWorkerScriptContext( | 61 ServiceWorkerScriptContext::ServiceWorkerScriptContext( |
51 EmbeddedWorkerContextClient* embedded_context, | 62 EmbeddedWorkerContextClient* embedded_context, |
52 blink::WebServiceWorkerContextProxy* proxy) | 63 blink::WebServiceWorkerContextProxy* proxy) |
53 : cache_storage_dispatcher_(new ServiceWorkerCacheStorageDispatcher(this)), | 64 : cache_storage_dispatcher_(new ServiceWorkerCacheStorageDispatcher(this)), |
54 embedded_context_(embedded_context), | 65 embedded_context_(embedded_context), |
55 proxy_(proxy) { | 66 proxy_(proxy) { |
56 } | 67 } |
57 | 68 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 195 } |
185 if (!request.blob_uuid.empty()) { | 196 if (!request.blob_uuid.empty()) { |
186 webRequest.setBlob(blink::WebString::fromUTF8(request.blob_uuid), | 197 webRequest.setBlob(blink::WebString::fromUTF8(request.blob_uuid), |
187 request.blob_size); | 198 request.blob_size); |
188 } | 199 } |
189 webRequest.setReferrer(blink::WebString::fromUTF8(request.referrer.spec()), | 200 webRequest.setReferrer(blink::WebString::fromUTF8(request.referrer.spec()), |
190 blink::WebReferrerPolicyDefault); | 201 blink::WebReferrerPolicyDefault); |
191 webRequest.setMode(GetBlinkFetchRequestMode(request.mode)); | 202 webRequest.setMode(GetBlinkFetchRequestMode(request.mode)); |
192 webRequest.setCredentialsMode( | 203 webRequest.setCredentialsMode( |
193 GetBlinkFetchCredentialsMode(request.credentials_mode)); | 204 GetBlinkFetchCredentialsMode(request.credentials_mode)); |
| 205 webRequest.setRequestContext( |
| 206 GetBlinkRequestContext(request.request_context_type)); |
| 207 webRequest.setFrameType(GetBlinkFrameType(request.frame_type)); |
194 webRequest.setIsReload(request.is_reload); | 208 webRequest.setIsReload(request.is_reload); |
195 fetch_start_timings_[request_id] = base::TimeTicks::Now(); | 209 fetch_start_timings_[request_id] = base::TimeTicks::Now(); |
196 proxy_->dispatchFetchEvent(request_id, webRequest); | 210 proxy_->dispatchFetchEvent(request_id, webRequest); |
197 } | 211 } |
198 | 212 |
199 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { | 213 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { |
200 TRACE_EVENT0("ServiceWorker", | 214 TRACE_EVENT0("ServiceWorker", |
201 "ServiceWorkerScriptContext::OnSyncEvent"); | 215 "ServiceWorkerScriptContext::OnSyncEvent"); |
202 proxy_->dispatchSyncEvent(request_id); | 216 proxy_->dispatchSyncEvent(request_id); |
203 } | 217 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 return; | 261 return; |
248 } | 262 } |
249 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( | 263 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( |
250 new blink::WebServiceWorkerClientsInfo); | 264 new blink::WebServiceWorkerClientsInfo); |
251 info->clientIDs = client_ids; | 265 info->clientIDs = client_ids; |
252 callbacks->onSuccess(info.release()); | 266 callbacks->onSuccess(info.release()); |
253 pending_clients_callbacks_.Remove(request_id); | 267 pending_clients_callbacks_.Remove(request_id); |
254 } | 268 } |
255 | 269 |
256 } // namespace content | 270 } // namespace content |
OLD | NEW |