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

Unified Diff: remoting/protocol/fake_authenticator.cc

Issue 551173004: Move PseudoTCP and channel auth out of LibjingleTransportFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean_dgrams
Patch Set: Created 6 years, 3 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
Index: remoting/protocol/fake_authenticator.cc
diff --git a/remoting/protocol/fake_authenticator.cc b/remoting/protocol/fake_authenticator.cc
index bf06c56c6a8b61b0a7389d1424b46a793b4100d4..2636acfc0b72d53f7e48aac41d94d0b81bc8d610 100644
--- a/remoting/protocol/fake_authenticator.cc
+++ b/remoting/protocol/fake_authenticator.cc
@@ -7,6 +7,7 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "net/base/io_buffer.h"
+#include "net/base/net_errors.h"
#include "net/socket/stream_socket.h"
#include "remoting/base/constants.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -56,9 +57,7 @@ void FakeChannelAuthenticator::SecureAndAuthenticate(
if (result != net::ERR_IO_PENDING)
OnAuthBytesRead(result);
} else {
- if (result_ != net::OK)
- socket_.reset();
- done_callback.Run(result_, socket_.Pass());
+ CallDoneCallback();
}
}
@@ -67,7 +66,7 @@ void FakeChannelAuthenticator::OnAuthBytesWritten(int result) {
EXPECT_FALSE(did_write_bytes_);
did_write_bytes_ = true;
if (did_read_bytes_)
- done_callback_.Run(result_, socket_.Pass());
+ CallDoneCallback();
}
void FakeChannelAuthenticator::OnAuthBytesRead(int result) {
@@ -75,7 +74,15 @@ void FakeChannelAuthenticator::OnAuthBytesRead(int result) {
EXPECT_FALSE(did_read_bytes_);
did_read_bytes_ = true;
if (did_write_bytes_)
- done_callback_.Run(result_, socket_.Pass());
+ CallDoneCallback();
+}
+
+void FakeChannelAuthenticator::CallDoneCallback() {
+ DoneCallback callback = done_callback_;
+ done_callback_.Reset();
+ if (result_ != net::OK)
+ socket_.reset();
+ callback.Run(result_, socket_.Pass());
}
FakeAuthenticator::FakeAuthenticator(

Powered by Google App Engine
This is Rietveld 408576698