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

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

Issue 305893003: ServiceWorker: support Request.{url,method,origin,headers} [chromium] (2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove #include "base/strings/utf_string_conversions.h" Created 6 years, 6 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 | « no previous file | 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 "base/logging.h" 7 #include "base/logging.h"
8 #include "content/child/thread_safe_sender.h" 8 #include "content/child/thread_safe_sender.h"
9 #include "content/child/webmessageportchannel_impl.h" 9 #include "content/child/webmessageportchannel_impl.h"
10 #include "content/common/service_worker/service_worker_messages.h" 10 #include "content/common/service_worker/service_worker_messages.h"
11 #include "content/renderer/service_worker/embedded_worker_context_client.h" 11 #include "content/renderer/service_worker/embedded_worker_context_client.h"
12 #include "ipc/ipc_message.h" 12 #include "ipc/ipc_message.h"
13 #include "third_party/WebKit/public/platform/WebServiceWorkerRequest.h"
14 #include "third_party/WebKit/public/platform/WebURL.h"
13 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" 15 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h"
14 #include "third_party/WebKit/public/web/WebServiceWorkerContextProxy.h" 16 #include "third_party/WebKit/public/web/WebServiceWorkerContextProxy.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 namespace { 20 namespace {
19 21
20 void SendPostMessageToDocumentOnMainThread( 22 void SendPostMessageToDocumentOnMainThread(
21 ThreadSafeSender* sender, 23 ThreadSafeSender* sender,
22 int routing_id, 24 int routing_id,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 116 }
115 117
116 void ServiceWorkerScriptContext::OnInstallEvent(int request_id, 118 void ServiceWorkerScriptContext::OnInstallEvent(int request_id,
117 int active_version_id) { 119 int active_version_id) {
118 proxy_->dispatchInstallEvent(request_id); 120 proxy_->dispatchInstallEvent(request_id);
119 } 121 }
120 122
121 void ServiceWorkerScriptContext::OnFetchEvent( 123 void ServiceWorkerScriptContext::OnFetchEvent(
122 int request_id, 124 int request_id,
123 const ServiceWorkerFetchRequest& request) { 125 const ServiceWorkerFetchRequest& request) {
124 // TODO(falken): Pass in the request. 126 blink::WebServiceWorkerRequest webRequest;
125 proxy_->dispatchFetchEvent(request_id); 127 webRequest.setURL(blink::WebURL(request.url));
128 webRequest.setMethod(blink::WebString::fromUTF8(request.method));
129 for (std::map<std::string, std::string>::const_iterator it =
130 request.headers.begin();
131 it != request.headers.end();
132 ++it) {
133 webRequest.setHeader(blink::WebString::fromUTF8(it->first),
134 blink::WebString::fromUTF8(it->second));
135 }
136 proxy_->dispatchFetchEvent(request_id, webRequest);
126 } 137 }
127 138
128 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { 139 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) {
129 proxy_->dispatchSyncEvent(request_id); 140 proxy_->dispatchSyncEvent(request_id);
130 } 141 }
131 142
132 void ServiceWorkerScriptContext::OnPostMessage( 143 void ServiceWorkerScriptContext::OnPostMessage(
133 const base::string16& message, 144 const base::string16& message,
134 const std::vector<int>& sent_message_port_ids, 145 const std::vector<int>& sent_message_port_ids,
135 const std::vector<int>& new_routing_ids) { 146 const std::vector<int>& new_routing_ids) {
(...skipping 23 matching lines...) Expand all
159 info->clientIDs = client_ids; 170 info->clientIDs = client_ids;
160 callbacks->onSuccess(info.release()); 171 callbacks->onSuccess(info.release());
161 pending_clients_callbacks_.Remove(request_id); 172 pending_clients_callbacks_.Remove(request_id);
162 } 173 }
163 174
164 int ServiceWorkerScriptContext::GetRoutingID() const { 175 int ServiceWorkerScriptContext::GetRoutingID() const {
165 return embedded_context_->embedded_worker_id(); 176 return embedded_context_->embedded_worker_id();
166 } 177 }
167 178
168 } // namespace content 179 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698