summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrkn@chromium.org <rkn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-23 20:30:33 +0000
committerrkn@chromium.org <rkn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-23 20:30:33 +0000
commitff04c53708ec68d1f6b1aefa2d44df1725cdf7eb (patch)
treeb0b3dc40223111a4440a56b5d3b279e5b92bd310 /net
parentfd0719894fe7432eec3155bd23cfab4bb22d4595 (diff)
downloadchromium_src-ff04c53708ec68d1f6b1aefa2d44df1725cdf7eb.zip
chromium_src-ff04c53708ec68d1f6b1aefa2d44df1725cdf7eb.tar.gz
chromium_src-ff04c53708ec68d1f6b1aefa2d44df1725cdf7eb.tar.bz2
Moved the ListenSocket class (found in net/base/listen_socket.h) to the net namespace.
BUG=87032 TEST=None Review URL: http://codereview.chromium.org/7190041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/listen_socket.cc6
-rw-r--r--net/base/listen_socket.h4
-rw-r--r--net/base/listen_socket_unittest.cc14
-rw-r--r--net/base/listen_socket_unittest.h23
-rw-r--r--net/tools/fetch/http_listen_socket.cc24
-rw-r--r--net/tools/fetch/http_listen_socket.h16
6 files changed, 50 insertions, 37 deletions
diff --git a/net/base/listen_socket.cc b/net/base/listen_socket.cc
index 0971784..e83f081 100644
--- a/net/base/listen_socket.cc
+++ b/net/base/listen_socket.cc
@@ -25,6 +25,8 @@
typedef int socklen_t;
#endif // defined(OS_WIN)
+namespace net {
+
namespace {
const int kReadBufSize = 4096;
@@ -132,7 +134,7 @@ SOCKET ListenSocket::Accept(SOCKET s) {
SOCKET conn =
HANDLE_EINTR(accept(s, reinterpret_cast<sockaddr*>(&from), &from_len));
if (conn != kInvalidSocket) {
- net::SetNonBlocking(conn);
+ SetNonBlocking(conn);
}
return conn;
}
@@ -321,3 +323,5 @@ void ListenSocket::OnFileCanWriteWithoutBlocking(int fd) {
}
#endif
+
+} // namespace net
diff --git a/net/base/listen_socket.h b/net/base/listen_socket.h
index 6a276b2..0624552 100644
--- a/net/base/listen_socket.h
+++ b/net/base/listen_socket.h
@@ -33,6 +33,8 @@
typedef int SOCKET;
#endif
+namespace net {
+
// Implements a raw socket interface
class NET_API ListenSocket : public base::RefCountedThreadSafe<ListenSocket>,
#if defined(OS_WIN)
@@ -129,4 +131,6 @@ class NET_API ListenSocket : public base::RefCountedThreadSafe<ListenSocket>,
DISALLOW_COPY_AND_ASSIGN(ListenSocket);
};
+} // namespace net
+
#endif // NET_BASE_LISTEN_SOCKET_H_
diff --git a/net/base/listen_socket_unittest.cc b/net/base/listen_socket_unittest.cc
index 75beeec..97a8cf5 100644
--- a/net/base/listen_socket_unittest.cc
+++ b/net/base/listen_socket_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -186,28 +186,28 @@ bool ListenSocketTester::Send(SOCKET sock, const std::string& str) {
return true;
}
-void ListenSocketTester::DidAccept(ListenSocket *server,
- ListenSocket *connection) {
+void ListenSocketTester::DidAccept(net::ListenSocket *server,
+ net::ListenSocket *connection) {
connection_ = connection;
connection_->AddRef();
ReportAction(ListenSocketTestAction(ACTION_ACCEPT));
}
-void ListenSocketTester::DidRead(ListenSocket *connection,
+void ListenSocketTester::DidRead(net::ListenSocket *connection,
const char* data,
int len) {
std::string str(data, len);
ReportAction(ListenSocketTestAction(ACTION_READ, str));
}
-void ListenSocketTester::DidClose(ListenSocket *sock) {
+void ListenSocketTester::DidClose(net::ListenSocket *sock) {
ReportAction(ListenSocketTestAction(ACTION_CLOSE));
}
ListenSocketTester::~ListenSocketTester() {}
-ListenSocket* ListenSocketTester::DoListen() {
- return ListenSocket::Listen(kLoopback, kTestPort, this);
+net::ListenSocket* ListenSocketTester::DoListen() {
+ return net::ListenSocket::Listen(kLoopback, kTestPort, this);
}
diff --git a/net/base/listen_socket_unittest.h b/net/base/listen_socket_unittest.h
index aaf9341..ed74b88 100644
--- a/net/base/listen_socket_unittest.h
+++ b/net/base/listen_socket_unittest.h
@@ -29,7 +29,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_POSIX)
-// Used same name as in Windows to avoid #ifdef where refrenced
+// Used same name as in Windows to avoid #ifdef where referenced
#define SOCKET int
const int INVALID_SOCKET = -1;
const int SOCKET_ERROR = -1;
@@ -63,9 +63,9 @@ class ListenSocketTestAction {
// This had to be split out into a separate class because I couldn't
-// make a the testing::Test class refcounted.
+// make the testing::Test class refcounted.
class ListenSocketTester :
- public ListenSocket::ListenSocketDelegate,
+ public net::ListenSocket::ListenSocketDelegate,
public base::RefCountedThreadSafe<ListenSocketTester> {
public:
@@ -92,15 +92,18 @@ class ListenSocketTester :
virtual bool Send(SOCKET sock, const std::string& str);
- // ListenSocket::ListenSocketDelegate:
- virtual void DidAccept(ListenSocket *server, ListenSocket *connection);
- virtual void DidRead(ListenSocket *connection, const char* data, int len);
- virtual void DidClose(ListenSocket *sock);
+ // net::ListenSocket::ListenSocketDelegate:
+ virtual void DidAccept(net::ListenSocket *server,
+ net::ListenSocket *connection);
+ virtual void DidRead(net::ListenSocket *connection,
+ const char* data,
+ int len);
+ virtual void DidClose(net::ListenSocket *sock);
scoped_ptr<base::Thread> thread_;
MessageLoopForIO* loop_;
- ListenSocket* server_;
- ListenSocket* connection_;
+ net::ListenSocket* server_;
+ net::ListenSocket* connection_;
ListenSocketTestAction last_action_;
SOCKET test_socket_;
@@ -115,7 +118,7 @@ class ListenSocketTester :
virtual ~ListenSocketTester();
- virtual ListenSocket* DoListen();
+ virtual net::ListenSocket* DoListen();
};
#endif // NET_BASE_LISTEN_SOCKET_UNITTEST_H_
diff --git a/net/tools/fetch/http_listen_socket.cc b/net/tools/fetch/http_listen_socket.cc
index 78d924d..fc9f5f3 100644
--- a/net/tools/fetch/http_listen_socket.cc
+++ b/net/tools/fetch/http_listen_socket.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -16,7 +16,7 @@
// must run in the IO thread
HttpListenSocket::HttpListenSocket(SOCKET s,
HttpListenSocket::Delegate* delegate)
- : ALLOW_THIS_IN_INITIALIZER_LIST(ListenSocket(s, this)),
+ : ALLOW_THIS_IN_INITIALIZER_LIST(net::ListenSocket(s, this)),
delegate_(delegate) {
}
@@ -25,13 +25,13 @@ HttpListenSocket::~HttpListenSocket() {
}
void HttpListenSocket::Listen() {
- ListenSocket::Listen();
+ net::ListenSocket::Listen();
}
void HttpListenSocket::Accept() {
- SOCKET conn = ListenSocket::Accept(socket_);
- DCHECK_NE(conn, ListenSocket::kInvalidSocket);
- if (conn == ListenSocket::kInvalidSocket) {
+ SOCKET conn = net::ListenSocket::Accept(socket_);
+ DCHECK_NE(conn, net::ListenSocket::kInvalidSocket);
+ if (conn == net::ListenSocket::kInvalidSocket) {
// TODO
} else {
scoped_refptr<HttpListenSocket> sock(
@@ -45,8 +45,8 @@ HttpListenSocket* HttpListenSocket::Listen(
const std::string& ip,
int port,
HttpListenSocket::Delegate* delegate) {
- SOCKET s = ListenSocket::Listen(ip, port);
- if (s == ListenSocket::kInvalidSocket) {
+ SOCKET s = net::ListenSocket::Listen(ip, port);
+ if (s == net::ListenSocket::kInvalidSocket) {
// TODO (ibrar): error handling
} else {
HttpListenSocket *serv = new HttpListenSocket(s, delegate);
@@ -185,12 +185,12 @@ HttpServerRequestInfo* HttpListenSocket::ParseHeaders() {
return NULL;
}
-void HttpListenSocket::DidAccept(ListenSocket* server,
- ListenSocket* connection) {
+void HttpListenSocket::DidAccept(net::ListenSocket* server,
+ net::ListenSocket* connection) {
connection->AddRef();
}
-void HttpListenSocket::DidRead(ListenSocket* connection,
+void HttpListenSocket::DidRead(net::ListenSocket* connection,
const char* data,
int len) {
recv_data_.append(data, len);
@@ -203,7 +203,7 @@ void HttpListenSocket::DidRead(ListenSocket* connection,
}
}
-void HttpListenSocket::DidClose(ListenSocket* sock) {
+void HttpListenSocket::DidClose(net::ListenSocket* sock) {
sock->Release();
}
diff --git a/net/tools/fetch/http_listen_socket.h b/net/tools/fetch/http_listen_socket.h
index 82f5312..4d20e1d 100644
--- a/net/tools/fetch/http_listen_socket.h
+++ b/net/tools/fetch/http_listen_socket.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -13,8 +13,8 @@ class HttpServerRequestInfo;
class HttpServerResponseInfo;
// Implements a simple HTTP listen socket on top of the raw socket interface.
-class HttpListenSocket : public ListenSocket,
- public ListenSocket::ListenSocketDelegate {
+class HttpListenSocket : public net::ListenSocket,
+ public net::ListenSocket::ListenSocketDelegate {
public:
class Delegate {
public:
@@ -36,12 +36,14 @@ class HttpListenSocket : public ListenSocket,
void Respond(HttpServerResponseInfo* info, std::string& data);
// ListenSocketDelegate
- virtual void DidAccept(ListenSocket* server, ListenSocket* connection);
- virtual void DidRead(ListenSocket* connection, const char* data, int len);
- virtual void DidClose(ListenSocket* sock);
+ virtual void DidAccept(net::ListenSocket* server,
+ net::ListenSocket* connection);
+ virtual void DidRead(net::ListenSocket* connection,
+ const char* data, int len);
+ virtual void DidClose(net::ListenSocket* sock);
private:
- friend class base::RefCountedThreadSafe<ListenSocket>;
+ friend class base::RefCountedThreadSafe<net::ListenSocket>;
static const int kReadBufSize = 16 * 1024;
HttpListenSocket(SOCKET s, HttpListenSocket::Delegate* del);