OLD | NEW |
---|---|
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" | |
haraken
2015/06/25 01:21:40
Remove this.
Marijn Kruisselbrink
2015/06/25 02:18:55
Done
| |
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 |
20 : public EventTargetWithInlineData | 24 : public RefCountedGarbageCollectedEventTargetWithInlineData<ServicePortColl ection> |
21 , public RefCountedWillBeNoBase<ServicePortCollection> | 25 , public ContextLifecycleObserver |
22 , public ContextLifecycleObserver { | 26 , public WebServicePortProviderClient { |
23 DEFINE_WRAPPERTYPEINFO(); | 27 DEFINE_WRAPPERTYPEINFO(); |
24 REFCOUNTED_EVENT_TARGET(ServicePortCollection); | 28 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(ServicePortCollection); |
25 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ServicePortCollection); | |
26 WTF_MAKE_NONCOPYABLE(ServicePortCollection); | 29 WTF_MAKE_NONCOPYABLE(ServicePortCollection); |
27 public: | 30 public: |
28 static PassRefPtrWillBeRawPtr<ServicePortCollection> create(ExecutionContext *); | 31 static ServicePortCollection* create(ExecutionContext*); |
29 ~ServicePortCollection() override; | 32 ~ServicePortCollection() override; |
30 | 33 |
34 // Adds a port to this collection to keep track of it and allow delivering | |
35 // events related to it. | |
36 void addPort(ServicePort*); | |
37 | |
38 // Called when a port is closed to signal the WebServicePortProvider as well | |
39 // as remove the port from this collection. | |
40 void closePort(ServicePort*); | |
41 | |
42 WebServicePortProvider* provider() { return m_provider.get(); } | |
43 | |
31 // ServicePortCollection.idl | 44 // ServicePortCollection.idl |
32 ScriptPromise connect(ScriptState*, const String& url, const ServicePortConn ectOptions&); | 45 ScriptPromise connect(ScriptState*, const String& url, const ServicePortConn ectOptions&, ExceptionState&); |
33 ScriptPromise match(ScriptState*, const ServicePortMatchOptions&); | 46 ScriptPromise match(ScriptState*, const ServicePortMatchOptions&); |
34 ScriptPromise matchAll(ScriptState*, const ServicePortMatchOptions&); | 47 ScriptPromise matchAll(ScriptState*, const ServicePortMatchOptions&); |
35 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 48 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
36 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 49 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
37 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); | 50 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); |
38 | 51 |
39 // EventTarget overrides. | 52 // EventTarget overrides. |
40 const AtomicString& interfaceName() const override; | 53 const AtomicString& interfaceName() const override; |
41 ExecutionContext* executionContext() const override; | 54 ExecutionContext* executionContext() const override; |
42 | 55 |
56 // WebServicePortProviderClient overrides. | |
57 void postMessage(WebServicePortID, const WebString&, const WebMessagePortCha nnelArray&) override; | |
58 | |
43 DECLARE_VIRTUAL_TRACE(); | 59 DECLARE_VIRTUAL_TRACE(); |
44 | 60 |
45 private: | 61 private: |
46 explicit ServicePortCollection(ExecutionContext*); | 62 explicit ServicePortCollection(ExecutionContext*); |
63 | |
64 OwnPtr<WebServicePortProvider> m_provider; | |
65 HeapVector<Member<ServicePort>> m_ports; | |
47 }; | 66 }; |
48 | 67 |
49 } // namespace blink | 68 } // namespace blink |
50 | 69 |
51 #endif // ServicePortCollection_h | 70 #endif // ServicePortCollection_h |
OLD | NEW |