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

Side by Side Diff: content/browser/service_worker/service_worker_provider_host.cc

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Add missing ScopedAsyncTaskScheduler instance for the new unit tests; required by a recent change t… Created 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/service_worker/service_worker_provider_host.h" 5 #include "content/browser/service_worker/service_worker_provider_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "content/browser/message_port_message_filter.h"
14 #include "content/browser/service_worker/embedded_worker_status.h" 13 #include "content/browser/service_worker/embedded_worker_status.h"
15 #include "content/browser/service_worker/service_worker_context_core.h" 14 #include "content/browser/service_worker/service_worker_context_core.h"
16 #include "content/browser/service_worker/service_worker_context_request_handler. h" 15 #include "content/browser/service_worker/service_worker_context_request_handler. h"
17 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h" 16 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h"
18 #include "content/browser/service_worker/service_worker_dispatcher_host.h" 17 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
19 #include "content/browser/service_worker/service_worker_handle.h" 18 #include "content/browser/service_worker/service_worker_handle.h"
20 #include "content/browser/service_worker/service_worker_registration_handle.h" 19 #include "content/browser/service_worker/service_worker_registration_handle.h"
21 #include "content/browser/service_worker/service_worker_version.h" 20 #include "content/browser/service_worker/service_worker_version.h"
22 #include "content/common/resource_request_body_impl.h" 21 #include "content/common/resource_request_body_impl.h"
23 #include "content/common/service_worker/service_worker_messages.h" 22 #include "content/common/service_worker/service_worker_messages.h"
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 if (running_hosted_version_.get()) 433 if (running_hosted_version_.get())
435 return false; 434 return false;
436 if (!registration || associated_registration_.get() || !allow_association_) 435 if (!registration || associated_registration_.get() || !allow_association_)
437 return false; 436 return false;
438 return true; 437 return true;
439 } 438 }
440 439
441 void ServiceWorkerProviderHost::PostMessageToClient( 440 void ServiceWorkerProviderHost::PostMessageToClient(
442 ServiceWorkerVersion* version, 441 ServiceWorkerVersion* version,
443 const base::string16& message, 442 const base::string16& message,
444 const std::vector<int>& sent_message_ports) { 443 const std::vector<MessagePort>& sent_message_ports) {
445 if (!dispatcher_host_) 444 if (!dispatcher_host_)
446 return; // Could be NULL in some tests. 445 return; // Could be NULL in some tests.
447 446
448 std::vector<int> new_routing_ids;
449 dispatcher_host_->message_port_message_filter()->
450 UpdateMessagePortsWithNewRoutes(sent_message_ports,
451 &new_routing_ids);
452
453 ServiceWorkerMsg_MessageToDocument_Params params; 447 ServiceWorkerMsg_MessageToDocument_Params params;
454 params.thread_id = kDocumentMainThreadId; 448 params.thread_id = kDocumentMainThreadId;
455 params.provider_id = provider_id(); 449 params.provider_id = provider_id();
456 params.service_worker_info = GetOrCreateServiceWorkerHandle(version); 450 params.service_worker_info = GetOrCreateServiceWorkerHandle(version);
457 params.message = message; 451 params.message = message;
458 params.message_ports = sent_message_ports; 452 params.message_ports = sent_message_ports;
459 params.new_routing_ids = new_routing_ids;
460 Send(new ServiceWorkerMsg_MessageToDocument(params)); 453 Send(new ServiceWorkerMsg_MessageToDocument(params));
461 } 454 }
462 455
463 void ServiceWorkerProviderHost::CountFeature(uint32_t feature) { 456 void ServiceWorkerProviderHost::CountFeature(uint32_t feature) {
464 if (!dispatcher_host_) 457 if (!dispatcher_host_)
465 return; // Could be nullptr in some tests. 458 return; // Could be nullptr in some tests.
466 459
467 // CountFeature message should be sent only for controllees. 460 // CountFeature message should be sent only for controllees.
468 DCHECK(IsProviderForClient()); 461 DCHECK(IsProviderForClient());
469 Send(new ServiceWorkerMsg_CountFeature(render_thread_id_, provider_id(), 462 Send(new ServiceWorkerMsg_CountFeature(render_thread_id_, provider_id(),
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 render_thread_id_, provider_id(), 735 render_thread_id_, provider_id(),
743 GetOrCreateServiceWorkerHandle( 736 GetOrCreateServiceWorkerHandle(
744 associated_registration_->active_version()), 737 associated_registration_->active_version()),
745 false /* shouldNotifyControllerChange */, 738 false /* shouldNotifyControllerChange */,
746 associated_registration_->active_version()->used_features())); 739 associated_registration_->active_version()->used_features()));
747 } 740 }
748 } 741 }
749 } 742 }
750 743
751 } // namespace content 744 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_provider_host.h ('k') | content/browser/service_worker/service_worker_version.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698