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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "content/child/notifications/notification_data_conversions.h" | 10 #include "content/child/notifications/notification_data_conversions.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 GetRoutingID(), request_id)); | 226 GetRoutingID(), request_id)); |
227 } | 227 } |
228 | 228 |
229 void ServiceWorkerScriptContext::OpenWindow( | 229 void ServiceWorkerScriptContext::OpenWindow( |
230 const GURL& url, blink::WebServiceWorkerClientCallbacks* callbacks) { | 230 const GURL& url, blink::WebServiceWorkerClientCallbacks* callbacks) { |
231 DCHECK(callbacks); | 231 DCHECK(callbacks); |
232 int request_id = pending_client_callbacks_.Add(callbacks); | 232 int request_id = pending_client_callbacks_.Add(callbacks); |
233 Send(new ServiceWorkerHostMsg_OpenWindow(GetRoutingID(), request_id, url)); | 233 Send(new ServiceWorkerHostMsg_OpenWindow(GetRoutingID(), request_id, url)); |
234 } | 234 } |
235 | 235 |
| 236 void ServiceWorkerScriptContext::SetCachedMetadata(const GURL& url, |
| 237 const char* data, |
| 238 size_t size) { |
| 239 std::vector<char> copy(data, data + size); |
| 240 Send(new ServiceWorkerHostMsg_SetCachedMetadata(GetRoutingID(), url, copy)); |
| 241 } |
| 242 |
| 243 void ServiceWorkerScriptContext::ClearCachedMetadata(const GURL& url) { |
| 244 Send(new ServiceWorkerHostMsg_ClearCachedMetadata(GetRoutingID(), url)); |
| 245 } |
| 246 |
236 void ServiceWorkerScriptContext::PostMessageToDocument( | 247 void ServiceWorkerScriptContext::PostMessageToDocument( |
237 int client_id, | 248 int client_id, |
238 const base::string16& message, | 249 const base::string16& message, |
239 scoped_ptr<blink::WebMessagePortChannelArray> channels) { | 250 scoped_ptr<blink::WebMessagePortChannelArray> channels) { |
240 // This may send channels for MessagePorts, and all internal book-keeping | 251 // This may send channels for MessagePorts, and all internal book-keeping |
241 // messages for MessagePort (e.g. QueueMessages) are sent from main thread | 252 // messages for MessagePort (e.g. QueueMessages) are sent from main thread |
242 // (with thread hopping), so we need to do the same thread hopping here not | 253 // (with thread hopping), so we need to do the same thread hopping here not |
243 // to overtake those messages. | 254 // to overtake those messages. |
244 embedded_context_->main_thread_proxy()->PostTask( | 255 embedded_context_->main_thread_proxy()->PostTask( |
245 FROM_HERE, | 256 FROM_HERE, |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 NOTREACHED() << "Got stray response: " << request_id; | 576 NOTREACHED() << "Got stray response: " << request_id; |
566 return; | 577 return; |
567 } | 578 } |
568 scoped_ptr<blink::WebServiceWorkerError> error( | 579 scoped_ptr<blink::WebServiceWorkerError> error( |
569 new blink::WebServiceWorkerError(error_type, message)); | 580 new blink::WebServiceWorkerError(error_type, message)); |
570 callbacks->onError(error.release()); | 581 callbacks->onError(error.release()); |
571 pending_claim_clients_callbacks_.Remove(request_id); | 582 pending_claim_clients_callbacks_.Remove(request_id); |
572 } | 583 } |
573 | 584 |
574 } // namespace content | 585 } // namespace content |
OLD | NEW |