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

Unified Diff: Source/modules/navigatorconnect/AcceptConnectionObserver.h

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
« no previous file with comments | « Source/modules/modules.gypi ('k') | Source/modules/navigatorconnect/AcceptConnectionObserver.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/navigatorconnect/AcceptConnectionObserver.h
diff --git a/Source/modules/navigatorconnect/AcceptConnectionObserver.h b/Source/modules/navigatorconnect/AcceptConnectionObserver.h
index 187ab3d184ded9f815a4c0fbab2c0316b8f2ae6e..fa4bd393a4f2b75385d52e2e582320c24c4c1e97 100644
--- a/Source/modules/navigatorconnect/AcceptConnectionObserver.h
+++ b/Source/modules/navigatorconnect/AcceptConnectionObserver.h
@@ -5,9 +5,12 @@
#ifndef AcceptConnectionObserver_h
#define AcceptConnectionObserver_h
+#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "core/dom/ContextLifecycleObserver.h"
#include "modules/ModulesExport.h"
+#include "modules/navigatorconnect/ServicePortCollection.h"
#include "platform/heap/Handle.h"
+#include "public/platform/modules/navigator_services/WebServicePort.h"
namespace blink {
@@ -24,19 +27,25 @@ class MODULES_EXPORT AcceptConnectionObserver final : public GarbageCollectedFin
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AcceptConnectionObserver);
public:
static AcceptConnectionObserver* create(ExecutionContext*, int eventID);
+ static AcceptConnectionObserver* create(ServicePortCollection*, PassOwnPtr<WebServicePortConnectEventCallbacks>, WebServicePortID, const KURL& targetURL);
void contextDestroyed() override;
// Must be called after dispatching the event. Will cause the connection to
- // be rejected if no call to acceptConnection was made.
+ // be rejected if no call to acceptConnection or respondWith was made.
void didDispatchEvent();
// Observes the promise and delays calling didHandleCrossOriginConnectEvent()
// until the given promise is resolved or rejected.
void acceptConnection(ScriptState*, ScriptPromise, ExceptionState&);
- void connectionWasRejected();
- void connectionWasAccepted(const ScriptValue&);
+ // Observes the promise and delays calling didHandleServicePortConnectEvent()
+ // until the given promise is resolved or rejected. Returns a promise that
+ // resolves to a ServicePort when the connection is accepted.
+ ScriptPromise respondWith(ScriptState*, ScriptPromise, ExceptionState&);
+
+ void responseWasRejected();
+ void responseWasResolved(const ScriptValue&);
DECLARE_VIRTUAL_TRACE();
@@ -44,8 +53,14 @@ private:
class ThenFunction;
AcceptConnectionObserver(ExecutionContext*, int eventID);
+ AcceptConnectionObserver(ServicePortCollection*, PassOwnPtr<WebServicePortConnectEventCallbacks>, WebServicePortID, const KURL& targetURL);
int m_eventID;
+ OwnPtr<WebServicePortConnectEventCallbacks> m_callbacks;
+ Member<ServicePortCollection> m_collection;
+ WebServicePortID m_portID;
+ KURL m_targetURL;
+ RefPtrWillBeMember<ScriptPromiseResolver> m_resolver;
enum State { Initial, Pending, Done };
State m_state;
« no previous file with comments | « Source/modules/modules.gypi ('k') | Source/modules/navigatorconnect/AcceptConnectionObserver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698