| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 PresentationConnection_h | 5 #ifndef PresentationConnection_h |
| 6 #define PresentationConnection_h | 6 #define PresentationConnection_h |
| 7 | 7 |
| 8 #include "core/dom/ContextLifecycleObserver.h" | 8 #include "core/dom/ContextLifecycleObserver.h" |
| 9 #include "core/events/EventTarget.h" | 9 #include "core/events/EventTarget.h" |
| 10 #include "core/fileapi/Blob.h" | 10 #include "core/fileapi/Blob.h" |
| 11 #include "core/fileapi/FileError.h" | 11 #include "core/fileapi/FileError.h" |
| 12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 13 #include "platform/weborigin/KURL.h" | 13 #include "platform/weborigin/KURL.h" |
| 14 #include "public/platform/modules/presentation/WebPresentationConnection.h" |
| 15 #include "public/platform/modules/presentation/WebPresentationConnectionProxy.h" |
| 14 #include "public/platform/modules/presentation/WebPresentationController.h" | 16 #include "public/platform/modules/presentation/WebPresentationController.h" |
| 15 #include "public/platform/modules/presentation/WebPresentationSessionInfo.h" | 17 #include "public/platform/modules/presentation/WebPresentationSessionInfo.h" |
| 16 #include "wtf/text/WTFString.h" | 18 #include "wtf/text/WTFString.h" |
| 17 #include <memory> | 19 #include <memory> |
| 18 | 20 |
| 19 namespace WTF { | 21 namespace WTF { |
| 20 class AtomicString; | 22 class AtomicString; |
| 21 } // namespace WTF | 23 } // namespace WTF |
| 22 | 24 |
| 23 namespace blink { | 25 namespace blink { |
| 24 | 26 |
| 25 class DOMArrayBuffer; | 27 class DOMArrayBuffer; |
| 26 class DOMArrayBufferView; | 28 class DOMArrayBufferView; |
| 27 class PresentationController; | 29 class PresentationController; |
| 28 class PresentationReceiver; | 30 class PresentationReceiver; |
| 29 class PresentationRequest; | 31 class PresentationRequest; |
| 30 | 32 |
| 31 class PresentationConnection final : public EventTargetWithInlineData, | 33 class PresentationConnection final : public EventTargetWithInlineData, |
| 32 public ContextClient { | 34 public ContextClient, |
| 35 public WebPresentationConnection { |
| 33 USING_GARBAGE_COLLECTED_MIXIN(PresentationConnection); | 36 USING_GARBAGE_COLLECTED_MIXIN(PresentationConnection); |
| 34 DEFINE_WRAPPERTYPEINFO(); | 37 DEFINE_WRAPPERTYPEINFO(); |
| 35 | 38 |
| 36 public: | 39 public: |
| 37 // For CallbackPromiseAdapter. | 40 // For CallbackPromiseAdapter. |
| 38 static PresentationConnection* take(ScriptPromiseResolver*, | 41 static PresentationConnection* take(ScriptPromiseResolver*, |
| 39 const WebPresentationSessionInfo&, | 42 const WebPresentationSessionInfo&, |
| 40 PresentationRequest*); | 43 PresentationRequest*); |
| 41 static PresentationConnection* take(PresentationController*, | 44 static PresentationConnection* take(PresentationController*, |
| 42 const WebPresentationSessionInfo&, | 45 const WebPresentationSessionInfo&, |
| 43 PresentationRequest*); | 46 PresentationRequest*); |
| 44 static PresentationConnection* take(PresentationReceiver*, | 47 static PresentationConnection* take(PresentationReceiver*, |
| 45 const WebPresentationSessionInfo&); | 48 const WebPresentationSessionInfo&); |
| 46 ~PresentationConnection() override; | 49 ~PresentationConnection() override; |
| 47 | 50 |
| 51 void setProxy(std::unique_ptr<WebPresentationConnectionProxy>) override; |
| 52 |
| 48 // EventTarget implementation. | 53 // EventTarget implementation. |
| 49 const AtomicString& interfaceName() const override; | 54 const AtomicString& interfaceName() const override; |
| 50 ExecutionContext* getExecutionContext() const override; | 55 ExecutionContext* getExecutionContext() const override; |
| 51 | 56 |
| 52 DECLARE_VIRTUAL_TRACE(); | 57 DECLARE_VIRTUAL_TRACE(); |
| 53 | 58 |
| 54 const String& id() const { return m_id; } | 59 const String& id() const { return m_id; } |
| 55 const WTF::AtomicString& state() const; | 60 const WTF::AtomicString& state() const; |
| 56 | 61 |
| 57 void send(const String& message, ExceptionState&); | 62 void send(const String& message, ExceptionState&); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 | 76 |
| 72 // Returns true if and only if the the session info represents this | 77 // Returns true if and only if the the session info represents this |
| 73 // connection. | 78 // connection. |
| 74 bool matches(const WebPresentationSessionInfo&) const; | 79 bool matches(const WebPresentationSessionInfo&) const; |
| 75 | 80 |
| 76 // Returns true if this connection's id equals to |id| and its url equals to | 81 // Returns true if this connection's id equals to |id| and its url equals to |
| 77 // |url|. | 82 // |url|. |
| 78 bool matches(const String& id, const KURL&) const; | 83 bool matches(const String& id, const KURL&) const; |
| 79 | 84 |
| 80 // Notifies the connection about its state change. | 85 // Notifies the connection about its state change. |
| 81 void didChangeState(WebPresentationConnectionState); | 86 void didChangeState(WebPresentationConnectionState) override; |
| 82 | 87 |
| 83 // Notifies the connection about its state change to 'closed'. | 88 // Notifies the connection about its state change to 'closed'. |
| 84 void didClose(WebPresentationConnectionCloseReason, const String& message); | 89 void didClose(WebPresentationConnectionCloseReason, const String& message); |
| 85 | 90 |
| 86 // Notifies the presentation about new message. | 91 // Notifies the presentation about new message. |
| 87 void didReceiveTextMessage(const String& message); | 92 void didReceiveTextMessage(const WebString& message) override; |
| 88 void didReceiveBinaryMessage(const uint8_t* data, size_t length); | 93 void didReceiveBinaryMessage(const uint8_t* data, size_t length) override; |
| 89 | 94 |
| 90 WebPresentationConnectionState getState(); | 95 WebPresentationConnectionState getState(); |
| 91 | 96 |
| 92 protected: | 97 protected: |
| 93 // EventTarget implementation. | 98 // EventTarget implementation. |
| 94 void addedEventListener(const AtomicString& eventType, | 99 void addedEventListener(const AtomicString& eventType, |
| 95 RegisteredEventListener&) override; | 100 RegisteredEventListener&) override; |
| 96 | 101 |
| 97 private: | 102 private: |
| 98 class BlobLoader; | 103 class BlobLoader; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 125 | 130 |
| 126 String m_id; | 131 String m_id; |
| 127 KURL m_url; | 132 KURL m_url; |
| 128 WebPresentationConnectionState m_state; | 133 WebPresentationConnectionState m_state; |
| 129 | 134 |
| 130 // For Blob data handling. | 135 // For Blob data handling. |
| 131 Member<BlobLoader> m_blobLoader; | 136 Member<BlobLoader> m_blobLoader; |
| 132 HeapDeque<Member<Message>> m_messages; | 137 HeapDeque<Member<Message>> m_messages; |
| 133 | 138 |
| 134 BinaryType m_binaryType; | 139 BinaryType m_binaryType; |
| 140 |
| 141 std::unique_ptr<WebPresentationConnectionProxy> m_proxy; |
| 135 }; | 142 }; |
| 136 | 143 |
| 137 } // namespace blink | 144 } // namespace blink |
| 138 | 145 |
| 139 #endif // PresentationConnection_h | 146 #endif // PresentationConnection_h |
| OLD | NEW |