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

Unified Diff: remoting/protocol/fake_datagram_socket.cc

Issue 1273233002: Implement QuicChannel and QuicChannelFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « remoting/protocol/fake_datagram_socket.h ('k') | remoting/protocol/quic_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/fake_datagram_socket.cc
diff --git a/remoting/protocol/fake_datagram_socket.cc b/remoting/protocol/fake_datagram_socket.cc
index 53d31d098276420b140092c0add0c4a22a479eaa..010cb36b186725b08c1e5c5e319e5a6129e5a2f4 100644
--- a/remoting/protocol/fake_datagram_socket.cc
+++ b/remoting/protocol/fake_datagram_socket.cc
@@ -69,6 +69,40 @@ int FakeDatagramSocket::Send(const scoped_refptr<net::IOBuffer>& buf,
int buf_len,
const net::CompletionCallback& callback) {
EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
+ EXPECT_FALSE(send_pending_);
+
+ if (async_send_) {
+ send_pending_ = true;
+ task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&FakeDatagramSocket::DoAsyncSend, weak_factory_.GetWeakPtr(),
+ buf, buf_len, callback));
+ return net::ERR_IO_PENDING;
+ } else {
+ return DoSend(buf, buf_len);
+ }
+}
+
+void FakeDatagramSocket::DoAsyncSend(const scoped_refptr<net::IOBuffer>& buf,
+ int buf_len,
+ const net::CompletionCallback& callback) {
+ EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
+
+ EXPECT_TRUE(send_pending_);
+ send_pending_ = false;
+ callback.Run(DoSend(buf, buf_len));
+}
+
+int FakeDatagramSocket::DoSend(const scoped_refptr<net::IOBuffer>& buf,
+ int buf_len) {
+ EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
+
+ if (next_send_error_ != net::OK) {
+ int r = next_send_error_;
+ next_send_error_ = net::OK;
+ return r;
+ }
+
written_packets_.push_back(std::string());
written_packets_.back().assign(buf->data(), buf->data() + buf_len);
« no previous file with comments | « remoting/protocol/fake_datagram_socket.h ('k') | remoting/protocol/quic_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698