Changeset 104791 in webkit
- Timestamp:
- Jan 11, 2012 10:47:47 PM (12 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r104780 r104791 1 2012-01-11 Takashi Toyoshima <toyoshim@chromium.org> 2 3 Add WebArrayBuffer support in WebSocket to WebKit API. 4 https://bugs.webkit.org/show_bug.cgi?id=75080 5 6 Reviewed by Darin Fisher. 7 8 * public/WebSocket.h: Add interface to send WebArrayBuffer, and set and get receiving binary object type. 9 * public/WebSocketClient.h: Add interface to receive WebArrayBuffer. 10 (WebKit::WebSocketClient::didReceiveArrayBuffer): 11 * src/WebSocketImpl.cpp: Add various binary types handling. 12 (WebKit::WebSocketImpl::WebSocketImpl): 13 (WebKit::WebSocketImpl::binaryType): 14 (WebKit::WebSocketImpl::setBinaryType): 15 (WebKit::WebSocketImpl::sendArrayBuffer): 16 (WebKit::WebSocketImpl::didReceiveBinaryData): 17 * src/WebSocketImpl.h: Add methods to handle various binary types. 18 1 19 2012-01-11 Scott Violet <sky@google.com> 2 20 -
trunk/Source/WebKit/chromium/public/WebSocket.h
r101122 r104791 1 1 /* 2 * Copyright (C) 2011 Google Inc. All rights reserved.2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 39 39 namespace WebKit { 40 40 41 class WebArrayBuffer; 41 42 class WebData; 42 43 class WebDocument; … … 61 62 }; 62 63 64 // FIXME: Remove BinaryTypeData after a switchover to other types. 65 enum BinaryType { 66 BinaryTypeBlob = 0, 67 BinaryTypeArrayBuffer = 1, 68 BinaryTypeData = 2 // Don't use it 69 }; 70 63 71 WEBKIT_EXPORT static WebSocket* create(const WebDocument&, WebSocketClient*); 64 72 virtual ~WebSocket() { } 65 73 74 // These functions come from binaryType attribute of the WebSocket API 75 // specification. It specifies binary object type for receiving binary 76 // frames representation. Receiving text frames are always mapped to 77 // WebString type regardless of this attribute. 78 // Default type must be BinaryTypeBlob, but currently is BinaryTypeData 79 // for a switchover from WebData to WebArrayBuffer. 80 // See also, The WebSocket API - http://www.w3.org/TR/websockets/ . 81 virtual BinaryType binaryType() const = 0; 82 virtual bool setBinaryType(BinaryType) = 0; 83 66 84 virtual void connect(const WebURL&, const WebString& protocol) = 0; 67 85 virtual WebString subprotocol() = 0; 68 virtual bool sendText(const WebString& message) = 0; 69 virtual bool sendBinary(const WebData& binaryData) = 0; 86 virtual bool sendText(const WebString&) = 0; 87 virtual bool sendBinary(const WebData&) = 0; 88 virtual bool sendArrayBuffer(const WebArrayBuffer&) = 0; 70 89 virtual unsigned long bufferedAmount() const = 0; 71 90 virtual void close(int code, const WebString& reason) = 0; -
trunk/Source/WebKit/chromium/public/WebSocketClient.h
r101614 r104791 1 1 /* 2 * Copyright (C) 2011 Google Inc. All rights reserved.2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 namespace WebKit { 38 38 39 class WebArrayBuffer; 39 40 class WebString; 40 41 … … 50 51 virtual void didReceiveMessage(const WebString& message) { } 51 52 virtual void didReceiveBinaryData(const WebData& binaryData) { } 53 virtual void didReceiveArrayBuffer(const WebArrayBuffer& arrayBuffer) { } 52 54 virtual void didReceiveMessageError() { } 53 55 virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) { } -
trunk/Source/WebKit/chromium/src/WebSocketImpl.cpp
r102044 r104791 1 1 /* 2 * Copyright (C) 2011 Google Inc. All rights reserved.2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 #include "WebSocketImpl.h" 33 33 34 #include "ArrayBuffer.h" 34 35 #include "Document.h" 35 36 #include "KURL.h" … … 44 45 #endif 45 46 46 #include " platform/WebData.h"47 #include "WebArrayBuffer.h" 47 48 #include "WebDocument.h" 48 49 #include "WebSocketClient.h" 50 #include "platform/WebData.h" 49 51 #include "platform/WebString.h" 50 52 #include "platform/WebURL.h" … … 54 56 namespace WebKit { 55 57 58 // FIXME: Default m_binaryType must be Blob after supporting WebBlob. 56 59 WebSocketImpl::WebSocketImpl(const WebDocument& document, WebSocketClient* client) 57 60 : m_client(client) 61 , m_binaryType(BinaryTypeData) 58 62 { 59 63 #if ENABLE(WEB_SOCKETS) … … 73 77 } 74 78 79 WebSocket::BinaryType WebSocketImpl::binaryType() const 80 { 81 return m_binaryType; 82 } 83 84 bool WebSocketImpl::setBinaryType(BinaryType binaryType) 85 { 86 if (binaryType > BinaryTypeArrayBuffer) 87 return false; 88 m_binaryType = binaryType; 89 return true; 90 } 91 75 92 void WebSocketImpl::connect(const WebURL& url, const WebString& protocol) 76 93 { … … 104 121 #if ENABLE(WEB_SOCKETS) 105 122 return m_private->send(binaryData.data(), binaryData.size()); 123 #else 124 ASSERT_NOT_REACHED(); 125 #endif 126 } 127 128 bool WebSocketImpl::sendArrayBuffer(const WebArrayBuffer& webArrayBuffer) 129 { 130 #if ENABLE(WEB_SOCKETS) 131 return m_private->send(*PassRefPtr<ArrayBuffer>(webArrayBuffer)); 106 132 #else 107 133 ASSERT_NOT_REACHED(); … … 167 193 { 168 194 #if ENABLE(WEB_SOCKETS) 169 m_client->didReceiveBinaryData(WebData(binaryData->data(), binaryData->size())); 195 switch (m_binaryType) { 196 case BinaryTypeData: 197 case BinaryTypeBlob: // FIXME: Handle Blob after supporting WebBlob. 198 m_client->didReceiveBinaryData(WebData(binaryData->data(), binaryData->size())); 199 break; 200 case BinaryTypeArrayBuffer: 201 m_client->didReceiveArrayBuffer(WebArrayBuffer(ArrayBuffer::create(binaryData->data(), binaryData->size()))); 202 break; 203 } 170 204 #else 171 205 ASSERT_NOT_REACHED(); -
trunk/Source/WebKit/chromium/src/WebSocketImpl.h
r102044 r104791 1 1 /* 2 * Copyright (C) 2011 Google Inc. All rights reserved.2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 55 55 bool isNull() const { return !m_private; } 56 56 57 BinaryType binaryType() const; 58 virtual bool setBinaryType(BinaryType); 57 59 virtual void connect(const WebURL&, const WebString& protocol); 58 60 virtual WebString subprotocol(); 59 virtual bool sendText(const WebString& message); 60 virtual bool sendBinary(const WebData& binaryData); 61 virtual bool sendText(const WebString&); 62 // FIXME: Remove sendBinary() after a switchover to other types. 63 virtual bool sendBinary(const WebData&); 64 virtual bool sendArrayBuffer(const WebArrayBuffer&); 61 65 virtual unsigned long bufferedAmount() const; 62 66 virtual void close(int code, const WebString& reason); … … 76 80 RefPtr<WebCore::WebSocketChannel> m_private; 77 81 WebSocketClient* m_client; 82 BinaryType m_binaryType; 78 83 }; 79 84
Note: See TracChangeset
for help on using the changeset viewer.