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

Unified Diff: content/browser/navigator_connect/navigator_connect_service_worker_service_factory.cc

Issue 1210643002: Update navigator.services API to use the new services.onconnect event [2/3]. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serviceport
Patch Set: properly run error callbacks when worker is stopped Created 5 years, 5 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/navigator_connect/navigator_connect_service_worker_service_factory.cc
diff --git a/content/browser/navigator_connect/navigator_connect_service_worker_service_factory.cc b/content/browser/navigator_connect/navigator_connect_service_worker_service_factory.cc
index 17ee080c87fd09784cbfaa80fde0bbe1f11f3c43..36f4ed4fbb9afb6e3ba9266ef5e2c77ee290b04e 100644
--- a/content/browser/navigator_connect/navigator_connect_service_worker_service_factory.cc
+++ b/content/browser/navigator_connect/navigator_connect_service_worker_service_factory.cc
@@ -156,24 +156,25 @@ void NavigatorConnectServiceWorkerServiceFactory::GotServiceWorkerRegistration(
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(callback, client, registration, status, false);
+ OnConnectResult(callback, client, registration, status, false,
+ base::string16(), base::string16());
return;
}
ServiceWorkerVersion* active_version = registration->active_version();
if (!active_version) {
// No active version, reject connection attempt.
- OnConnectResult(callback, client, registration, status, false);
+ OnConnectResult(callback, client, registration, status, false,
+ base::string16(), base::string16());
return;
}
- active_version->DispatchCrossOriginConnectEvent(
+ active_version->DispatchServicePortConnectEvent(
base::Bind(&NavigatorConnectServiceWorkerServiceFactory::OnConnectResult,
weak_factory_.GetWeakPtr(), callback, client, registration),
- client);
+ client.target_url, client.origin, client.message_port_id);
}
void NavigatorConnectServiceWorkerServiceFactory::OnConnectResult(
@@ -181,7 +182,9 @@ void NavigatorConnectServiceWorkerServiceFactory::OnConnectResult(
const NavigatorConnectClient& client,
const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration,
ServiceWorkerStatusCode status,
- bool accept_connection) {
+ bool accept_connection,
+ const base::string16& name,
+ const base::string16& data) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (status != SERVICE_WORKER_OK || !accept_connection) {
@@ -189,6 +192,7 @@ void NavigatorConnectServiceWorkerServiceFactory::OnConnectResult(
return;
}
+ // TODO(mek): Keep track of name and data for this port.
// TODO(mek): http://crbug.com/462744 Keep track of these
// NavigatorConnectServiceWorkerService instances and clean them up when a
// service worker registration is deleted.

Powered by Google App Engine
This is Rietveld 408576698