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" | |
| 15 #include "third_party/WebKit/public/platform/WebURL.h" | |
| 13 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" | 16 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" |
| 14 #include "third_party/WebKit/public/web/WebServiceWorkerContextProxy.h" | 17 #include "third_party/WebKit/public/web/WebServiceWorkerContextProxy.h" |
| 15 | 18 |
| 16 namespace content { | 19 namespace content { |
| 17 | 20 |
| 18 namespace { | 21 namespace { |
| 19 | 22 |
| 20 void SendPostMessageToDocumentOnMainThread( | 23 void SendPostMessageToDocumentOnMainThread( |
| 21 ThreadSafeSender* sender, | 24 ThreadSafeSender* sender, |
| 22 int routing_id, | 25 int routing_id, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 } | 117 } |
| 115 | 118 |
| 116 void ServiceWorkerScriptContext::OnInstallEvent(int request_id, | 119 void ServiceWorkerScriptContext::OnInstallEvent(int request_id, |
| 117 int active_version_id) { | 120 int active_version_id) { |
| 118 proxy_->dispatchInstallEvent(request_id); | 121 proxy_->dispatchInstallEvent(request_id); |
| 119 } | 122 } |
| 120 | 123 |
| 121 void ServiceWorkerScriptContext::OnFetchEvent( | 124 void ServiceWorkerScriptContext::OnFetchEvent( |
| 122 int request_id, | 125 int request_id, |
| 123 const ServiceWorkerFetchRequest& request) { | 126 const ServiceWorkerFetchRequest& request) { |
| 124 // TODO(falken): Pass in the request. | 127 blink::WebServiceWorkerRequest webRequest; |
| 125 proxy_->dispatchFetchEvent(request_id); | 128 webRequest.setURL(blink::WebURL(request.url)); |
| 129 webRequest.setMethod(blink::WebString(base::UTF8ToUTF16(request.method))); | |
|
falken
2014/05/30 09:37:01
Why convert to UTF16? WebString::fromUTF8(string)
horo
2014/05/30 10:11:46
Done.
| |
| 130 for (std::map<std::string, std::string>::const_iterator it = | |
| 131 request.headers.begin(); | |
| 132 it != request.headers.end(); | |
| 133 ++it) { | |
| 134 webRequest.setHeader(blink::WebString(base::UTF8ToUTF16(it->first)), | |
| 135 blink::WebString(base::UTF8ToUTF16(it->second))); | |
| 136 } | |
| 137 proxy_->dispatchFetchEvent(request_id, webRequest); | |
| 126 } | 138 } |
| 127 | 139 |
| 128 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { | 140 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { |
| 129 proxy_->dispatchSyncEvent(request_id); | 141 proxy_->dispatchSyncEvent(request_id); |
| 130 } | 142 } |
| 131 | 143 |
| 132 void ServiceWorkerScriptContext::OnPostMessage( | 144 void ServiceWorkerScriptContext::OnPostMessage( |
| 133 const base::string16& message, | 145 const base::string16& message, |
| 134 const std::vector<int>& sent_message_port_ids, | 146 const std::vector<int>& sent_message_port_ids, |
| 135 const std::vector<int>& new_routing_ids) { | 147 const std::vector<int>& new_routing_ids) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 159 info->clientIDs = client_ids; | 171 info->clientIDs = client_ids; |
| 160 callbacks->onSuccess(info.release()); | 172 callbacks->onSuccess(info.release()); |
| 161 pending_clients_callbacks_.Remove(request_id); | 173 pending_clients_callbacks_.Remove(request_id); |
| 162 } | 174 } |
| 163 | 175 |
| 164 int ServiceWorkerScriptContext::GetRoutingID() const { | 176 int ServiceWorkerScriptContext::GetRoutingID() const { |
| 165 return embedded_context_->embedded_worker_id(); | 177 return embedded_context_->embedded_worker_id(); |
| 166 } | 178 } |
| 167 | 179 |
| 168 } // namespace content | 180 } // namespace content |
| OLD | NEW |