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

Side by Side Diff: trunk/Source/web/WebSocketImpl.cpp

Issue 338243006: Revert 176298 "[WebSocket] bufferedAmount should not decrease in..." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/Source/web/WebSocketImpl.h ('k') | trunk/public/web/WebSocketClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/frame/ConsoleTypes.h" 36 #include "core/frame/ConsoleTypes.h"
37 #include "modules/websockets/MainThreadWebSocketChannel.h" 37 #include "modules/websockets/MainThreadWebSocketChannel.h"
38 #include "modules/websockets/NewWebSocketChannelImpl.h" 38 #include "modules/websockets/NewWebSocketChannelImpl.h"
39 #include "modules/websockets/WebSocketChannel.h" 39 #include "modules/websockets/WebSocketChannel.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 "wtf/ArrayBuffer.h" 44 #include "wtf/ArrayBuffer.h"
45 #include "wtf/text/CString.h"
46 #include "wtf/text/WTFString.h" 45 #include "wtf/text/WTFString.h"
47 46
48 using namespace WebCore; 47 using namespace WebCore;
49 48
50 namespace blink { 49 namespace blink {
51 50
52 WebSocketImpl::WebSocketImpl(const WebDocument& document, WebSocketClient* clien t) 51 WebSocketImpl::WebSocketImpl(const WebDocument& document, WebSocketClient* clien t)
53 : m_client(client) 52 : m_client(client)
54 , m_binaryType(BinaryTypeBlob) 53 , m_binaryType(BinaryTypeBlob)
55 , m_bufferedAmount(0)
56 { 54 {
57 RefPtrWillBeRawPtr<Document> coreDocument = PassRefPtrWillBeRawPtr<Document> (document); 55 RefPtrWillBeRawPtr<Document> coreDocument = PassRefPtrWillBeRawPtr<Document> (document);
58 if (RuntimeEnabledFeatures::experimentalWebSocketEnabled()) { 56 if (RuntimeEnabledFeatures::experimentalWebSocketEnabled()) {
59 m_private = NewWebSocketChannelImpl::create(coreDocument.get(), this); 57 m_private = NewWebSocketChannelImpl::create(coreDocument.get(), this);
60 } else { 58 } else {
61 m_private = MainThreadWebSocketChannel::create(coreDocument.get(), this) ; 59 m_private = MainThreadWebSocketChannel::create(coreDocument.get(), this) ;
62 } 60 }
63 } 61 }
64 62
65 WebSocketImpl::~WebSocketImpl() 63 WebSocketImpl::~WebSocketImpl()
(...skipping 24 matching lines...) Expand all
90 return m_subprotocol; 88 return m_subprotocol;
91 } 89 }
92 90
93 WebString WebSocketImpl::extensions() 91 WebString WebSocketImpl::extensions()
94 { 92 {
95 return m_extensions; 93 return m_extensions;
96 } 94 }
97 95
98 bool WebSocketImpl::sendText(const WebString& message) 96 bool WebSocketImpl::sendText(const WebString& message)
99 { 97 {
100 m_bufferedAmount += message.utf8().length();
101 return m_private->send(message) == WebSocketChannel::SendSuccess; 98 return m_private->send(message) == WebSocketChannel::SendSuccess;
102 } 99 }
103 100
104 bool WebSocketImpl::sendArrayBuffer(const WebArrayBuffer& webArrayBuffer) 101 bool WebSocketImpl::sendArrayBuffer(const WebArrayBuffer& webArrayBuffer)
105 { 102 {
106 m_bufferedAmount += webArrayBuffer.byteLength();
107 return m_private->send(*PassRefPtr<ArrayBuffer>(webArrayBuffer), 0, webArray Buffer.byteLength()) == WebSocketChannel::SendSuccess; 103 return m_private->send(*PassRefPtr<ArrayBuffer>(webArrayBuffer), 0, webArray Buffer.byteLength()) == WebSocketChannel::SendSuccess;
108 } 104 }
109 105
110 unsigned long WebSocketImpl::bufferedAmount() const 106 unsigned long WebSocketImpl::bufferedAmount() const
111 { 107 {
112 return m_bufferedAmount; 108 return m_private->bufferedAmount();
113 } 109 }
114 110
115 void WebSocketImpl::close(int code, const WebString& reason) 111 void WebSocketImpl::close(int code, const WebString& reason)
116 { 112 {
117 m_private->close(code, reason); 113 m_private->close(code, reason);
118 } 114 }
119 115
120 void WebSocketImpl::fail(const WebString& reason) 116 void WebSocketImpl::fail(const WebString& reason)
121 { 117 {
122 m_private->fail(reason, ErrorMessageLevel, String(), 0); 118 m_private->fail(reason, ErrorMessageLevel, String(), 0);
(...skipping 27 matching lines...) Expand all
150 m_client->didReceiveArrayBuffer(WebArrayBuffer(ArrayBuffer::create(binar yData->data(), binaryData->size()))); 146 m_client->didReceiveArrayBuffer(WebArrayBuffer(ArrayBuffer::create(binar yData->data(), binaryData->size())));
151 break; 147 break;
152 } 148 }
153 } 149 }
154 150
155 void WebSocketImpl::didReceiveMessageError() 151 void WebSocketImpl::didReceiveMessageError()
156 { 152 {
157 m_client->didReceiveMessageError(); 153 m_client->didReceiveMessageError();
158 } 154 }
159 155
160 void WebSocketImpl::didConsumeBufferedAmount(unsigned long consumed) 156 void WebSocketImpl::didUpdateBufferedAmount(unsigned long bufferedAmount)
161 { 157 {
162 m_bufferedAmount -= consumed; 158 m_client->didUpdateBufferedAmount(bufferedAmount);
163 } 159 }
164 160
165 void WebSocketImpl::didStartClosingHandshake() 161 void WebSocketImpl::didStartClosingHandshake()
166 { 162 {
167 m_client->didStartClosingHandshake(); 163 m_client->didStartClosingHandshake();
168 } 164 }
169 165
170 void WebSocketImpl::didClose(ClosingHandshakeCompletionStatus status, unsigned s hort code, const String& reason) 166 void WebSocketImpl::didClose(unsigned long bufferedAmount, ClosingHandshakeCompl etionStatus status, unsigned short code, const String& reason)
171 { 167 {
172 m_client->didClose(m_bufferedAmount, static_cast<WebSocketClient::ClosingHan dshakeCompletionStatus>(status), code, WebString(reason)); 168 m_client->didClose(bufferedAmount, static_cast<WebSocketClient::ClosingHands hakeCompletionStatus>(status), code, WebString(reason));
173 } 169 }
174 170
175 } // namespace blink 171 } // namespace blink
OLDNEW
« no previous file with comments | « trunk/Source/web/WebSocketImpl.h ('k') | trunk/public/web/WebSocketClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698