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

Unified Diff: Source/modules/navigatorconnect/ServicePortConnectEvent.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/ServicePortConnectEvent.cpp
diff --git a/Source/modules/navigatorconnect/ServicePortConnectEvent.cpp b/Source/modules/navigatorconnect/ServicePortConnectEvent.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4bbc217267d9fd0767b8a96c775b4e2e117e944d
--- /dev/null
+++ b/Source/modules/navigatorconnect/ServicePortConnectEvent.cpp
@@ -0,0 +1,62 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "modules/navigatorconnect/ServicePortConnectEvent.h"
+
+#include "core/dom/DOMException.h"
+#include "core/dom/ExceptionCode.h"
+#include "modules/navigatorconnect/AcceptConnectionObserver.h"
+#include "modules/navigatorconnect/ServicePortConnectEventInit.h"
+
+namespace blink {
+
+PassRefPtrWillBeRawPtr<ServicePortConnectEvent> ServicePortConnectEvent::create()
+{
+ return adoptRefWillBeNoop(new ServicePortConnectEvent());
+}
+
+PassRefPtrWillBeRawPtr<ServicePortConnectEvent> ServicePortConnectEvent::create(const AtomicString& type, const ServicePortConnectEventInit& initializer)
+{
+ return adoptRefWillBeNoop(new ServicePortConnectEvent(type, initializer, nullptr));
+}
+
+PassRefPtrWillBeRawPtr<ServicePortConnectEvent> ServicePortConnectEvent::create(const AtomicString& type, const ServicePortConnectEventInit& initializer, AcceptConnectionObserver* observer)
+{
+ return adoptRefWillBeNoop(new ServicePortConnectEvent(type, initializer, observer));
+}
+
+ScriptPromise ServicePortConnectEvent::respondWith(ScriptState* scriptState, const ScriptPromise& response, ExceptionState& exceptionState)
+{
+ stopImmediatePropagation();
+ if (m_observer)
+ return m_observer->respondWith(scriptState, response, exceptionState);
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError));
+}
+
+const AtomicString& ServicePortConnectEvent::interfaceName() const
+{
+ return EventNames::ServicePortConnectEvent;
+}
+
+DEFINE_TRACE(ServicePortConnectEvent)
+{
+ visitor->trace(m_observer);
+ ExtendableEvent::trace(visitor);
+}
+
+ServicePortConnectEvent::ServicePortConnectEvent()
+{
+}
+
+ServicePortConnectEvent::ServicePortConnectEvent(const AtomicString& type, const ServicePortConnectEventInit& initializer, AcceptConnectionObserver* observer)
+ : ExtendableEvent(type, initializer)
+ , m_observer(observer)
+ , m_targetURL(initializer.targetURL())
+ , m_origin(initializer.origin())
+{
+}
+
+} // namespace blink
+
« no previous file with comments | « Source/modules/navigatorconnect/ServicePortConnectEvent.h ('k') | Source/modules/navigatorconnect/ServicePortConnectEvent.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698