| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 35 #include "core/frame/ConsoleTypes.h" | 35 #include "core/frame/ConsoleTypes.h" |
| 36 #include "modules/websockets/MainThreadWebSocketChannel.h" | 36 #include "modules/websockets/MainThreadWebSocketChannel.h" |
| 37 #include "modules/websockets/NewWebSocketChannelImpl.h" | 37 #include "modules/websockets/NewWebSocketChannelImpl.h" |
| 38 #include "modules/websockets/WebSocketChannel.h" | 38 #include "modules/websockets/WebSocketChannel.h" |
| 39 #include "platform/RuntimeEnabledFeatures.h" | 39 #include "platform/RuntimeEnabledFeatures.h" |
| 40 #include "public/platform/WebArrayBuffer.h" | 40 #include "public/platform/WebArrayBuffer.h" |
| 41 #include "public/platform/WebString.h" | 41 #include "public/platform/WebString.h" |
| 42 #include "public/platform/WebURL.h" | 42 #include "public/platform/WebURL.h" |
| 43 #include "public/web/WebDocument.h" | 43 #include "public/web/WebDocument.h" |
| 44 #include "web/WebSocketChannelClientProxy.h" |
| 44 #include "wtf/ArrayBuffer.h" | 45 #include "wtf/ArrayBuffer.h" |
| 45 #include "wtf/text/CString.h" | 46 #include "wtf/text/CString.h" |
| 46 #include "wtf/text/WTFString.h" | 47 #include "wtf/text/WTFString.h" |
| 47 | 48 |
| 48 using namespace blink; | 49 using namespace blink; |
| 49 | 50 |
| 50 namespace blink { | 51 namespace blink { |
| 51 | 52 |
| 52 WebSocketImpl::WebSocketImpl(const WebDocument& document, WebSocketClient* clien
t) | 53 WebSocketImpl::WebSocketImpl(const WebDocument& document, WebSocketClient* clien
t) |
| 53 : m_client(client) | 54 : m_client(client) |
| 55 , m_channelProxy(WebSocketChannelClientProxy::create(this)) |
| 54 , m_binaryType(BinaryTypeBlob) | 56 , m_binaryType(BinaryTypeBlob) |
| 55 , m_isClosingOrClosed(false) | 57 , m_isClosingOrClosed(false) |
| 56 , m_bufferedAmount(0) | 58 , m_bufferedAmount(0) |
| 57 , m_bufferedAmountAfterClose(0) | 59 , m_bufferedAmountAfterClose(0) |
| 58 { | 60 { |
| 59 RefPtrWillBeRawPtr<Document> coreDocument = PassRefPtrWillBeRawPtr<Document>
(document); | 61 RefPtrWillBeRawPtr<Document> coreDocument = PassRefPtrWillBeRawPtr<Document>
(document); |
| 60 if (RuntimeEnabledFeatures::experimentalWebSocketEnabled()) { | 62 if (RuntimeEnabledFeatures::experimentalWebSocketEnabled()) { |
| 61 m_private = NewWebSocketChannelImpl::create(coreDocument.get(), this); | 63 m_private = NewWebSocketChannelImpl::create(coreDocument.get(), m_channe
lProxy.get()); |
| 62 } else { | 64 } else { |
| 63 m_private = MainThreadWebSocketChannel::create(coreDocument.get(), this)
; | 65 m_private = MainThreadWebSocketChannel::create(coreDocument.get(), m_cha
nnelProxy.get()); |
| 64 } | 66 } |
| 65 } | 67 } |
| 66 | 68 |
| 67 WebSocketImpl::~WebSocketImpl() | 69 WebSocketImpl::~WebSocketImpl() |
| 68 { | 70 { |
| 69 #if !ENABLE(OILPAN) | |
| 70 m_private->disconnect(); | 71 m_private->disconnect(); |
| 71 #endif | |
| 72 } | 72 } |
| 73 | 73 |
| 74 WebSocket::BinaryType WebSocketImpl::binaryType() const | 74 WebSocket::BinaryType WebSocketImpl::binaryType() const |
| 75 { | 75 { |
| 76 return m_binaryType; | 76 return m_binaryType; |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool WebSocketImpl::setBinaryType(BinaryType binaryType) | 79 bool WebSocketImpl::setBinaryType(BinaryType binaryType) |
| 80 { | 80 { |
| 81 if (binaryType > BinaryTypeArrayBuffer) | 81 if (binaryType > BinaryTypeArrayBuffer) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // FIXME: Deprecate the following statements. | 194 // FIXME: Deprecate the following statements. |
| 195 m_bufferedAmount -= consumed; | 195 m_bufferedAmount -= consumed; |
| 196 m_client->didUpdateBufferedAmount(m_bufferedAmount); | 196 m_client->didUpdateBufferedAmount(m_bufferedAmount); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void WebSocketImpl::didStartClosingHandshake() | 199 void WebSocketImpl::didStartClosingHandshake() |
| 200 { | 200 { |
| 201 m_client->didStartClosingHandshake(); | 201 m_client->didStartClosingHandshake(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void WebSocketImpl::didClose(ClosingHandshakeCompletionStatus status, unsigned s
hort code, const String& reason) | 204 void WebSocketImpl::didClose(WebSocketChannelClient::ClosingHandshakeCompletionS
tatus status, unsigned short code, const String& reason) |
| 205 { | 205 { |
| 206 m_isClosingOrClosed = true; | 206 m_isClosingOrClosed = true; |
| 207 m_client->didClose(static_cast<WebSocketClient::ClosingHandshakeCompletionSt
atus>(status), code, WebString(reason)); | 207 m_client->didClose(static_cast<WebSocketClient::ClosingHandshakeCompletionSt
atus>(status), code, WebString(reason)); |
| 208 | 208 |
| 209 // FIXME: Deprecate this call. | 209 // FIXME: Deprecate this call. |
| 210 m_client->didClose(m_bufferedAmount - m_bufferedAmountAfterClose, static_cas
t<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(re
ason)); | 210 m_client->didClose(m_bufferedAmount - m_bufferedAmountAfterClose, static_cas
t<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(re
ason)); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void WebSocketImpl::trace(blink::Visitor* visitor) | |
| 214 { | |
| 215 visitor->trace(m_private); | |
| 216 blink::WebSocketChannelClient::trace(visitor); | |
| 217 } | |
| 218 | |
| 219 } // namespace blink | 213 } // namespace blink |
| OLD | NEW |