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

Unified Diff: remoting/protocol/socket_reader_base.cc

Issue 11361197: Rename SocketReaderBase to SocketReader and move it to remoting/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/socket_reader_base.cc
diff --git a/remoting/protocol/socket_reader_base.cc b/remoting/protocol/socket_reader_base.cc
deleted file mode 100644
index bb315db2414db6679f9013816312b3436dbcb6b3..0000000000000000000000000000000000000000
--- a/remoting/protocol/socket_reader_base.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "remoting/protocol/socket_reader_base.h"
-
-#include "net/base/completion_callback.h"
-#include "net/base/io_buffer.h"
-#include "net/base/net_errors.h"
-#include "net/socket/socket.h"
-
-namespace remoting {
-
-namespace {
-int kReadBufferSize = 4096;
-} // namespace
-
-SocketReaderBase::SocketReaderBase()
- : socket_(NULL),
- closed_(false) {
-}
-
-SocketReaderBase::~SocketReaderBase() { }
-
-void SocketReaderBase::Init(net::Socket* socket) {
- DCHECK(socket);
- socket_ = socket;
- DoRead();
-}
-
-void SocketReaderBase::DoRead() {
- while (true) {
- read_buffer_ = new net::IOBuffer(kReadBufferSize);
- int result = socket_->Read(
- read_buffer_, kReadBufferSize, base::Bind(&SocketReaderBase::OnRead,
- base::Unretained(this)));
- HandleReadResult(result);
- if (result < 0)
- break;
- }
-}
-
-void SocketReaderBase::OnRead(int result) {
- if (!closed_) {
- HandleReadResult(result);
- DoRead();
- }
-}
-
-void SocketReaderBase::HandleReadResult(int result) {
- if (result > 0) {
- OnDataReceived(read_buffer_, result);
- } else {
- if (result == net::ERR_CONNECTION_CLOSED) {
- closed_ = true;
- } else if (result != net::ERR_IO_PENDING) {
- LOG(ERROR) << "Read() returned error " << result;
- }
- }
-}
-
-} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698