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

Side by Side Diff: remoting/protocol/message_reader.cc

Issue 6359018: Remove aggressive DCHECK in remoting::protocol::MessageReader() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 | « no previous file | no next file » | 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 "remoting/protocol/message_reader.h" 5 #include "remoting/protocol/message_reader.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/socket/socket.h" 10 #include "net/socket/socket.h"
(...skipping 22 matching lines...) Expand all
33 void MessageReader::Init(net::Socket* socket, 33 void MessageReader::Init(net::Socket* socket,
34 MessageReceivedCallback* callback) { 34 MessageReceivedCallback* callback) {
35 message_received_callback_.reset(callback); 35 message_received_callback_.reset(callback);
36 DCHECK(socket); 36 DCHECK(socket);
37 socket_ = socket; 37 socket_ = socket;
38 message_loop_ = MessageLoop::current(); 38 message_loop_ = MessageLoop::current();
39 DoRead(); 39 DoRead();
40 } 40 }
41 41
42 void MessageReader::DoRead() { 42 void MessageReader::DoRead() {
43 DCHECK(!read_pending_);
44
45 // Don't try to read again if there is another read pending or we 43 // Don't try to read again if there is another read pending or we
46 // have messages that we haven't finished processing yet. 44 // have messages that we haven't finished processing yet.
47 while (!closed_ && !read_pending_ && pending_messages_ == 0) { 45 while (!closed_ && !read_pending_ && pending_messages_ == 0) {
48 read_buffer_ = new net::IOBuffer(kReadBufferSize); 46 read_buffer_ = new net::IOBuffer(kReadBufferSize);
49 int result = socket_->Read( 47 int result = socket_->Read(
50 read_buffer_, kReadBufferSize, &read_callback_); 48 read_buffer_, kReadBufferSize, &read_callback_);
51 HandleReadResult(result); 49 HandleReadResult(result);
52 } 50 }
53 } 51 }
54 52
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 112 }
115 113
116 pending_messages_--; 114 pending_messages_--;
117 DCHECK_GE(pending_messages_, 0); 115 DCHECK_GE(pending_messages_, 0);
118 116
119 DoRead(); // Start next read if neccessary. 117 DoRead(); // Start next read if neccessary.
120 } 118 }
121 119
122 } // namespace protocol 120 } // namespace protocol
123 } // namespace remoting 121 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698