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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ServicePortCollection_h 5 #ifndef ServicePortCollection_h
6 #define ServicePortCollection_h 6 #define ServicePortCollection_h
7 7
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "core/dom/ContextLifecycleObserver.h" 9 #include "core/dom/ContextLifecycleObserver.h"
10 #include "core/events/EventTarget.h" 10 #include "core/events/EventTarget.h"
11 #include "modules/ModulesExport.h" 11 #include "modules/ModulesExport.h"
12 #include "public/platform/modules/navigator_services/WebServicePortProvider.h"
13 #include "public/platform/modules/navigator_services/WebServicePortProviderClien t.h"
12 #include "wtf/RefCounted.h" 14 #include "wtf/RefCounted.h"
15 #include "wtf/WeakPtr.h"
13 16
14 namespace blink { 17 namespace blink {
15 18
19 class ServicePort;
16 class ServicePortConnectOptions; 20 class ServicePortConnectOptions;
17 class ServicePortMatchOptions; 21 class ServicePortMatchOptions;
18 22
19 class MODULES_EXPORT ServicePortCollection final 23 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.
20 : public EventTargetWithInlineData 24 : public EventTargetWithInlineData
21 , public RefCountedWillBeNoBase<ServicePortCollection> 25 , public RefCountedWillBeNoBase<ServicePortCollection>
22 , public ContextLifecycleObserver { 26 , public ContextLifecycleObserver
27 , public WebServicePortProviderClient {
23 DEFINE_WRAPPERTYPEINFO(); 28 DEFINE_WRAPPERTYPEINFO();
24 REFCOUNTED_EVENT_TARGET(ServicePortCollection); 29 REFCOUNTED_EVENT_TARGET(ServicePortCollection);
25 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ServicePortCollection); 30 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ServicePortCollection);
26 WTF_MAKE_NONCOPYABLE(ServicePortCollection); 31 WTF_MAKE_NONCOPYABLE(ServicePortCollection);
27 public: 32 public:
28 static PassRefPtrWillBeRawPtr<ServicePortCollection> create(ExecutionContext *); 33 static PassRefPtrWillBeRawPtr<ServicePortCollection> create(ExecutionContext *);
29 ~ServicePortCollection() override; 34 ~ServicePortCollection() override;
30 35
36 // Adds a port to this collection to keep track of it and allow delivering
37 // events related to it.
38 void addPort(ServicePort*);
39
40 // Called when a port is closed to signal the WebServicePortProvider as well
41 // as remove the port from this collection.
42 void closePort(ServicePort*);
43
44 WebServicePortProvider* provider() { return m_provider.get(); }
45
46 #if !ENABLE(OILPAN)
47 WeakPtr<ServicePortCollection> weakPtr() { return m_weakFactory.createWeakPt r(); }
haraken 2015/06/24 23:59:59 Then you can remove this.
Marijn Kruisselbrink 2015/06/25 01:07:26 Done
48 #endif
49
31 // ServicePortCollection.idl 50 // ServicePortCollection.idl
32 ScriptPromise connect(ScriptState*, const String& url, const ServicePortConn ectOptions&); 51 ScriptPromise connect(ScriptState*, const String& url, const ServicePortConn ectOptions&, ExceptionState&);
33 ScriptPromise match(ScriptState*, const ServicePortMatchOptions&); 52 ScriptPromise match(ScriptState*, const ServicePortMatchOptions&);
34 ScriptPromise matchAll(ScriptState*, const ServicePortMatchOptions&); 53 ScriptPromise matchAll(ScriptState*, const ServicePortMatchOptions&);
35 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); 54 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect);
36 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); 55 DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
37 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); 56 DEFINE_ATTRIBUTE_EVENT_LISTENER(close);
38 57
39 // EventTarget overrides. 58 // EventTarget overrides.
40 const AtomicString& interfaceName() const override; 59 const AtomicString& interfaceName() const override;
41 ExecutionContext* executionContext() const override; 60 ExecutionContext* executionContext() const override;
42 61
62 // WebServicePortProviderClient overrides.
63 void postMessage(WebServicePortID, const WebString&, const WebMessagePortCha nnelArray&) override;
64
43 DECLARE_VIRTUAL_TRACE(); 65 DECLARE_VIRTUAL_TRACE();
44 66
45 private: 67 private:
46 explicit ServicePortCollection(ExecutionContext*); 68 explicit ServicePortCollection(ExecutionContext*);
69
70 OwnPtr<WebServicePortProvider> m_provider;
71 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
72 #if !ENABLE(OILPAN)
73 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
74 #endif
47 }; 75 };
48 76
49 } // namespace blink 77 } // namespace blink
50 78
51 #endif // ServicePortCollection_h 79 #endif // ServicePortCollection_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698