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

Unified Diff: net/base/listen_socket_unittest.cc

Issue 6248021: Reapply r72562 with willchan's nits + locally tested shlib fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix path 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/listen_socket_unittest.h ('k') | net/base/mock_filter_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/listen_socket_unittest.cc
diff --git a/net/base/listen_socket_unittest.cc b/net/base/listen_socket_unittest.cc
index 53fc79ba57e8ce6ed1f8fe9f673e0a062915da3b..75beeec257694ad9890c2238a6ade1372f7aa3a8 100644
--- a/net/base/listen_socket_unittest.cc
+++ b/net/base/listen_socket_unittest.cc
@@ -19,8 +19,12 @@ static const int kMaxQueueSize = 20;
static const char kLoopback[] = "127.0.0.1";
static const int kDefaultTimeoutMs = 5000;
-ListenSocket* ListenSocketTester::DoListen() {
- return ListenSocket::Listen(kLoopback, kTestPort, this);
+ListenSocketTester::ListenSocketTester()
+ : thread_(NULL),
+ loop_(NULL),
+ server_(NULL),
+ connection_(NULL),
+ cv_(&lock_) {
}
void ListenSocketTester::SetUp() {
@@ -121,36 +125,6 @@ void ListenSocketTester::SendFromTester() {
ReportAction(ListenSocketTestAction(ACTION_SEND));
}
-void ListenSocketTester::DidAccept(ListenSocket *server,
- ListenSocket *connection) {
- connection_ = connection;
- connection_->AddRef();
- ReportAction(ListenSocketTestAction(ACTION_ACCEPT));
-}
-
-void ListenSocketTester::DidRead(ListenSocket *connection,
- const char* data,
- int len) {
- std::string str(data, len);
- ReportAction(ListenSocketTestAction(ACTION_READ, str));
-}
-
-void ListenSocketTester::DidClose(ListenSocket *sock) {
- ReportAction(ListenSocketTestAction(ACTION_CLOSE));
-}
-
-bool ListenSocketTester::Send(SOCKET sock, const std::string& str) {
- int len = static_cast<int>(str.length());
- int send_len = HANDLE_EINTR(send(sock, str.data(), len, 0));
- if (send_len == SOCKET_ERROR) {
- LOG(ERROR) << "send failed: " << errno;
- return false;
- } else if (send_len != len) {
- return false;
- }
- return true;
-}
-
void ListenSocketTester::TestClientSend() {
ASSERT_TRUE(Send(test_socket_, kHelloWorld));
NextAction();
@@ -200,6 +174,42 @@ void ListenSocketTester::TestServerSend() {
ASSERT_STREQ(buf, kHelloWorld);
}
+bool ListenSocketTester::Send(SOCKET sock, const std::string& str) {
+ int len = static_cast<int>(str.length());
+ int send_len = HANDLE_EINTR(send(sock, str.data(), len, 0));
+ if (send_len == SOCKET_ERROR) {
+ LOG(ERROR) << "send failed: " << errno;
+ return false;
+ } else if (send_len != len) {
+ return false;
+ }
+ return true;
+}
+
+void ListenSocketTester::DidAccept(ListenSocket *server,
+ ListenSocket *connection) {
+ connection_ = connection;
+ connection_->AddRef();
+ ReportAction(ListenSocketTestAction(ACTION_ACCEPT));
+}
+
+void ListenSocketTester::DidRead(ListenSocket *connection,
+ const char* data,
+ int len) {
+ std::string str(data, len);
+ ReportAction(ListenSocketTestAction(ACTION_READ, str));
+}
+
+void ListenSocketTester::DidClose(ListenSocket *sock) {
+ ReportAction(ListenSocketTestAction(ACTION_CLOSE));
+}
+
+ListenSocketTester::~ListenSocketTester() {}
+
+ListenSocket* ListenSocketTester::DoListen() {
+ return ListenSocket::Listen(kLoopback, kTestPort, this);
+}
+
class ListenSocketTest: public PlatformTest {
public:
« no previous file with comments | « net/base/listen_socket_unittest.h ('k') | net/base/mock_filter_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698