Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1036)

Unified Diff: Source/modules/presentation/PresentationSession.h

Issue 1131463006: [PresentationAPI] Plumbing send(Blob) from PresentationSession IDL to platform/. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/presentation/PresentationSession.h
diff --git a/Source/modules/presentation/PresentationSession.h b/Source/modules/presentation/PresentationSession.h
index 378995d434d77e45b804057c0fda35fbafcf9afd..fb9baff88b27c9789b9c0d18bbdb5c8c9c6ebf27 100644
--- a/Source/modules/presentation/PresentationSession.h
+++ b/Source/modules/presentation/PresentationSession.h
@@ -6,7 +6,10 @@
#define PresentationSession_h
#include "core/events/EventTarget.h"
+#include "core/fileapi/Blob.h"
+#include "core/fileapi/FileError.h"
#include "core/frame/DOMWindowProperty.h"
+#include "platform/heap/Handle.h"
#include "public/platform/modules/presentation/WebPresentationSessionClient.h"
#include "wtf/text/WTFString.h"
@@ -42,8 +45,9 @@ public:
const WTF::AtomicString& state() const;
void send(const String& message, ExceptionState&);
- void send(PassRefPtr<DOMArrayBuffer> data, ExceptionState&);
- void send(PassRefPtr<DOMArrayBufferView> data, ExceptionState&);
+ void send(PassRefPtr<DOMArrayBuffer>, ExceptionState&);
+ void send(PassRefPtr<DOMArrayBufferView>, ExceptionState&);
+ void send(Blob*, ExceptionState&);
void close();
DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
@@ -59,6 +63,33 @@ public:
void didReceiveTextMessage(const String& message);
private:
+ class BlobLoader;
+
+ enum MessageType {
+ MessageTypeText,
+ MessageTypeArrayBuffer,
+ MessageTypeBlob,
+ };
+
+ struct Message {
+ Message(const String& text)
+ : type(MessageTypeText)
+ , text(text) { }
+
+ Message(PassRefPtr<DOMArrayBuffer> arrayBuffer)
+ : type(MessageTypeArrayBuffer)
+ , arrayBuffer(arrayBuffer) { }
+
+ Message(PassRefPtr<BlobDataHandle> blobDataHandle)
+ : type(MessageTypeBlob)
+ , blobDataHandle(blobDataHandle) { }
+
+ MessageType type;
+ String text;
+ RefPtr<DOMArrayBuffer> arrayBuffer;
+ RefPtr<BlobDataHandle> blobDataHandle;
+ };
+
PresentationSession(LocalFrame*, const String& id, const String& url);
// Returns the |PresentationController| object associated with the frame
@@ -66,12 +97,20 @@ private:
// detached from the document.
PresentationController* presentationController();
- // Common send method for both ArrayBufferView and ArrayBuffer.
- void sendInternal(const uint8_t* data, size_t, ExceptionState&);
+ bool canSendMessage(ExceptionState&);
+ void handleMessageQueue();
+
+ // Callbacks invoked from BlobLoader.
+ void didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer>);
+ void didFailLoadingBlob(FileError::ErrorCode);
String m_id;
String m_url;
WebPresentationSessionState m_state;
+
+ // For Blob data handling.
+ Member<BlobLoader> m_blobLoader;
+ Deque<OwnPtr<Message>> m_messages;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698