| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/socket/socket.h" | 15 #include "net/socket/socket.h" |
| 16 #include "remoting/base/compound_buffer.h" | 16 #include "remoting/base/compound_buffer.h" |
| 17 #include "remoting/proto/internal.pb.h" | 17 #include "remoting/proto/internal.pb.h" |
| 18 | 18 |
| 19 namespace remoting { | 19 namespace remoting { |
| 20 namespace protocol { | 20 namespace protocol { |
| 21 | 21 |
| 22 static const int kReadBufferSize = 4096; | 22 static const int kReadBufferSize = 4096; |
| 23 | 23 |
| 24 MessageReader::MessageReader() | 24 MessageReader::MessageReader() |
| 25 : socket_(NULL), | 25 : socket_(nullptr), |
| 26 read_pending_(false), | 26 read_pending_(false), |
| 27 pending_messages_(0), | 27 pending_messages_(0), |
| 28 closed_(false), | 28 closed_(false), |
| 29 weak_factory_(this) { | 29 weak_factory_(this) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 void MessageReader::Init(net::Socket* socket, | 32 void MessageReader::Init(net::Socket* socket, |
| 33 const MessageReceivedCallback& callback) { | 33 const MessageReceivedCallback& callback) { |
| 34 DCHECK(CalledOnValidThread()); | 34 DCHECK(CalledOnValidThread()); |
| 35 message_received_callback_ = callback; | 35 message_received_callback_ = callback; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 DCHECK(CalledOnValidThread()); | 113 DCHECK(CalledOnValidThread()); |
| 114 pending_messages_--; | 114 pending_messages_--; |
| 115 DCHECK_GE(pending_messages_, 0); | 115 DCHECK_GE(pending_messages_, 0); |
| 116 | 116 |
| 117 // Start next read if necessary. | 117 // Start next read if necessary. |
| 118 DoRead(); | 118 DoRead(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace protocol | 121 } // namespace protocol |
| 122 } // namespace remoting | 122 } // namespace remoting |
| OLD | NEW |