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

Unified Diff: Source/modules/navigatorconnect/ServicePortCollection.cpp

Issue 1210633002: Update navigator.services API to use the new services.onconnect event [1/3]. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@serviceport-part3
Patch Set: rebase 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: Source/modules/navigatorconnect/ServicePortCollection.cpp
diff --git a/Source/modules/navigatorconnect/ServicePortCollection.cpp b/Source/modules/navigatorconnect/ServicePortCollection.cpp
index 142b82e6b2a9ba66d74c1c124ab93f15183ecd10..6ce5ada3946f7c902a27a9f8752035a3f82f40da 100644
--- a/Source/modules/navigatorconnect/ServicePortCollection.cpp
+++ b/Source/modules/navigatorconnect/ServicePortCollection.cpp
@@ -12,7 +12,10 @@
#include "core/dom/MessagePort.h"
#include "core/events/MessageEvent.h"
#include "modules/EventTargetModules.h"
+#include "modules/navigatorconnect/AcceptConnectionObserver.h"
#include "modules/navigatorconnect/ServicePort.h"
+#include "modules/navigatorconnect/ServicePortConnectEvent.h"
+#include "modules/navigatorconnect/ServicePortConnectEventInit.h"
#include "modules/navigatorconnect/ServicePortConnectOptions.h"
#include "public/platform/Platform.h"
#include "public/platform/modules/navigator_services/WebServicePortProvider.h"
@@ -146,6 +149,17 @@ void ServicePortCollection::postMessage(WebServicePortID portId, const WebString
dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION);
}
+void ServicePortCollection::dispatchConnectEvent(PassOwnPtr<WebServicePortConnectEventCallbacks> callbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID)
+{
+ AcceptConnectionObserver* observer = AcceptConnectionObserver::create(this, callbacks, portID, targetURL);
+ ServicePortConnectEventInit init;
+ init.setTargetURL(targetURL.string());
+ init.setOrigin(origin);
+ RefPtrWillBeRawPtr<Event> event = ServicePortConnectEvent::create(EventTypeNames::connect, init, observer);
+ dispatchEvent(event.release());
+ observer->didDispatchEvent();
+}
+
DEFINE_TRACE(ServicePortCollection)
{
visitor->trace(m_ports);
« no previous file with comments | « Source/modules/navigatorconnect/ServicePortCollection.h ('k') | Source/modules/navigatorconnect/ServicePortCollection.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698