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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // EventTarget implementation. | 42 // EventTarget implementation. |
43 const AtomicString& interfaceName() const override; | 43 const AtomicString& interfaceName() const override; |
44 ExecutionContext* getExecutionContext() const override; | 44 ExecutionContext* getExecutionContext() const override; |
45 | 45 |
46 DECLARE_VIRTUAL_TRACE(); | 46 DECLARE_VIRTUAL_TRACE(); |
47 | 47 |
48 const String& id() const { return m_id; } | 48 const String& id() const { return m_id; } |
49 const WTF::AtomicString& state() const; | 49 const WTF::AtomicString& state() const; |
50 | 50 |
51 void send(const String& message, ExceptionState&); | 51 void send(const String& message, ExceptionState&); |
52 void send(DOMArrayBuffer*, ExceptionState&); | 52 void send(PassRefPtr<DOMArrayBuffer>, ExceptionState&); |
53 void send(DOMArrayBufferView*, ExceptionState&); | 53 void send(PassRefPtr<DOMArrayBufferView>, ExceptionState&); |
54 void send(Blob*, ExceptionState&); | 54 void send(Blob*, ExceptionState&); |
55 void close(); | 55 void close(); |
56 void terminate(); | 56 void terminate(); |
57 | 57 |
58 String binaryType() const; | 58 String binaryType() const; |
59 void setBinaryType(const String&); | 59 void setBinaryType(const String&); |
60 | 60 |
61 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 61 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
62 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 62 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
63 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 63 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
(...skipping 24 matching lines...) Expand all Loading... |
88 MessageTypeText, | 88 MessageTypeText, |
89 MessageTypeArrayBuffer, | 89 MessageTypeArrayBuffer, |
90 MessageTypeBlob, | 90 MessageTypeBlob, |
91 }; | 91 }; |
92 | 92 |
93 enum BinaryType { | 93 enum BinaryType { |
94 BinaryTypeBlob, | 94 BinaryTypeBlob, |
95 BinaryTypeArrayBuffer | 95 BinaryTypeArrayBuffer |
96 }; | 96 }; |
97 | 97 |
98 class Message; | 98 struct Message { |
| 99 Message(const String& text) |
| 100 : type(MessageTypeText) |
| 101 , text(text) { } |
| 102 |
| 103 Message(PassRefPtr<DOMArrayBuffer> arrayBuffer) |
| 104 : type(MessageTypeArrayBuffer) |
| 105 , arrayBuffer(arrayBuffer) { } |
| 106 |
| 107 Message(PassRefPtr<BlobDataHandle> blobDataHandle) |
| 108 : type(MessageTypeBlob) |
| 109 , blobDataHandle(blobDataHandle) { } |
| 110 |
| 111 MessageType type; |
| 112 String text; |
| 113 RefPtr<DOMArrayBuffer> arrayBuffer; |
| 114 RefPtr<BlobDataHandle> blobDataHandle; |
| 115 }; |
99 | 116 |
100 PresentationConnection(LocalFrame*, const String& id, const String& url); | 117 PresentationConnection(LocalFrame*, const String& id, const String& url); |
101 | 118 |
102 bool canSendMessage(ExceptionState&); | 119 bool canSendMessage(ExceptionState&); |
103 void handleMessageQueue(); | 120 void handleMessageQueue(); |
104 | 121 |
105 // Callbacks invoked from BlobLoader. | 122 // Callbacks invoked from BlobLoader. |
106 void didFinishLoadingBlob(DOMArrayBuffer*); | 123 void didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer>); |
107 void didFailLoadingBlob(FileError::ErrorCode); | 124 void didFailLoadingBlob(FileError::ErrorCode); |
108 | 125 |
109 // Cancel loads and pending messages when the connection is closed. | 126 // Cancel loads and pending messages when the connection is closed. |
110 void tearDown(); | 127 void tearDown(); |
111 | 128 |
112 String m_id; | 129 String m_id; |
113 String m_url; | 130 String m_url; |
114 WebPresentationConnectionState m_state; | 131 WebPresentationConnectionState m_state; |
115 | 132 |
116 // For Blob data handling. | 133 // For Blob data handling. |
117 Member<BlobLoader> m_blobLoader; | 134 Member<BlobLoader> m_blobLoader; |
118 HeapDeque<Member<Message>> m_messages; | 135 Deque<OwnPtr<Message>> m_messages; |
119 | 136 |
120 BinaryType m_binaryType; | 137 BinaryType m_binaryType; |
121 }; | 138 }; |
122 | 139 |
123 } // namespace blink | 140 } // namespace blink |
124 | 141 |
125 #endif // PresentationConnection_h | 142 #endif // PresentationConnection_h |
OLD | NEW |