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( |