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

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

Issue 1191393003: Update client side navigator.connect API to use ServicePortCollection [1/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@serviceport
Patch Set: improve comments Created 5 years, 6 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/ServicePort.h
diff --git a/Source/modules/navigatorconnect/ServicePort.h b/Source/modules/navigatorconnect/ServicePort.h
new file mode 100644
index 0000000000000000000000000000000000000000..0aeddb3a9b941d91c0642c339791615941149ff3
--- /dev/null
+++ b/Source/modules/navigatorconnect/ServicePort.h
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef ServicePort_h
+#define ServicePort_h
+
+#include "bindings/core/v8/ScriptWrappable.h"
+#include "modules/ModulesExport.h"
+#include "public/platform/modules/navigator_services/WebServicePort.h"
+
+namespace blink {
+
+class ExceptionState;
+class ExecutionContext;
+class MessagePort;
+class ScriptState;
+class ScriptValue;
+class SerializedScriptValue;
+class ServicePortCollection;
+
+typedef WillBeHeapVector<RefPtrWillBeMember<MessagePort>, 1> MessagePortArray;
haraken 2015/06/24 23:59:59 Nit: It is a bit unfortunate we duplicate this typ
Marijn Kruisselbrink 2015/06/25 01:07:26 Agreed, I changed it to just include one of the he
+
+class MODULES_EXPORT ServicePort final
+ : public GarbageCollectedFinalized<ServicePort>, public ScriptWrappable {
+ DEFINE_WRAPPERTYPEINFO();
+ WTF_MAKE_NONCOPYABLE(ServicePort);
+public:
+ static ServicePort* create(WeakPtrWillBeRawPtr<ServicePortCollection>, const WebServicePort&);
+ virtual ~ServicePort();
+
+ WebServicePortID id() const { return m_port.id; }
+
+ // ServicePort.idl
+ String targetURL() const;
+ String name() const;
+ ScriptValue data(ScriptState*) const;
+ void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionState&);
+ void close();
+
+ DEFINE_INLINE_VIRTUAL_TRACE() { }
+
+private:
+ explicit ServicePort(WeakPtrWillBeRawPtr<ServicePortCollection>, const WebServicePort&);
haraken 2015/06/24 23:59:59 Drop explicit.
Marijn Kruisselbrink 2015/06/25 01:07:26 Done
+
+ bool m_isOpen;
+ WebServicePort m_port;
+ RefPtr<SerializedScriptValue> m_serializedData;
+ WeakPtrWillBeWeakMember<ServicePortCollection> m_collection;
haraken 2015/06/24 23:59:59 Would you help me understand why this needs to be
Marijn Kruisselbrink 2015/06/25 01:07:26 With ServicePortCollection being refcounted I had
haraken 2015/06/25 01:21:40 Cool!
+};
+
+} // namespace blink
+
+#endif // ServicePort_h

Powered by Google App Engine
This is Rietveld 408576698