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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp

Issue 2743023002: Migrate WTF::Deque::append() to ::push_back() (Closed)
Patch Set: rebase Created 3 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return true; 228 return true;
229 } 229 }
230 230
231 void DocumentWebSocketChannel::send(const CString& message) { 231 void DocumentWebSocketChannel::send(const CString& message) {
232 NETWORK_DVLOG(1) << this << " sendText(" << message << ")"; 232 NETWORK_DVLOG(1) << this << " sendText(" << message << ")";
233 // FIXME: Change the inspector API to show the entire message instead 233 // FIXME: Change the inspector API to show the entire message instead
234 // of individual frames. 234 // of individual frames.
235 probe::didSendWebSocketFrame(document(), m_identifier, 235 probe::didSendWebSocketFrame(document(), m_identifier,
236 WebSocketFrame::OpCodeText, true, message.data(), 236 WebSocketFrame::OpCodeText, true, message.data(),
237 message.length()); 237 message.length());
238 m_messages.append(new Message(message)); 238 m_messages.push_back(new Message(message));
239 processSendQueue(); 239 processSendQueue();
240 } 240 }
241 241
242 void DocumentWebSocketChannel::send(PassRefPtr<BlobDataHandle> blobDataHandle) { 242 void DocumentWebSocketChannel::send(PassRefPtr<BlobDataHandle> blobDataHandle) {
243 NETWORK_DVLOG(1) << this << " sendBlob(" << blobDataHandle->uuid() << ", " 243 NETWORK_DVLOG(1) << this << " sendBlob(" << blobDataHandle->uuid() << ", "
244 << blobDataHandle->type() << ", " << blobDataHandle->size() 244 << blobDataHandle->type() << ", " << blobDataHandle->size()
245 << ")"; 245 << ")";
246 // FIXME: Change the inspector API to show the entire message instead 246 // FIXME: Change the inspector API to show the entire message instead
247 // of individual frames. 247 // of individual frames.
248 // FIXME: We can't access the data here. 248 // FIXME: We can't access the data here.
249 // Since Binary data are not displayed in Inspector, this does not 249 // Since Binary data are not displayed in Inspector, this does not
250 // affect actual behavior. 250 // affect actual behavior.
251 probe::didSendWebSocketFrame(document(), m_identifier, 251 probe::didSendWebSocketFrame(document(), m_identifier,
252 WebSocketFrame::OpCodeBinary, true, "", 0); 252 WebSocketFrame::OpCodeBinary, true, "", 0);
253 m_messages.append(new Message(std::move(blobDataHandle))); 253 m_messages.push_back(new Message(std::move(blobDataHandle)));
254 processSendQueue(); 254 processSendQueue();
255 } 255 }
256 256
257 void DocumentWebSocketChannel::send(const DOMArrayBuffer& buffer, 257 void DocumentWebSocketChannel::send(const DOMArrayBuffer& buffer,
258 unsigned byteOffset, 258 unsigned byteOffset,
259 unsigned byteLength) { 259 unsigned byteLength) {
260 NETWORK_DVLOG(1) << this << " sendArrayBuffer(" << buffer.data() << ", " 260 NETWORK_DVLOG(1) << this << " sendArrayBuffer(" << buffer.data() << ", "
261 << byteOffset << ", " << byteLength << ")"; 261 << byteOffset << ", " << byteLength << ")";
262 // FIXME: Change the inspector API to show the entire message instead 262 // FIXME: Change the inspector API to show the entire message instead
263 // of individual frames. 263 // of individual frames.
264 probe::didSendWebSocketFrame( 264 probe::didSendWebSocketFrame(
265 document(), m_identifier, WebSocketFrame::OpCodeBinary, true, 265 document(), m_identifier, WebSocketFrame::OpCodeBinary, true,
266 static_cast<const char*>(buffer.data()) + byteOffset, byteLength); 266 static_cast<const char*>(buffer.data()) + byteOffset, byteLength);
267 // buffer.slice copies its contents. 267 // buffer.slice copies its contents.
268 // FIXME: Reduce copy by sending the data immediately when we don't need to 268 // FIXME: Reduce copy by sending the data immediately when we don't need to
269 // queue the data. 269 // queue the data.
270 m_messages.append( 270 m_messages.push_back(
271 new Message(buffer.slice(byteOffset, byteOffset + byteLength))); 271 new Message(buffer.slice(byteOffset, byteOffset + byteLength)));
272 processSendQueue(); 272 processSendQueue();
273 } 273 }
274 274
275 void DocumentWebSocketChannel::sendTextAsCharVector( 275 void DocumentWebSocketChannel::sendTextAsCharVector(
276 std::unique_ptr<Vector<char>> data) { 276 std::unique_ptr<Vector<char>> data) {
277 NETWORK_DVLOG(1) << this << " sendTextAsCharVector(" 277 NETWORK_DVLOG(1) << this << " sendTextAsCharVector("
278 << static_cast<void*>(data.get()) << ", " << data->size() 278 << static_cast<void*>(data.get()) << ", " << data->size()
279 << ")"; 279 << ")";
280 // FIXME: Change the inspector API to show the entire message instead 280 // FIXME: Change the inspector API to show the entire message instead
281 // of individual frames. 281 // of individual frames.
282 probe::didSendWebSocketFrame(document(), m_identifier, 282 probe::didSendWebSocketFrame(document(), m_identifier,
283 WebSocketFrame::OpCodeText, true, data->data(), 283 WebSocketFrame::OpCodeText, true, data->data(),
284 data->size()); 284 data->size());
285 m_messages.append(new Message(std::move(data), MessageTypeTextAsCharVector)); 285 m_messages.push_back(
286 new Message(std::move(data), MessageTypeTextAsCharVector));
286 processSendQueue(); 287 processSendQueue();
287 } 288 }
288 289
289 void DocumentWebSocketChannel::sendBinaryAsCharVector( 290 void DocumentWebSocketChannel::sendBinaryAsCharVector(
290 std::unique_ptr<Vector<char>> data) { 291 std::unique_ptr<Vector<char>> data) {
291 NETWORK_DVLOG(1) << this << " sendBinaryAsCharVector(" 292 NETWORK_DVLOG(1) << this << " sendBinaryAsCharVector("
292 << static_cast<void*>(data.get()) << ", " << data->size() 293 << static_cast<void*>(data.get()) << ", " << data->size()
293 << ")"; 294 << ")";
294 // FIXME: Change the inspector API to show the entire message instead 295 // FIXME: Change the inspector API to show the entire message instead
295 // of individual frames. 296 // of individual frames.
296 probe::didSendWebSocketFrame(document(), m_identifier, 297 probe::didSendWebSocketFrame(document(), m_identifier,
297 WebSocketFrame::OpCodeBinary, true, data->data(), 298 WebSocketFrame::OpCodeBinary, true, data->data(),
298 data->size()); 299 data->size());
299 m_messages.append( 300 m_messages.push_back(
300 new Message(std::move(data), MessageTypeBinaryAsCharVector)); 301 new Message(std::move(data), MessageTypeBinaryAsCharVector));
301 processSendQueue(); 302 processSendQueue();
302 } 303 }
303 304
304 void DocumentWebSocketChannel::close(int code, const String& reason) { 305 void DocumentWebSocketChannel::close(int code, const String& reason) {
305 NETWORK_DVLOG(1) << this << " close(" << code << ", " << reason << ")"; 306 NETWORK_DVLOG(1) << this << " close(" << code << ", " << reason << ")";
306 DCHECK(m_handle); 307 DCHECK(m_handle);
307 unsigned short codeToSend = static_cast<unsigned short>( 308 unsigned short codeToSend = static_cast<unsigned short>(
308 code == CloseEventCodeNotSpecified ? CloseEventCodeNoStatusRcvd : code); 309 code == CloseEventCodeNotSpecified ? CloseEventCodeNoStatusRcvd : code);
309 m_messages.append(new Message(codeToSend, reason)); 310 m_messages.push_back(new Message(codeToSend, reason));
310 processSendQueue(); 311 processSendQueue();
311 } 312 }
312 313
313 void DocumentWebSocketChannel::fail(const String& reason, 314 void DocumentWebSocketChannel::fail(const String& reason,
314 MessageLevel level, 315 MessageLevel level,
315 std::unique_ptr<SourceLocation> location) { 316 std::unique_ptr<SourceLocation> location) {
316 NETWORK_DVLOG(1) << this << " fail(" << reason << ")"; 317 NETWORK_DVLOG(1) << this << " fail(" << reason << ")";
317 if (document()) { 318 if (document()) {
318 probe::didReceiveWebSocketFrameError(document(), m_identifier, reason); 319 probe::didReceiveWebSocketFrameError(document(), m_identifier, reason);
319 const String message = "WebSocket connection to '" + m_url.elidedString() + 320 const String message = "WebSocket connection to '" + m_url.elidedString() +
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 WebSocketChannel::trace(visitor); 720 WebSocketChannel::trace(visitor);
720 } 721 }
721 722
722 std::ostream& operator<<(std::ostream& ostream, 723 std::ostream& operator<<(std::ostream& ostream,
723 const DocumentWebSocketChannel* channel) { 724 const DocumentWebSocketChannel* channel) {
724 return ostream << "DocumentWebSocketChannel " 725 return ostream << "DocumentWebSocketChannel "
725 << static_cast<const void*>(channel); 726 << static_cast<const void*>(channel);
726 } 727 }
727 728
728 } // namespace blink 729 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698