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

Side by Side Diff: content/renderer/service_worker/service_worker_script_context.cc

Issue 588153002: [ServiceWorker] Plumbing the request mode from the renderer to the ServiceWorker. [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 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
« no previous file with comments | « content/common/service_worker/service_worker_types.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 7 #include <map>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 17 matching lines...) Expand all
28 ThreadSafeSender* sender, 28 ThreadSafeSender* sender,
29 int routing_id, 29 int routing_id,
30 int client_id, 30 int client_id,
31 const base::string16& message, 31 const base::string16& message,
32 scoped_ptr<blink::WebMessagePortChannelArray> channels) { 32 scoped_ptr<blink::WebMessagePortChannelArray> channels) {
33 sender->Send(new ServiceWorkerHostMsg_PostMessageToDocument( 33 sender->Send(new ServiceWorkerHostMsg_PostMessageToDocument(
34 routing_id, client_id, message, 34 routing_id, client_id, message,
35 WebMessagePortChannelImpl::ExtractMessagePortIDs(channels.release()))); 35 WebMessagePortChannelImpl::ExtractMessagePortIDs(channels.release())));
36 } 36 }
37 37
38 blink::WebURLRequest::FetchRequestMode GetBlinkFetchRequestMode(
39 FetchRequestMode mode) {
40 switch (mode) {
41 case FETCH_REQUEST_MODE_SAME_ORIGIN:
42 return blink::WebURLRequest::FetchRequestModeSameOrigin;
jochen (gone - plz use gerrit) 2014/09/29 12:56:44 nit. you could just use ASSERT_MATCHING_ENUM() and
horo 2014/09/30 02:15:39 Done.
43 break;
44 case FETCH_REQUEST_MODE_NO_CORS:
45 return blink::WebURLRequest::FetchRequestModeNoCORS;
46 break;
47 case FETCH_REQUEST_MODE_CORS:
48 return blink::WebURLRequest::FetchRequestModeCORS;
49 break;
50 case FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT:
51 return blink::WebURLRequest::FetchRequestModeCORSWithForcedPreflight;
52 break;
53 }
54 NOTREACHED();
55 return blink::WebURLRequest::FetchRequestModeNoCORS;
56 }
57
38 } // namespace 58 } // namespace
39 59
40 ServiceWorkerScriptContext::ServiceWorkerScriptContext( 60 ServiceWorkerScriptContext::ServiceWorkerScriptContext(
41 EmbeddedWorkerContextClient* embedded_context, 61 EmbeddedWorkerContextClient* embedded_context,
42 blink::WebServiceWorkerContextProxy* proxy) 62 blink::WebServiceWorkerContextProxy* proxy)
43 : cache_storage_dispatcher_(new ServiceWorkerCacheStorageDispatcher(this)), 63 : cache_storage_dispatcher_(new ServiceWorkerCacheStorageDispatcher(this)),
44 embedded_context_(embedded_context), 64 embedded_context_(embedded_context),
45 proxy_(proxy) { 65 proxy_(proxy) {
46 } 66 }
47 67
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ++it) { 174 ++it) {
155 webRequest.setHeader(blink::WebString::fromUTF8(it->first), 175 webRequest.setHeader(blink::WebString::fromUTF8(it->first),
156 blink::WebString::fromUTF8(it->second)); 176 blink::WebString::fromUTF8(it->second));
157 } 177 }
158 if (!request.blob_uuid.empty()) { 178 if (!request.blob_uuid.empty()) {
159 webRequest.setBlob(blink::WebString::fromUTF8(request.blob_uuid), 179 webRequest.setBlob(blink::WebString::fromUTF8(request.blob_uuid),
160 request.blob_size); 180 request.blob_size);
161 } 181 }
162 webRequest.setReferrer(blink::WebString::fromUTF8(request.referrer.spec()), 182 webRequest.setReferrer(blink::WebString::fromUTF8(request.referrer.spec()),
163 blink::WebReferrerPolicyDefault); 183 blink::WebReferrerPolicyDefault);
184 webRequest.setMode(GetBlinkFetchRequestMode(request.mode));
164 webRequest.setIsReload(request.is_reload); 185 webRequest.setIsReload(request.is_reload);
165 proxy_->dispatchFetchEvent(request_id, webRequest); 186 proxy_->dispatchFetchEvent(request_id, webRequest);
166 } 187 }
167 188
168 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { 189 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) {
169 TRACE_EVENT0("ServiceWorker", 190 TRACE_EVENT0("ServiceWorker",
170 "ServiceWorkerScriptContext::OnSyncEvent"); 191 "ServiceWorkerScriptContext::OnSyncEvent");
171 proxy_->dispatchSyncEvent(request_id); 192 proxy_->dispatchSyncEvent(request_id);
172 } 193 }
173 194
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return; 231 return;
211 } 232 }
212 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( 233 scoped_ptr<blink::WebServiceWorkerClientsInfo> info(
213 new blink::WebServiceWorkerClientsInfo); 234 new blink::WebServiceWorkerClientsInfo);
214 info->clientIDs = client_ids; 235 info->clientIDs = client_ids;
215 callbacks->onSuccess(info.release()); 236 callbacks->onSuccess(info.release());
216 pending_clients_callbacks_.Remove(request_id); 237 pending_clients_callbacks_.Remove(request_id);
217 } 238 }
218 239
219 } // namespace content 240 } // namespace content
OLDNEW
« no previous file with comments | « content/common/service_worker/service_worker_types.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698