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

Unified Diff: content/browser/service_worker/service_worker_dispatcher_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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_dispatcher_host.cc
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc
index 51c500c41c8bfa09814ce6f576564f5464c69f29..96f7899364741790b225525b89fba6ff67e527e8 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host.cc
@@ -16,8 +16,6 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "content/browser/bad_message.h"
-#include "content/browser/message_port_message_filter.h"
-#include "content/browser/message_port_service.h"
#include "content/browser/service_worker/embedded_worker_registry.h"
#include "content/browser/service_worker/embedded_worker_status.h"
#include "content/browser/service_worker/service_worker_client_utils.h"
@@ -107,12 +105,10 @@ std::string GetNavigationPreloadDisabledErrorMessage(
ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost(
int render_process_id,
- MessagePortMessageFilter* message_port_message_filter,
ResourceContext* resource_context)
: BrowserMessageFilter(kFilteredMessageClasses,
arraysize(kFilteredMessageClasses)),
render_process_id_(render_process_id),
- message_port_message_filter_(message_port_message_filter),
resource_context_(resource_context),
channel_ready_(false),
weak_factory_(this) {
@@ -143,7 +139,7 @@ void ServiceWorkerDispatcherHost::Init(
if (!GetContext())
return;
GetContext()->embedded_worker_registry()->AddChildProcessSender(
- render_process_id_, this, message_port_message_filter_);
+ render_process_id_, this);
}
void ServiceWorkerDispatcherHost::OnFilterAdded(IPC::Channel* channel) {
@@ -941,7 +937,7 @@ void ServiceWorkerDispatcherHost::OnPostMessageToWorker(
int provider_id,
const base::string16& message,
const url::Origin& source_origin,
- const std::vector<int>& sent_message_ports) {
+ const std::vector<MessagePort>& sent_message_ports) {
TRACE_EVENT0("ServiceWorker",
"ServiceWorkerDispatcherHost::OnPostMessageToWorker");
if (!GetContext())
@@ -971,12 +967,9 @@ void ServiceWorkerDispatcherHost::DispatchExtendableMessageEvent(
scoped_refptr<ServiceWorkerVersion> worker,
const base::string16& message,
const url::Origin& source_origin,
- const std::vector<int>& sent_message_ports,
+ const std::vector<MessagePort>& sent_message_ports,
ServiceWorkerProviderHost* sender_provider_host,
const StatusCallback& callback) {
- for (int port : sent_message_ports)
- MessagePortService::GetInstance()->HoldMessages(port);
-
switch (sender_provider_host->provider_type()) {
case SERVICE_WORKER_PROVIDER_FOR_WINDOW:
case SERVICE_WORKER_PROVIDER_FOR_WORKER:
@@ -1171,7 +1164,7 @@ void ServiceWorkerDispatcherHost::DispatchExtendableMessageEventInternal(
scoped_refptr<ServiceWorkerVersion> worker,
const base::string16& message,
const url::Origin& source_origin,
- const std::vector<int>& sent_message_ports,
+ const std::vector<MessagePort>& sent_message_ports,
const base::Optional<base::TimeDelta>& timeout,
const StatusCallback& callback,
const SourceInfo& source_info) {
@@ -1207,7 +1200,7 @@ void ServiceWorkerDispatcherHost::
scoped_refptr<ServiceWorkerVersion> worker,
const base::string16& message,
const url::Origin& source_origin,
- const std::vector<int>& sent_message_ports,
+ const std::vector<MessagePort>& sent_message_ports,
const ExtendableMessageEventSource& source,
const base::Optional<base::TimeDelta>& timeout,
const StatusCallback& callback) {
@@ -1221,16 +1214,10 @@ void ServiceWorkerDispatcherHost::
callback);
}
- MessagePortMessageFilter* filter =
- worker->embedded_worker()->message_port_message_filter();
- std::vector<int> new_routing_ids;
- filter->UpdateMessagePortsWithNewRoutes(sent_message_ports, &new_routing_ids);
-
mojom::ExtendableMessageEventPtr event = mojom::ExtendableMessageEvent::New();
event->message = message;
event->source_origin = source_origin;
- event->message_ports = sent_message_ports;
- event->new_routing_ids = new_routing_ids;
+ event->message_ports = MessagePort::ReleaseHandles(sent_message_ports);
event->source = source;
// Hide the client url if the client has a unique origin.
@@ -1247,13 +1234,10 @@ void ServiceWorkerDispatcherHost::
template <typename SourceInfo>
void ServiceWorkerDispatcherHost::DidFailToDispatchExtendableMessageEvent(
- const std::vector<int>& sent_message_ports,
+ const std::vector<MessagePort>& sent_message_ports,
const SourceInfo& source_info,
const StatusCallback& callback,
ServiceWorkerStatusCode status) {
- // Transfering the message ports failed, so destroy the ports.
- for (int port : sent_message_ports)
- MessagePortService::GetInstance()->ClosePort(port);
if (source_info.IsValid())
ReleaseSourceInfo(source_info);
callback.Run(status);

Powered by Google App Engine
This is Rietveld 408576698