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

Unified Diff: content/browser/service_worker/service_worker_version.h

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 close connections when a 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/service_worker/service_worker_version.h
diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h
index 922f12bb4c8ca70963431f163639e33964d2172e..984de9bf1587730b7f2db7df94e90c89e13541bd 100644
--- a/content/browser/service_worker/service_worker_version.h
+++ b/content/browser/service_worker/service_worker_version.h
@@ -22,8 +22,12 @@
#include "content/browser/service_worker/embedded_worker_instance.h"
#include "content/browser/service_worker/service_worker_script_cache_map.h"
#include "content/common/content_export.h"
+#include "content/common/service_port_service.mojom.h"
#include "content/common/service_worker/service_worker_status_code.h"
#include "content/common/service_worker/service_worker_types.h"
+#include "content/public/common/service_registry.h"
+#include "mojo/common/common_type_converters.h"
+#include "mojo/common/url_type_converters.h"
#include "third_party/WebKit/public/platform/WebGeofencingEventType.h"
#include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h"
@@ -69,8 +73,10 @@ class CONTENT_EXPORT ServiceWorkerVersion
ServiceWorkerFetchEventResult,
const ServiceWorkerResponse&)> FetchCallback;
typedef base::Callback<void(ServiceWorkerStatusCode,
- bool /* accept_connction */)>
- CrossOriginConnectCallback;
+ bool /* accept_connction */,
+ const base::string16& /* name */,
+ const base::string16& /* data */)>
+ ServicePortConnectCallback;
typedef base::Callback<void(ServiceWorkerStatusCode, const std::vector<int>&)>
SendStashedPortsCallback;
@@ -237,13 +243,15 @@ class CONTENT_EXPORT ServiceWorkerVersion
const std::string& region_id,
const blink::WebCircularGeofencingRegion& region);
- // Sends a cross origin connect event to the associated embedded worker and
+ // Sends a ServicePort connect event to the associated embedded worker and
// asynchronously calls |callback| with the response from the worker.
//
// This must be called when the status() is ACTIVATED.
- void DispatchCrossOriginConnectEvent(
- const CrossOriginConnectCallback& callback,
- const NavigatorConnectClient& client);
+ void DispatchServicePortConnectEvent(
+ const ServicePortConnectCallback& callback,
+ const GURL& target_url,
+ const GURL& origin,
+ int port_id);
// Sends a cross origin message event to the associated embedded worker and
// asynchronously calls |callback| when the message was sent (or failed to
@@ -363,7 +371,7 @@ class CONTENT_EXPORT ServiceWorkerVersion
REQUEST_NOTIFICATION_CLICK,
REQUEST_PUSH,
REQUEST_GEOFENCING,
- REQUEST_CROSS_ORIGIN_CONNECT
+ REQUEST_SERVICE_PORT_CONNECT
};
struct RequestInfo {
@@ -428,8 +436,10 @@ class CONTENT_EXPORT ServiceWorkerVersion
void OnPushEventFinished(int request_id,
blink::WebServiceWorkerEventResult result);
void OnGeofencingEventFinished(int request_id);
- void OnCrossOriginConnectEventFinished(int request_id,
- bool accept_connection);
+ void OnServicePortConnectEventFinished(int request_id,
+ ServicePortConnectResult result,
+ const mojo::String& name,
+ const mojo::String& data);
void OnOpenWindow(int request_id, GURL url);
void DidOpenWindow(int request_id,
int render_process_id,
@@ -522,6 +532,13 @@ class CONTENT_EXPORT ServiceWorkerVersion
void OnStoppedInternal(EmbeddedWorkerInstance::Status old_status);
+ template <typename Interface, typename Callback>
+ void OnMojoConnectionError(
+ mojo::InterfacePtr<Interface>* interface,
+ IDMap<Callback, IDMapOwnPointer>* callbacks,
+ const base::Callback<void(const Callback&, ServiceWorkerStatusCode)>
+ callback);
+
const int64 version_id_;
const int64 registration_id_;
const GURL script_url_;
@@ -542,8 +559,10 @@ class CONTENT_EXPORT ServiceWorkerVersion
IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_;
IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_;
IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_;
- IDMap<CrossOriginConnectCallback, IDMapOwnPointer>
- cross_origin_connect_callbacks_;
+ IDMap<ServicePortConnectCallback, IDMapOwnPointer>
+ service_port_connect_callbacks_;
+
+ ServicePortDispatcherPtr service_port_dispatcher_;
std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_;

Powered by Google App Engine
This is Rietveld 408576698