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 PresentationSession_h | 5 #ifndef PresentationSession_h |
6 #define PresentationSession_h | 6 #define PresentationSession_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 | 42 |
43 const String id() const { return m_id; } | 43 const String id() const { return m_id; } |
44 const WTF::AtomicString& state() const; | 44 const WTF::AtomicString& state() const; |
45 | 45 |
46 void send(const String& message, ExceptionState&); | 46 void send(const String& message, ExceptionState&); |
47 void send(PassRefPtr<DOMArrayBuffer>, ExceptionState&); | 47 void send(PassRefPtr<DOMArrayBuffer>, ExceptionState&); |
48 void send(PassRefPtr<DOMArrayBufferView>, ExceptionState&); | 48 void send(PassRefPtr<DOMArrayBufferView>, ExceptionState&); |
49 void send(Blob*, ExceptionState&); | 49 void send(Blob*, ExceptionState&); |
50 void close(); | 50 void close(); |
51 | 51 |
| 52 String binaryType() const; |
| 53 void setBinaryType(const String&); |
| 54 |
52 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 55 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
53 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 56 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
54 | 57 |
55 // Returns true if and only if the WebPresentationSessionClient represents t
his session. | 58 // Returns true if and only if the WebPresentationSessionClient represents t
his session. |
56 bool matches(WebPresentationSessionClient*) const; | 59 bool matches(WebPresentationSessionClient*) const; |
57 | 60 |
58 // Notifies the session about its state change. | 61 // Notifies the session about its state change. |
59 void didChangeState(WebPresentationSessionState); | 62 void didChangeState(WebPresentationSessionState); |
60 | 63 |
61 // Notifies the session about new text message. | 64 // Notifies the session about new message. |
62 void didReceiveTextMessage(const String& message); | 65 void didReceiveTextMessage(const String& message); |
| 66 void didReceiveBinaryMessage(const uint8_t* data, size_t length); |
63 | 67 |
64 private: | 68 private: |
65 class BlobLoader; | 69 class BlobLoader; |
66 | 70 |
67 enum MessageType { | 71 enum MessageType { |
68 MessageTypeText, | 72 MessageTypeText, |
69 MessageTypeArrayBuffer, | 73 MessageTypeArrayBuffer, |
70 MessageTypeBlob, | 74 MessageTypeBlob, |
71 }; | 75 }; |
72 | 76 |
| 77 enum BinaryType { |
| 78 BinaryTypeBlob, |
| 79 BinaryTypeArrayBuffer |
| 80 }; |
| 81 |
73 struct Message { | 82 struct Message { |
74 Message(const String& text) | 83 Message(const String& text) |
75 : type(MessageTypeText) | 84 : type(MessageTypeText) |
76 , text(text) { } | 85 , text(text) { } |
77 | 86 |
78 Message(PassRefPtr<DOMArrayBuffer> arrayBuffer) | 87 Message(PassRefPtr<DOMArrayBuffer> arrayBuffer) |
79 : type(MessageTypeArrayBuffer) | 88 : type(MessageTypeArrayBuffer) |
80 , arrayBuffer(arrayBuffer) { } | 89 , arrayBuffer(arrayBuffer) { } |
81 | 90 |
82 Message(PassRefPtr<BlobDataHandle> blobDataHandle) | 91 Message(PassRefPtr<BlobDataHandle> blobDataHandle) |
(...skipping 15 matching lines...) Expand all Loading... |
98 void didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer>); | 107 void didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer>); |
99 void didFailLoadingBlob(FileError::ErrorCode); | 108 void didFailLoadingBlob(FileError::ErrorCode); |
100 | 109 |
101 String m_id; | 110 String m_id; |
102 String m_url; | 111 String m_url; |
103 WebPresentationSessionState m_state; | 112 WebPresentationSessionState m_state; |
104 | 113 |
105 // For Blob data handling. | 114 // For Blob data handling. |
106 Member<BlobLoader> m_blobLoader; | 115 Member<BlobLoader> m_blobLoader; |
107 Deque<OwnPtr<Message>> m_messages; | 116 Deque<OwnPtr<Message>> m_messages; |
| 117 |
| 118 BinaryType m_binaryType; |
108 }; | 119 }; |
109 | 120 |
110 } // namespace blink | 121 } // namespace blink |
111 | 122 |
112 #endif // PresentationSession_h | 123 #endif // PresentationSession_h |
OLD | NEW |