Index: content/browser/navigator_connect/navigator_connect_dispatcher_host.cc |
diff --git a/content/browser/navigator_connect/navigator_connect_dispatcher_host.cc b/content/browser/navigator_connect/navigator_connect_dispatcher_host.cc |
index 3a4ae29562e0197788be10a119cf2716f8c79424..b65f4a5d2fad4b349114ec81c9d4189db2b3eb51 100644 |
--- a/content/browser/navigator_connect/navigator_connect_dispatcher_host.cc |
+++ b/content/browser/navigator_connect/navigator_connect_dispatcher_host.cc |
@@ -5,18 +5,16 @@ |
#include "content/browser/navigator_connect/navigator_connect_dispatcher_host.h" |
#include "content/browser/message_port_service.h" |
-#include "content/browser/navigator_connect/navigator_connect_context.h" |
+#include "content/browser/navigator_connect/navigator_connect_context_impl.h" |
#include "content/browser/service_worker/service_worker_context_wrapper.h" |
#include "content/common/navigator_connect_messages.h" |
-#include "content/common/navigator_connect_types.h" |
+#include "content/public/common/navigator_connect_client.h" |
namespace content { |
NavigatorConnectDispatcherHost::NavigatorConnectDispatcherHost( |
- const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context, |
- const scoped_refptr<NavigatorConnectContext>& navigator_connect_context) |
+ const scoped_refptr<NavigatorConnectContextImpl>& navigator_connect_context) |
: BrowserMessageFilter(NavigatorConnectMsgStart), |
- service_worker_context_(service_worker_context), |
navigator_connect_context_(navigator_connect_context) { |
} |
@@ -36,65 +34,21 @@ bool NavigatorConnectDispatcherHost::OnMessageReceived( |
void NavigatorConnectDispatcherHost::OnConnect( |
int thread_id, |
int request_id, |
- const CrossOriginServiceWorkerClient& client) { |
+ const NavigatorConnectClient& client) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
- // Hold messages for port while setting up connection. |
- MessagePortService::GetInstance()->HoldMessages(client.message_port_id); |
- |
- // Find the right service worker to service this connection. |
- service_worker_context_->context()->storage()->FindRegistrationForDocument( |
- client.target_url, |
- base::Bind(&NavigatorConnectDispatcherHost::GotServiceWorkerRegistration, |
- this, thread_id, request_id, client)); |
-} |
- |
-void NavigatorConnectDispatcherHost::GotServiceWorkerRegistration( |
- int thread_id, |
- int request_id, |
- const CrossOriginServiceWorkerClient& client, |
- ServiceWorkerStatusCode status, |
- const scoped_refptr<ServiceWorkerRegistration>& registration) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
- |
- if (status != SERVICE_WORKER_OK) { |
- // No service worker found, reject connection attempt. |
- OnConnectResult(thread_id, request_id, client, registration, status, false); |
- return; |
- } |
- |
- ServiceWorkerVersion* active_version = registration->active_version(); |
- if (!active_version) { |
- // No active version, reject connection attempt. |
- OnConnectResult(thread_id, request_id, client, registration, status, false); |
- return; |
- } |
- |
- active_version->DispatchCrossOriginConnectEvent( |
- base::Bind(&NavigatorConnectDispatcherHost::OnConnectResult, this, |
- thread_id, request_id, client, registration), |
- client); |
+ navigator_connect_context_->Connect( |
+ client, base::Bind(&NavigatorConnectDispatcherHost::OnConnectResult, this, |
+ thread_id, request_id)); |
} |
void NavigatorConnectDispatcherHost::OnConnectResult( |
int thread_id, |
int request_id, |
- const CrossOriginServiceWorkerClient& client, |
- const scoped_refptr<ServiceWorkerRegistration>& registration, |
- ServiceWorkerStatusCode status, |
bool accept_connection) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
- |
- if (status != SERVICE_WORKER_OK || !accept_connection) { |
- // Close port since connection failed. |
- MessagePortService::GetInstance()->ClosePort(client.message_port_id); |
- Send(new NavigatorConnectMsg_ConnectResult(thread_id, request_id, false)); |
- return; |
- } |
- |
- // Register connection and post back result. |
- navigator_connect_context_->RegisterConnection(client, registration); |
- Send(new NavigatorConnectMsg_ConnectResult(thread_id, request_id, true)); |
+ Send(new NavigatorConnectMsg_ConnectResult(thread_id, request_id, |
+ accept_connection)); |
} |
} // namespace content |