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

Unified Diff: remoting/protocol/authenticator_test_base.cc

Issue 12389010: Refactor of Authenticator to allow it to ProcessMessage asynchronously and then call a callback (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: Rebase missed one include Created 7 years, 10 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/authenticator_test_base.h ('k') | remoting/protocol/connection_to_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/authenticator_test_base.cc
diff --git a/remoting/protocol/authenticator_test_base.cc b/remoting/protocol/authenticator_test_base.cc
index 18450987f3f0559e79f491eda89cd4a47491cfe1..2805d99ed83a3e766b855ba985182ceb3e517226 100644
--- a/remoting/protocol/authenticator_test_base.cc
+++ b/remoting/protocol/authenticator_test_base.cc
@@ -60,36 +60,27 @@ void AuthenticatorTestBase::SetUp() {
}
void AuthenticatorTestBase::RunAuthExchange() {
- do {
- scoped_ptr<buzz::XmlElement> message;
-
- // Pass message from client to host.
- ASSERT_EQ(Authenticator::MESSAGE_READY, client_->state());
- message = client_->GetNextMessage();
- ASSERT_TRUE(message.get());
- ASSERT_NE(Authenticator::MESSAGE_READY, client_->state());
-
- ASSERT_EQ(Authenticator::WAITING_MESSAGE, host_->state());
- host_->ProcessMessage(message.get());
- ASSERT_NE(Authenticator::WAITING_MESSAGE, host_->state());
-
- // Are we done yet?
- if (host_->state() == Authenticator::ACCEPTED ||
- host_->state() == Authenticator::REJECTED) {
- break;
- }
-
- // Pass message from host to client.
- ASSERT_EQ(Authenticator::MESSAGE_READY, host_->state());
- message = host_->GetNextMessage();
- ASSERT_TRUE(message.get());
- ASSERT_NE(Authenticator::MESSAGE_READY, host_->state());
-
- ASSERT_EQ(Authenticator::WAITING_MESSAGE, client_->state());
- client_->ProcessMessage(message.get());
- ASSERT_NE(Authenticator::WAITING_MESSAGE, client_->state());
- } while (client_->state() != Authenticator::ACCEPTED &&
- client_->state() != Authenticator::REJECTED);
+ ContinueAuthExchangeWith(client_.get(), host_.get());
+}
+
+// static
+void AuthenticatorTestBase::ContinueAuthExchangeWith(Authenticator* sender,
+ Authenticator* receiver) {
+ scoped_ptr<buzz::XmlElement> message;
+ ASSERT_NE(Authenticator::WAITING_MESSAGE, sender->state());
+ if (sender->state() == Authenticator::ACCEPTED ||
+ sender->state() == Authenticator::REJECTED)
+ return;
+ // Pass message from client to host.
+ ASSERT_EQ(Authenticator::MESSAGE_READY, sender->state());
+ message = sender->GetNextMessage();
+ ASSERT_TRUE(message.get());
+ ASSERT_NE(Authenticator::MESSAGE_READY, sender->state());
+
+ ASSERT_EQ(Authenticator::WAITING_MESSAGE, receiver->state());
+ receiver->ProcessMessage(message.get(), base::Bind(
+ &AuthenticatorTestBase::ContinueAuthExchangeWith,
+ base::Unretained(receiver), base::Unretained(sender)));
}
void AuthenticatorTestBase::RunChannelAuth(bool expected_fail) {
« no previous file with comments | « remoting/protocol/authenticator_test_base.h ('k') | remoting/protocol/connection_to_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698