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

Unified Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Eliminate unnecessary PostTask 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 f23aece6697dd199ee86bd81e291c93396551376..69b6bdad48b38c1db5993bef0bcb0130c9690b4b 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) {
@@ -940,7 +936,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())
@@ -970,12 +966,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:
@@ -1170,7 +1163,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) {
@@ -1206,7 +1199,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) {
@@ -1220,16 +1213,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.
@@ -1250,13 +1237,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