| 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 29 matching lines...) Expand all Loading... |
| 71 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 74 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
| 72 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 75 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
| 73 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); | 76 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); |
| 74 DEFINE_ATTRIBUTE_EVENT_LISTENER(terminate); | 77 DEFINE_ATTRIBUTE_EVENT_LISTENER(terminate); |
| 75 | 78 |
| 76 // Returns true if and only if the WebPresentationConnectionClient represents | 79 // Returns true if and only if the WebPresentationConnectionClient represents |
| 77 // this connection. | 80 // this connection. |
| 78 bool matches(WebPresentationConnectionClient*) const; | 81 bool matches(WebPresentationConnectionClient*) const; |
| 79 | 82 |
| 80 // Notifies the connection about its state change. | 83 // Notifies the connection about its state change. |
| 81 void didChangeState(WebPresentationConnectionState); | 84 void didChangeState(WebPresentationConnectionState) override; |
| 82 | 85 |
| 83 // Notifies the connection about its state change to 'closed'. | 86 // Notifies the connection about its state change to 'closed'. |
| 84 void didClose(WebPresentationConnectionCloseReason, const String& message); | 87 void didClose(WebPresentationConnectionCloseReason, const String& message); |
| 85 | 88 |
| 86 // Notifies the presentation about new message. | 89 // Notifies the presentation about new message. |
| 87 void didReceiveTextMessage(const String& message); | 90 void didReceiveTextMessage(const WebString& message) override; |
| 88 void didReceiveBinaryMessage(const uint8_t* data, size_t length); | 91 void didReceiveBinaryMessage(const uint8_t* data, size_t length) override; |
| 89 | 92 |
| 90 protected: | 93 protected: |
| 91 // EventTarget implementation. | 94 // EventTarget implementation. |
| 92 void addedEventListener(const AtomicString& eventType, | 95 void addedEventListener(const AtomicString& eventType, |
| 93 RegisteredEventListener&) override; | 96 RegisteredEventListener&) override; |
| 94 | 97 |
| 95 private: | 98 private: |
| 96 class BlobLoader; | 99 class BlobLoader; |
| 97 | 100 |
| 98 enum MessageType { | 101 enum MessageType { |
| 99 MessageTypeText, | 102 MessageTypeText, |
| 100 MessageTypeArrayBuffer, | 103 MessageTypeArrayBuffer, |
| 101 MessageTypeBlob, | 104 MessageTypeBlob, |
| 102 }; | 105 }; |
| 103 | 106 |
| 104 enum BinaryType { BinaryTypeBlob, BinaryTypeArrayBuffer }; | 107 enum BinaryType { BinaryTypeBlob, BinaryTypeArrayBuffer }; |
| 105 | 108 |
| 106 class Message; | 109 class Message; |
| 107 | 110 |
| 108 PresentationConnection(LocalFrame*, const String& id, const KURL&); | 111 PresentationConnection(LocalFrame*, const String& id, const KURL&); |
| 112 void SetPresentationConnectionProxy( |
| 113 std::unique_ptr<WebPresentationConnectionProxy>); |
| 109 | 114 |
| 110 bool canSendMessage(ExceptionState&); | 115 bool canSendMessage(ExceptionState&); |
| 111 void handleMessageQueue(); | 116 void handleMessageQueue(); |
| 112 | 117 |
| 113 // Callbacks invoked from BlobLoader. | 118 // Callbacks invoked from BlobLoader. |
| 114 void didFinishLoadingBlob(DOMArrayBuffer*); | 119 void didFinishLoadingBlob(DOMArrayBuffer*); |
| 115 void didFailLoadingBlob(FileError::ErrorCode); | 120 void didFailLoadingBlob(FileError::ErrorCode); |
| 116 | 121 |
| 117 // Cancel loads and pending messages when the connection is closed. | 122 // Cancel loads and pending messages when the connection is closed. |
| 118 void tearDown(); | 123 void tearDown(); |
| 119 | 124 |
| 120 String m_id; | 125 String m_id; |
| 121 KURL m_url; | 126 KURL m_url; |
| 122 WebPresentationConnectionState m_state; | 127 WebPresentationConnectionState m_state; |
| 123 | 128 |
| 124 // For Blob data handling. | 129 // For Blob data handling. |
| 125 Member<BlobLoader> m_blobLoader; | 130 Member<BlobLoader> m_blobLoader; |
| 126 HeapDeque<Member<Message>> m_messages; | 131 HeapDeque<Member<Message>> m_messages; |
| 127 | 132 |
| 128 BinaryType m_binaryType; | 133 BinaryType m_binaryType; |
| 134 |
| 135 std::unique_ptr<WebPresentationConnectionProxy> m_proxy; |
| 129 }; | 136 }; |
| 130 | 137 |
| 131 } // namespace blink | 138 } // namespace blink |
| 132 | 139 |
| 133 #endif // PresentationConnection_h | 140 #endif // PresentationConnection_h |
| OLD | NEW |