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

Unified Diff: net/socket/web_socket_server_socket_unittest.cc

Issue 8831001: base::Bind: Convert Socket::Write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix alignment. Created 9 years 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/socket/web_socket_server_socket.cc ('k') | net/spdy/spdy_proxy_client_socket.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/web_socket_server_socket_unittest.cc
diff --git a/net/socket/web_socket_server_socket_unittest.cc b/net/socket/web_socket_server_socket_unittest.cc
index cabb4b9c922bcd733a8ccc0d9f5a4c51196c3579..bb4d0223dd4a565150c34b5953399013ac43b15c 100644
--- a/net/socket/web_socket_server_socket_unittest.cc
+++ b/net/socket/web_socket_server_socket_unittest.cc
@@ -157,6 +157,24 @@ class TestingTransportSocket : public net::Socket {
}
MessageLoop::current()->PostTask(FROM_HERE,
method_factory_.NewRunnableMethod(
+ &TestingTransportSocket::DoOldWriteCallback, callback, lot));
+ return net::ERR_IO_PENDING;
+ }
+ virtual int Write(net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback) {
+ CHECK_GT(buf_len, 0);
+ int remaining = answer_->BytesRemaining();
+ CHECK_GE(remaining, buf_len);
+ int lot = std::min(remaining, buf_len);
+ if (GetRand(0, 1))
+ lot = GetRand(1, lot);
+ std::copy(buf->data(), buf->data() + lot, answer_->data());
+ answer_->DidConsume(lot);
+ if (GetRand(0, 1)) {
+ return lot;
+ }
+ MessageLoop::current()->PostTask(FROM_HERE,
+ method_factory_.NewRunnableMethod(
&TestingTransportSocket::DoWriteCallback, callback, lot));
return net::ERR_IO_PENDING;
}
@@ -192,10 +210,14 @@ class TestingTransportSocket : public net::Socket {
}
}
- void DoWriteCallback(net::OldCompletionCallback* callback, int result) {
+ void DoOldWriteCallback(net::OldCompletionCallback* callback, int result) {
if (callback)
callback->Run(result);
}
+ void DoWriteCallback(const net::CompletionCallback& callback, int result) {
+ if (!callback.is_null())
+ callback.Run(result);
+ }
bool is_closed_;
« no previous file with comments | « net/socket/web_socket_server_socket.cc ('k') | net/spdy/spdy_proxy_client_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698