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) | 71 #if !ENABLE(OILPAN) |
yhirano
2014/08/04 01:05:53
WebSocketImpl is not on heap any more, so we can r
haraken
2014/08/04 01:21:57
Done.
| |
70 m_private->disconnect(); | 72 m_private->disconnect(); |
71 #endif | 73 #endif |
72 } | 74 } |
73 | 75 |
74 WebSocket::BinaryType WebSocketImpl::binaryType() const | 76 WebSocket::BinaryType WebSocketImpl::binaryType() const |
75 { | 77 { |
76 return m_binaryType; | 78 return m_binaryType; |
77 } | 79 } |
78 | 80 |
79 bool WebSocketImpl::setBinaryType(BinaryType binaryType) | 81 bool WebSocketImpl::setBinaryType(BinaryType binaryType) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 // FIXME: Deprecate the following statements. | 196 // FIXME: Deprecate the following statements. |
195 m_bufferedAmount -= consumed; | 197 m_bufferedAmount -= consumed; |
196 m_client->didUpdateBufferedAmount(m_bufferedAmount); | 198 m_client->didUpdateBufferedAmount(m_bufferedAmount); |
197 } | 199 } |
198 | 200 |
199 void WebSocketImpl::didStartClosingHandshake() | 201 void WebSocketImpl::didStartClosingHandshake() |
200 { | 202 { |
201 m_client->didStartClosingHandshake(); | 203 m_client->didStartClosingHandshake(); |
202 } | 204 } |
203 | 205 |
204 void WebSocketImpl::didClose(ClosingHandshakeCompletionStatus status, unsigned s hort code, const String& reason) | 206 void WebSocketImpl::didClose(WebSocketChannelClient::ClosingHandshakeCompletionS tatus status, unsigned short code, const String& reason) |
205 { | 207 { |
206 m_isClosingOrClosed = true; | 208 m_isClosingOrClosed = true; |
207 m_client->didClose(static_cast<WebSocketClient::ClosingHandshakeCompletionSt atus>(status), code, WebString(reason)); | 209 m_client->didClose(static_cast<WebSocketClient::ClosingHandshakeCompletionSt atus>(status), code, WebString(reason)); |
208 | 210 |
209 // FIXME: Deprecate this call. | 211 // FIXME: Deprecate this call. |
210 m_client->didClose(m_bufferedAmount - m_bufferedAmountAfterClose, static_cas t<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(re ason)); | 212 m_client->didClose(m_bufferedAmount - m_bufferedAmountAfterClose, static_cas t<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(re ason)); |
211 } | 213 } |
212 | 214 |
213 void WebSocketImpl::trace(blink::Visitor* visitor) | |
214 { | |
215 visitor->trace(m_private); | |
216 blink::WebSocketChannelClient::trace(visitor); | |
217 } | |
218 | |
219 } // namespace blink | 215 } // namespace blink |
OLD | NEW |