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

Side by Side Diff: net/websockets/websocket_job.cc

Issue 6609008: Change other usages of .size() to .empty() when applicable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter nits Created 9 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 | Annotate | Revision Log
« no previous file with comments | « net/websockets/websocket_handshake_handler.cc ('k') | ppapi/proxy/serialized_var.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/websockets/websocket_job.h" 5 #include "net/websockets/websocket_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/string_tokenizer.h" 10 #include "base/string_tokenizer.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 std::string received_data; 227 std::string received_data;
228 receive_frame_handler_->AppendData(data, len); 228 receive_frame_handler_->AppendData(data, len);
229 // Don't buffer receiving data for now. 229 // Don't buffer receiving data for now.
230 // TODO(ukai): fix performance of WebSocketFrameHandler. 230 // TODO(ukai): fix performance of WebSocketFrameHandler.
231 while (receive_frame_handler_->UpdateCurrentBuffer(false) > 0) { 231 while (receive_frame_handler_->UpdateCurrentBuffer(false) > 0) {
232 received_data += 232 received_data +=
233 std::string(receive_frame_handler_->GetCurrentBuffer()->data(), 233 std::string(receive_frame_handler_->GetCurrentBuffer()->data(),
234 receive_frame_handler_->GetCurrentBufferSize()); 234 receive_frame_handler_->GetCurrentBufferSize());
235 receive_frame_handler_->ReleaseCurrentBuffer(); 235 receive_frame_handler_->ReleaseCurrentBuffer();
236 } 236 }
237 if (delegate_ && received_data.size() > 0) 237 if (delegate_ && !received_data.empty())
238 delegate_->OnReceivedData( 238 delegate_->OnReceivedData(
239 socket, received_data.data(), received_data.size()); 239 socket, received_data.data(), received_data.size());
240 } 240 }
241 241
242 void WebSocketJob::OnClose(SocketStream* socket) { 242 void WebSocketJob::OnClose(SocketStream* socket) {
243 state_ = CLOSED; 243 state_ = CLOSED;
244 WebSocketThrottle::GetInstance()->RemoveFromQueue(this); 244 WebSocketThrottle::GetInstance()->RemoveFromQueue(this);
245 WebSocketThrottle::GetInstance()->WakeupSocketIfNecessary(); 245 WebSocketThrottle::GetInstance()->WakeupSocketIfNecessary();
246 246
247 scoped_refptr<WebSocketJob> protect(this); 247 scoped_refptr<WebSocketJob> protect(this);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 socket_->Close(); 503 socket_->Close();
504 return; 504 return;
505 } 505 }
506 current_buffer_ = new DrainableIOBuffer( 506 current_buffer_ = new DrainableIOBuffer(
507 send_frame_handler_->GetCurrentBuffer(), 507 send_frame_handler_->GetCurrentBuffer(),
508 send_frame_handler_->GetCurrentBufferSize()); 508 send_frame_handler_->GetCurrentBufferSize());
509 socket_->SendData(current_buffer_->data(), current_buffer_->BytesRemaining()); 509 socket_->SendData(current_buffer_->data(), current_buffer_->BytesRemaining());
510 } 510 }
511 511
512 } // namespace net 512 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_handshake_handler.cc ('k') | ppapi/proxy/serialized_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698