Chromium Code Reviews| 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" | |
| 10 #include "core/fileapi/FileError.h" | |
| 9 #include "core/frame/DOMWindowProperty.h" | 11 #include "core/frame/DOMWindowProperty.h" |
| 10 #include "public/platform/modules/presentation/WebPresentationSessionClient.h" | 12 #include "public/platform/modules/presentation/WebPresentationSessionClient.h" |
| 11 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
| 12 | 14 |
| 13 namespace WTF { | 15 namespace WTF { |
| 14 class AtomicString; | 16 class AtomicString; |
| 15 } // namespace WTF | 17 } // namespace WTF |
| 16 | 18 |
| 17 namespace blink { | 19 namespace blink { |
| 18 | 20 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 37 virtual ExecutionContext* executionContext() const override; | 39 virtual ExecutionContext* executionContext() const override; |
| 38 | 40 |
| 39 DECLARE_VIRTUAL_TRACE(); | 41 DECLARE_VIRTUAL_TRACE(); |
| 40 | 42 |
| 41 const String id() const { return m_id; } | 43 const String id() const { return m_id; } |
| 42 const WTF::AtomicString& state() const; | 44 const WTF::AtomicString& state() const; |
| 43 | 45 |
| 44 void send(const String& message, ExceptionState&); | 46 void send(const String& message, ExceptionState&); |
| 45 void send(PassRefPtr<DOMArrayBuffer> data, ExceptionState&); | 47 void send(PassRefPtr<DOMArrayBuffer> data, ExceptionState&); |
| 46 void send(PassRefPtr<DOMArrayBufferView> data, ExceptionState&); | 48 void send(PassRefPtr<DOMArrayBufferView> data, ExceptionState&); |
| 49 void send(Blob* data, ExceptionState&); | |
| 47 void close(); | 50 void close(); |
| 48 | 51 |
| 49 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 52 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
| 50 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 53 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
| 51 | 54 |
| 52 // Returns true if and only if the WebPresentationSessionClient represents t his session. | 55 // Returns true if and only if the WebPresentationSessionClient represents t his session. |
| 53 bool matches(WebPresentationSessionClient*) const; | 56 bool matches(WebPresentationSessionClient*) const; |
| 54 | 57 |
| 55 // Notifies the session about its state change. | 58 // Notifies the session about its state change. |
| 56 void didChangeState(WebPresentationSessionState); | 59 void didChangeState(WebPresentationSessionState); |
| 57 | 60 |
| 58 // Notifies the session about new text message. | 61 // Notifies the session about new text message. |
| 59 void didReceiveTextMessage(const String& message); | 62 void didReceiveTextMessage(const String& message); |
| 60 | 63 |
| 61 private: | 64 private: |
| 65 class BlobLoader; | |
| 66 // Blob data items are queued and sent after loading asynchronously. | |
| 67 struct Message { | |
| 68 Message(PassRefPtr<BlobDataHandle> blobDataHandle) | |
| 69 : blobDataHandle(blobDataHandle) | |
| 70 { | |
| 71 } | |
| 72 | |
| 73 RefPtr<BlobDataHandle> blobDataHandle; | |
| 74 // TODO(s.singapati): Currently String and ArrayBuffer data is sent | |
|
mark a. foltz
2015/05/26 20:41:48
It looks like the way that WebSocket implements se
USE s.singapati at gmail.com
2015/05/27 19:37:51
Done. One difference is, this patch does not repla
| |
| 75 // immediately to the client, but Blob data is loaded as array buffer | |
| 76 // asynchrounously and then sent. This makes message sending order | |
| 77 // incorrect. | |
| 78 }; | |
| 79 | |
| 62 PresentationSession(LocalFrame*, const String& id, const String& url); | 80 PresentationSession(LocalFrame*, const String& id, const String& url); |
| 63 | 81 |
| 64 // Returns the |PresentationController| object associated with the frame | 82 // Returns the |PresentationController| object associated with the frame |
| 65 // |Presentation| corresponds to. Can return |nullptr| if the frame is | 83 // |Presentation| corresponds to. Can return |nullptr| if the frame is |
| 66 // detached from the document. | 84 // detached from the document. |
| 67 PresentationController* presentationController(); | 85 PresentationController* presentationController(); |
| 68 | 86 |
| 69 // Common send method for both ArrayBufferView and ArrayBuffer. | 87 // Common send method for both ArrayBufferView and ArrayBuffer. |
| 70 void sendInternal(const uint8_t* data, size_t, ExceptionState&); | 88 void sendInternal(const uint8_t* data, size_t, ExceptionState&); |
| 71 | 89 |
| 90 void handleMessageQueue(); | |
| 91 | |
| 92 // Callbacks invoked from BlobLoader. | |
| 93 void didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer>); | |
| 94 void didFailLoadingBlob(FileError::ErrorCode); | |
| 95 | |
| 72 String m_id; | 96 String m_id; |
| 73 String m_url; | 97 String m_url; |
| 74 WebPresentationSessionState m_state; | 98 WebPresentationSessionState m_state; |
| 99 | |
| 100 // For Blob data handling. | |
| 101 Member<BlobLoader> m_blobLoader; | |
| 102 Deque<OwnPtr<Message>> m_messages; | |
| 75 }; | 103 }; |
| 76 | 104 |
| 77 } // namespace blink | 105 } // namespace blink |
| 78 | 106 |
| 79 #endif // PresentationSession_h | 107 #endif // PresentationSession_h |
| OLD | NEW |