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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "content/child/notifications/notification_data_conversions.h" | 10 #include "content/child/notifications/notification_data_conversions.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 TRACE_EVENT0("ServiceWorker", | 332 TRACE_EVENT0("ServiceWorker", |
333 "ServiceWorkerScriptContext::OnGeofencingEvent"); | 333 "ServiceWorkerScriptContext::OnGeofencingEvent"); |
334 proxy_->dispatchGeofencingEvent( | 334 proxy_->dispatchGeofencingEvent( |
335 request_id, event_type, blink::WebString::fromUTF8(region_id), region); | 335 request_id, event_type, blink::WebString::fromUTF8(region_id), region); |
336 Send(new ServiceWorkerHostMsg_GeofencingEventFinished(GetRoutingID(), | 336 Send(new ServiceWorkerHostMsg_GeofencingEventFinished(GetRoutingID(), |
337 request_id)); | 337 request_id)); |
338 } | 338 } |
339 | 339 |
340 void ServiceWorkerScriptContext::OnCrossOriginConnectEvent( | 340 void ServiceWorkerScriptContext::OnCrossOriginConnectEvent( |
341 int request_id, | 341 int request_id, |
342 const CrossOriginServiceWorkerClient& client) { | 342 const NavigatorConnectClient& client) { |
343 TRACE_EVENT0("ServiceWorker", | 343 TRACE_EVENT0("ServiceWorker", |
344 "ServiceWorkerScriptContext::OnCrossOriginConnectEvent"); | 344 "ServiceWorkerScriptContext::OnCrossOriginConnectEvent"); |
345 blink::WebCrossOriginServiceWorkerClient web_client; | 345 blink::WebCrossOriginServiceWorkerClient web_client; |
346 web_client.origin = client.origin; | 346 web_client.origin = client.origin; |
347 web_client.targetURL = client.target_url; | 347 web_client.targetURL = client.target_url; |
348 web_client.clientID = client.message_port_id; | 348 web_client.clientID = client.message_port_id; |
349 proxy_->dispatchCrossOriginConnectEvent(request_id, web_client); | 349 proxy_->dispatchCrossOriginConnectEvent(request_id, web_client); |
350 } | 350 } |
351 | 351 |
352 void ServiceWorkerScriptContext::OnPostMessage( | 352 void ServiceWorkerScriptContext::OnPostMessage( |
(...skipping 15 matching lines...) Expand all Loading... |
368 // dispatchMessageEvent is expected to execute onmessage function | 368 // dispatchMessageEvent is expected to execute onmessage function |
369 // synchronously. | 369 // synchronously. |
370 base::TimeTicks before = base::TimeTicks::Now(); | 370 base::TimeTicks before = base::TimeTicks::Now(); |
371 proxy_->dispatchMessageEvent(message, ports); | 371 proxy_->dispatchMessageEvent(message, ports); |
372 UMA_HISTOGRAM_TIMES( | 372 UMA_HISTOGRAM_TIMES( |
373 "ServiceWorker.MessageEventExecutionTime", | 373 "ServiceWorker.MessageEventExecutionTime", |
374 base::TimeTicks::Now() - before); | 374 base::TimeTicks::Now() - before); |
375 } | 375 } |
376 | 376 |
377 void ServiceWorkerScriptContext::OnCrossOriginMessageToWorker( | 377 void ServiceWorkerScriptContext::OnCrossOriginMessageToWorker( |
378 const CrossOriginServiceWorkerClient& client, | 378 const NavigatorConnectClient& client, |
379 const base::string16& message, | 379 const base::string16& message, |
380 const std::vector<int>& sent_message_port_ids, | 380 const std::vector<int>& sent_message_port_ids, |
381 const std::vector<int>& new_routing_ids) { | 381 const std::vector<int>& new_routing_ids) { |
382 TRACE_EVENT0("ServiceWorker", | 382 TRACE_EVENT0("ServiceWorker", |
383 "ServiceWorkerScriptContext::OnCrossOriginMessageToWorker"); | 383 "ServiceWorkerScriptContext::OnCrossOriginMessageToWorker"); |
384 std::vector<WebMessagePortChannelImpl*> ports; | 384 std::vector<WebMessagePortChannelImpl*> ports; |
385 if (!sent_message_port_ids.empty()) { | 385 if (!sent_message_port_ids.empty()) { |
386 base::MessageLoopProxy* loop_proxy = embedded_context_->main_thread_proxy(); | 386 base::MessageLoopProxy* loop_proxy = embedded_context_->main_thread_proxy(); |
387 ports.resize(sent_message_port_ids.size()); | 387 ports.resize(sent_message_port_ids.size()); |
388 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { | 388 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 pending_skip_waiting_callbacks_.Lookup(request_id); | 446 pending_skip_waiting_callbacks_.Lookup(request_id); |
447 if (!callbacks) { | 447 if (!callbacks) { |
448 NOTREACHED() << "Got stray response: " << request_id; | 448 NOTREACHED() << "Got stray response: " << request_id; |
449 return; | 449 return; |
450 } | 450 } |
451 callbacks->onSuccess(); | 451 callbacks->onSuccess(); |
452 pending_skip_waiting_callbacks_.Remove(request_id); | 452 pending_skip_waiting_callbacks_.Remove(request_id); |
453 } | 453 } |
454 | 454 |
455 } // namespace content | 455 } // namespace content |
OLD | NEW |