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

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: Remove useless 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
Index: remoting/protocol/authenticator_test_base.cc
diff --git a/remoting/protocol/authenticator_test_base.cc b/remoting/protocol/authenticator_test_base.cc
index 1e3f5409adb8578fef452286738897556548bb07..cd77841ecb5b90ef3d594c5ba6254d7c4820f242 100644
--- a/remoting/protocol/authenticator_test_base.cc
+++ b/remoting/protocol/authenticator_test_base.cc
@@ -59,36 +59,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);
+ RunAuthExchangeStep(client_.get(), host_.get());
Sergey Ulanov 2013/03/01 01:28:30 This changes behavior of this function. Should it
rmsousa 2013/03/01 02:22:11 It's the other one that's named wrongly - running
+}
+
+void AuthenticatorTestBase::RunAuthExchangeStep(Authenticator* sender,
Sergey Ulanov 2013/03/01 01:28:30 Can this be static?
rmsousa 2013/03/01 02:22:11 Yes.
+ 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(base::Bind(
+ &AuthenticatorTestBase::RunAuthExchangeStep,
+ base::Unretained(this), base::Unretained(receiver),
+ base::Unretained(sender)), message.get());
}
void AuthenticatorTestBase::RunChannelAuth(bool expected_fail) {

Powered by Google App Engine
This is Rietveld 408576698