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

Unified Diff: Source/modules/navigatorconnect/ServicePortCollection.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/ServicePortCollection.h
diff --git a/Source/modules/navigatorconnect/ServicePortCollection.h b/Source/modules/navigatorconnect/ServicePortCollection.h
index c8f1b7c83f5df0ae2311b3a87333368fdbe4ec22..abf550d594f6a012cdf0df6b8d613672a03ca214 100644
--- a/Source/modules/navigatorconnect/ServicePortCollection.h
+++ b/Source/modules/navigatorconnect/ServicePortCollection.h
@@ -9,17 +9,22 @@
#include "core/dom/ContextLifecycleObserver.h"
#include "core/events/EventTarget.h"
#include "modules/ModulesExport.h"
+#include "public/platform/modules/navigator_services/WebServicePortProvider.h"
+#include "public/platform/modules/navigator_services/WebServicePortProviderClient.h"
#include "wtf/RefCounted.h"
+#include "wtf/WeakPtr.h"
namespace blink {
+class ServicePort;
class ServicePortConnectOptions;
class ServicePortMatchOptions;
class MODULES_EXPORT ServicePortCollection final
haraken 2015/06/24 23:59:59 Maybe it's better to move this class to Oilpan by
Marijn Kruisselbrink 2015/06/25 01:07:26 Yes, that would be much nicer. Done.
: public EventTargetWithInlineData
, public RefCountedWillBeNoBase<ServicePortCollection>
- , public ContextLifecycleObserver {
+ , public ContextLifecycleObserver
+ , public WebServicePortProviderClient {
DEFINE_WRAPPERTYPEINFO();
REFCOUNTED_EVENT_TARGET(ServicePortCollection);
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ServicePortCollection);
@@ -28,8 +33,22 @@ public:
static PassRefPtrWillBeRawPtr<ServicePortCollection> create(ExecutionContext*);
~ServicePortCollection() override;
+ // Adds a port to this collection to keep track of it and allow delivering
+ // events related to it.
+ void addPort(ServicePort*);
+
+ // Called when a port is closed to signal the WebServicePortProvider as well
+ // as remove the port from this collection.
+ void closePort(ServicePort*);
+
+ WebServicePortProvider* provider() { return m_provider.get(); }
+
+#if !ENABLE(OILPAN)
+ WeakPtr<ServicePortCollection> weakPtr() { return m_weakFactory.createWeakPtr(); }
haraken 2015/06/24 23:59:59 Then you can remove this.
Marijn Kruisselbrink 2015/06/25 01:07:26 Done
+#endif
+
// ServicePortCollection.idl
- ScriptPromise connect(ScriptState*, const String& url, const ServicePortConnectOptions&);
+ ScriptPromise connect(ScriptState*, const String& url, const ServicePortConnectOptions&, ExceptionState&);
ScriptPromise match(ScriptState*, const ServicePortMatchOptions&);
ScriptPromise matchAll(ScriptState*, const ServicePortMatchOptions&);
DEFINE_ATTRIBUTE_EVENT_LISTENER(connect);
@@ -40,10 +59,19 @@ public:
const AtomicString& interfaceName() const override;
ExecutionContext* executionContext() const override;
+ // WebServicePortProviderClient overrides.
+ void postMessage(WebServicePortID, const WebString&, const WebMessagePortChannelArray&) override;
+
DECLARE_VIRTUAL_TRACE();
private:
explicit ServicePortCollection(ExecutionContext*);
+
+ OwnPtr<WebServicePortProvider> m_provider;
+ PersistentHeapVectorWillBeHeapVector<Member<ServicePort>> m_ports;
haraken 2015/06/24 23:59:59 This can be HeapVector<Member<>>.
Marijn Kruisselbrink 2015/06/25 01:07:26 Done
+#if !ENABLE(OILPAN)
+ WeakPtrFactory<ServicePortCollection> m_weakFactory;
haraken 2015/06/24 23:59:59 And you can remove this.
Marijn Kruisselbrink 2015/06/25 01:07:26 Done
+#endif
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698