Chromium Code Reviews| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/utf_string_conversions.h" | |
| 8 #include "content/child/thread_safe_sender.h" | 9 #include "content/child/thread_safe_sender.h" |
| 9 #include "content/child/webmessageportchannel_impl.h" | 10 #include "content/child/webmessageportchannel_impl.h" |
| 10 #include "content/common/service_worker/service_worker_messages.h" | 11 #include "content/common/service_worker/service_worker_messages.h" |
| 11 #include "content/renderer/service_worker/embedded_worker_context_client.h" | 12 #include "content/renderer/service_worker/embedded_worker_context_client.h" |
| 12 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
| 14 #include "third_party/WebKit/public/platform/WebServiceWorkerRequest.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 Loading... | |
| 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::WebString(base::UTF8ToUTF16(request.url.spec()))); |
|
falken
2014/05/30 03:39:17
It seems more common in the codebase to use WebStr
horo
2014/05/30 04:55:18
I changed to use WebURL in WebServiceWorkerRequest
| |
| 128 webRequest.setMethod(blink::WebString(base::UTF8ToUTF16(request.method))); | |
| 129 webRequest.setOrigin( | |
| 130 blink::WebString(base::UTF8ToUTF16(request.url.GetOrigin().spec()))); | |
| 131 for (std::map<std::string, std::string>::const_iterator it = | |
| 132 request.headers.begin(); | |
| 133 it != request.headers.end(); | |
| 134 ++it) { | |
| 135 webRequest.setHeader(blink::WebString(base::UTF8ToUTF16(it->first)), | |
| 136 blink::WebString(base::UTF8ToUTF16(it->second))); | |
| 137 } | |
| 138 proxy_->dispatchFetchEvent(request_id, webRequest); | |
| 126 } | 139 } |
| 127 | 140 |
| 128 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { | 141 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { |
| 129 proxy_->dispatchSyncEvent(request_id); | 142 proxy_->dispatchSyncEvent(request_id); |
| 130 } | 143 } |
| 131 | 144 |
| 132 void ServiceWorkerScriptContext::OnPostMessage( | 145 void ServiceWorkerScriptContext::OnPostMessage( |
| 133 const base::string16& message, | 146 const base::string16& message, |
| 134 const std::vector<int>& sent_message_port_ids, | 147 const std::vector<int>& sent_message_port_ids, |
| 135 const std::vector<int>& new_routing_ids) { | 148 const std::vector<int>& new_routing_ids) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 159 info->clientIDs = client_ids; | 172 info->clientIDs = client_ids; |
| 160 callbacks->onSuccess(info.release()); | 173 callbacks->onSuccess(info.release()); |
| 161 pending_clients_callbacks_.Remove(request_id); | 174 pending_clients_callbacks_.Remove(request_id); |
| 162 } | 175 } |
| 163 | 176 |
| 164 int ServiceWorkerScriptContext::GetRoutingID() const { | 177 int ServiceWorkerScriptContext::GetRoutingID() const { |
| 165 return embedded_context_->embedded_worker_id(); | 178 return embedded_context_->embedded_worker_id(); |
| 166 } | 179 } |
| 167 | 180 |
| 168 } // namespace content | 181 } // namespace content |
| OLD | NEW |