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

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

Issue 861373002: Refactor navigator.connect code to make it more flexible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 5 years, 10 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 | « content/renderer/service_worker/service_worker_script_context.h ('k') | 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/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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 TRACE_EVENT0("ServiceWorker", 340 TRACE_EVENT0("ServiceWorker",
341 "ServiceWorkerScriptContext::OnGeofencingEvent"); 341 "ServiceWorkerScriptContext::OnGeofencingEvent");
342 proxy_->dispatchGeofencingEvent( 342 proxy_->dispatchGeofencingEvent(
343 request_id, event_type, blink::WebString::fromUTF8(region_id), region); 343 request_id, event_type, blink::WebString::fromUTF8(region_id), region);
344 Send(new ServiceWorkerHostMsg_GeofencingEventFinished(GetRoutingID(), 344 Send(new ServiceWorkerHostMsg_GeofencingEventFinished(GetRoutingID(),
345 request_id)); 345 request_id));
346 } 346 }
347 347
348 void ServiceWorkerScriptContext::OnCrossOriginConnectEvent( 348 void ServiceWorkerScriptContext::OnCrossOriginConnectEvent(
349 int request_id, 349 int request_id,
350 const CrossOriginServiceWorkerClient& client) { 350 const NavigatorConnectClient& client) {
351 TRACE_EVENT0("ServiceWorker", 351 TRACE_EVENT0("ServiceWorker",
352 "ServiceWorkerScriptContext::OnCrossOriginConnectEvent"); 352 "ServiceWorkerScriptContext::OnCrossOriginConnectEvent");
353 blink::WebCrossOriginServiceWorkerClient web_client; 353 blink::WebCrossOriginServiceWorkerClient web_client;
354 web_client.origin = client.origin; 354 web_client.origin = client.origin;
355 web_client.targetURL = client.target_url; 355 web_client.targetURL = client.target_url;
356 web_client.clientID = client.message_port_id; 356 web_client.clientID = client.message_port_id;
357 proxy_->dispatchCrossOriginConnectEvent(request_id, web_client); 357 proxy_->dispatchCrossOriginConnectEvent(request_id, web_client);
358 } 358 }
359 359
360 void ServiceWorkerScriptContext::OnPostMessage( 360 void ServiceWorkerScriptContext::OnPostMessage(
(...skipping 15 matching lines...) Expand all
376 // dispatchMessageEvent is expected to execute onmessage function 376 // dispatchMessageEvent is expected to execute onmessage function
377 // synchronously. 377 // synchronously.
378 base::TimeTicks before = base::TimeTicks::Now(); 378 base::TimeTicks before = base::TimeTicks::Now();
379 proxy_->dispatchMessageEvent(message, ports); 379 proxy_->dispatchMessageEvent(message, ports);
380 UMA_HISTOGRAM_TIMES( 380 UMA_HISTOGRAM_TIMES(
381 "ServiceWorker.MessageEventExecutionTime", 381 "ServiceWorker.MessageEventExecutionTime",
382 base::TimeTicks::Now() - before); 382 base::TimeTicks::Now() - before);
383 } 383 }
384 384
385 void ServiceWorkerScriptContext::OnCrossOriginMessageToWorker( 385 void ServiceWorkerScriptContext::OnCrossOriginMessageToWorker(
386 const CrossOriginServiceWorkerClient& client, 386 const NavigatorConnectClient& client,
387 const base::string16& message, 387 const base::string16& message,
388 const std::vector<int>& sent_message_port_ids, 388 const std::vector<int>& sent_message_port_ids,
389 const std::vector<int>& new_routing_ids) { 389 const std::vector<int>& new_routing_ids) {
390 TRACE_EVENT0("ServiceWorker", 390 TRACE_EVENT0("ServiceWorker",
391 "ServiceWorkerScriptContext::OnCrossOriginMessageToWorker"); 391 "ServiceWorkerScriptContext::OnCrossOriginMessageToWorker");
392 std::vector<WebMessagePortChannelImpl*> ports; 392 std::vector<WebMessagePortChannelImpl*> ports;
393 if (!sent_message_port_ids.empty()) { 393 if (!sent_message_port_ids.empty()) {
394 base::MessageLoopProxy* loop_proxy = embedded_context_->main_thread_proxy(); 394 base::MessageLoopProxy* loop_proxy = embedded_context_->main_thread_proxy();
395 ports.resize(sent_message_port_ids.size()); 395 ports.resize(sent_message_port_ids.size());
396 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { 396 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 pending_skip_waiting_callbacks_.Lookup(request_id); 454 pending_skip_waiting_callbacks_.Lookup(request_id);
455 if (!callbacks) { 455 if (!callbacks) {
456 NOTREACHED() << "Got stray response: " << request_id; 456 NOTREACHED() << "Got stray response: " << request_id;
457 return; 457 return;
458 } 458 }
459 callbacks->onSuccess(); 459 callbacks->onSuccess();
460 pending_skip_waiting_callbacks_.Remove(request_id); 460 pending_skip_waiting_callbacks_.Remove(request_id);
461 } 461 }
462 462
463 } // namespace content 463 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/service_worker/service_worker_script_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698