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; |