| 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/events/EventTarget.h" | 8 #include "core/events/EventTarget.h" |
| 9 #include "core/fileapi/Blob.h" | 9 #include "core/fileapi/Blob.h" |
| 10 #include "core/fileapi/FileError.h" | 10 #include "core/fileapi/FileError.h" |
| 11 #include "core/frame/DOMWindowProperty.h" | 11 #include "core/frame/DOMWindowProperty.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" |
| 14 #include "public/platform/modules/presentation/WebPresentationConnectionClient.h
" | 15 #include "public/platform/modules/presentation/WebPresentationConnectionClient.h
" |
| 16 #include "public/platform/modules/presentation/WebPresentationConnectionProxy.h" |
| 15 #include "wtf/text/WTFString.h" | 17 #include "wtf/text/WTFString.h" |
| 16 #include <memory> | 18 #include <memory> |
| 17 | 19 |
| 18 namespace WTF { | 20 namespace WTF { |
| 19 class AtomicString; | 21 class AtomicString; |
| 20 } // namespace WTF | 22 } // namespace WTF |
| 21 | 23 |
| 22 namespace blink { | 24 namespace blink { |
| 23 | 25 |
| 24 class DOMArrayBuffer; | 26 class DOMArrayBuffer; |
| 25 class DOMArrayBufferView; | 27 class DOMArrayBufferView; |
| 26 class PresentationController; | 28 class PresentationController; |
| 27 class PresentationReceiver; | 29 class PresentationReceiver; |
| 28 class PresentationRequest; | 30 class PresentationRequest; |
| 29 | 31 |
| 30 class PresentationConnection final : public EventTargetWithInlineData, | 32 class PresentationConnection final : public EventTargetWithInlineData, |
| 31 public DOMWindowProperty { | 33 public DOMWindowProperty, |
| 34 public WebPresentationConnection { |
| 32 USING_GARBAGE_COLLECTED_MIXIN(PresentationConnection); | 35 USING_GARBAGE_COLLECTED_MIXIN(PresentationConnection); |
| 33 DEFINE_WRAPPERTYPEINFO(); | 36 DEFINE_WRAPPERTYPEINFO(); |
| 34 | 37 |
| 35 public: | 38 public: |
| 36 // For CallbackPromiseAdapter. | 39 // For CallbackPromiseAdapter. |
| 37 using WebType = std::unique_ptr<WebPresentationConnectionClient>; | 40 using WebType = std::unique_ptr<WebPresentationConnectionClient>; |
| 38 | 41 |
| 39 static PresentationConnection* take( | 42 static PresentationConnection* take( |
| 40 ScriptPromiseResolver*, | 43 ScriptPromiseResolver*, |
| 41 std::unique_ptr<WebPresentationConnectionClient>, | 44 std::unique_ptr<WebPresentationConnectionClient>, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Returns true if and only if the WebPresentationConnectionClient represents
this connection. | 79 // Returns true if and only if the WebPresentationConnectionClient represents
this connection. |
| 77 bool matches(WebPresentationConnectionClient*) const; | 80 bool matches(WebPresentationConnectionClient*) const; |
| 78 | 81 |
| 79 // Notifies the connection about its state change. | 82 // Notifies the connection about its state change. |
| 80 void didChangeState(WebPresentationConnectionState); | 83 void didChangeState(WebPresentationConnectionState); |
| 81 | 84 |
| 82 // Notifies the connection about its state change to 'closed'. | 85 // Notifies the connection about its state change to 'closed'. |
| 83 void didClose(WebPresentationConnectionCloseReason, const String& message); | 86 void didClose(WebPresentationConnectionCloseReason, const String& message); |
| 84 | 87 |
| 85 // Notifies the presentation about new message. | 88 // Notifies the presentation about new message. |
| 86 void didReceiveTextMessage(const String& message); | 89 void didReceiveTextMessage(const WebString& message) override; |
| 87 void didReceiveBinaryMessage(const uint8_t* data, size_t length); | 90 void didReceiveBinaryMessage(const uint8_t* data, size_t length) override; |
| 88 | 91 |
| 89 protected: | 92 protected: |
| 90 // EventTarget implementation. | 93 // EventTarget implementation. |
| 91 void addedEventListener(const AtomicString& eventType, | 94 void addedEventListener(const AtomicString& eventType, |
| 92 RegisteredEventListener&) override; | 95 RegisteredEventListener&) override; |
| 93 | 96 |
| 94 private: | 97 private: |
| 95 class BlobLoader; | 98 class BlobLoader; |
| 96 | 99 |
| 97 enum MessageType { | 100 enum MessageType { |
| 98 MessageTypeText, | 101 MessageTypeText, |
| 99 MessageTypeArrayBuffer, | 102 MessageTypeArrayBuffer, |
| 100 MessageTypeBlob, | 103 MessageTypeBlob, |
| 101 }; | 104 }; |
| 102 | 105 |
| 103 enum BinaryType { BinaryTypeBlob, BinaryTypeArrayBuffer }; | 106 enum BinaryType { BinaryTypeBlob, BinaryTypeArrayBuffer }; |
| 104 | 107 |
| 105 class Message; | 108 class Message; |
| 106 | 109 |
| 107 PresentationConnection(LocalFrame*, const String& id, const KURL&); | 110 PresentationConnection(LocalFrame*, |
| 111 const String& id, |
| 112 const KURL&, |
| 113 WebPresentationConnectionProxy*); |
| 108 | 114 |
| 109 bool canSendMessage(ExceptionState&); | 115 bool canSendMessage(ExceptionState&); |
| 110 void handleMessageQueue(); | 116 void handleMessageQueue(); |
| 111 | 117 |
| 112 // Callbacks invoked from BlobLoader. | 118 // Callbacks invoked from BlobLoader. |
| 113 void didFinishLoadingBlob(DOMArrayBuffer*); | 119 void didFinishLoadingBlob(DOMArrayBuffer*); |
| 114 void didFailLoadingBlob(FileError::ErrorCode); | 120 void didFailLoadingBlob(FileError::ErrorCode); |
| 115 | 121 |
| 116 // Cancel loads and pending messages when the connection is closed. | 122 // Cancel loads and pending messages when the connection is closed. |
| 117 void tearDown(); | 123 void tearDown(); |
| 118 | 124 |
| 119 String m_id; | 125 String m_id; |
| 120 KURL m_url; | 126 KURL m_url; |
| 121 WebPresentationConnectionState m_state; | 127 WebPresentationConnectionState m_state; |
| 122 | 128 |
| 123 // For Blob data handling. | 129 // For Blob data handling. |
| 124 Member<BlobLoader> m_blobLoader; | 130 Member<BlobLoader> m_blobLoader; |
| 125 HeapDeque<Member<Message>> m_messages; | 131 HeapDeque<Member<Message>> m_messages; |
| 126 | 132 |
| 127 BinaryType m_binaryType; | 133 BinaryType m_binaryType; |
| 134 |
| 135 std::unique_ptr<WebPresentationConnectionProxy> m_proxy; |
| 128 }; | 136 }; |
| 129 | 137 |
| 130 } // namespace blink | 138 } // namespace blink |
| 131 | 139 |
| 132 #endif // PresentationConnection_h | 140 #endif // PresentationConnection_h |
| OLD | NEW |