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

Side by Side Diff: remoting/protocol/fake_authenticator.cc

Issue 2453933008: Bugfixes in JingleSession (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/fake_authenticator.h" 5 #include "remoting/protocol/fake_authenticator.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 Action action, 94 Action action,
95 bool async) 95 bool async)
96 : type_(type), round_trips_(round_trips), action_(action), async_(async) {} 96 : type_(type), round_trips_(round_trips), action_(action), async_(async) {}
97 97
98 FakeAuthenticator::~FakeAuthenticator() {} 98 FakeAuthenticator::~FakeAuthenticator() {}
99 99
100 void FakeAuthenticator::set_messages_till_started(int messages) { 100 void FakeAuthenticator::set_messages_till_started(int messages) {
101 messages_till_started_ = messages; 101 messages_till_started_ = messages;
102 } 102 }
103 103
104 void FakeAuthenticator::Resume() {
105 base::ResetAndReturn(&resume_closure_).Run();
106 }
107
104 Authenticator::State FakeAuthenticator::state() const { 108 Authenticator::State FakeAuthenticator::state() const {
105 EXPECT_LE(messages_, round_trips_ * 2); 109 EXPECT_LE(messages_, round_trips_ * 2);
110
111 if (messages_ == pause_message_index_ && !resume_closure_.is_null())
112 return PROCESSING_MESSAGE;
113
106 if (messages_ >= round_trips_ * 2) { 114 if (messages_ >= round_trips_ * 2) {
107 if (action_ == REJECT) { 115 if (action_ == REJECT) {
108 return REJECTED; 116 return REJECTED;
109 } else { 117 } else {
110 return ACCEPTED; 118 return ACCEPTED;
111 } 119 }
112 } 120 }
113 121
114 // Don't send the last message if this is a host that wants to 122 // Don't send the last message if this is a host that wants to
115 // reject a connection. 123 // reject a connection.
(...skipping 29 matching lines...) Expand all
145 153
146 // On the client receive the key in the last message. 154 // On the client receive the key in the last message.
147 if (type_ == CLIENT && messages_ == round_trips_ * 2 - 1) { 155 if (type_ == CLIENT && messages_ == round_trips_ * 2 - 1) {
148 std::string key_base64 = 156 std::string key_base64 =
149 message->TextNamed(buzz::QName(kChromotingXmlNamespace, "key")); 157 message->TextNamed(buzz::QName(kChromotingXmlNamespace, "key"));
150 EXPECT_TRUE(!key_base64.empty()); 158 EXPECT_TRUE(!key_base64.empty());
151 EXPECT_TRUE(base::Base64Decode(key_base64, &auth_key_)); 159 EXPECT_TRUE(base::Base64Decode(key_base64, &auth_key_));
152 } 160 }
153 161
154 ++messages_; 162 ++messages_;
163 if (messages_ == pause_message_index_) {
164 resume_closure_ = resume_callback;
165 return;
166 }
155 resume_callback.Run(); 167 resume_callback.Run();
156 } 168 }
157 169
158 std::unique_ptr<buzz::XmlElement> FakeAuthenticator::GetNextMessage() { 170 std::unique_ptr<buzz::XmlElement> FakeAuthenticator::GetNextMessage() {
159 EXPECT_EQ(MESSAGE_READY, state()); 171 EXPECT_EQ(MESSAGE_READY, state());
160 172
161 std::unique_ptr<buzz::XmlElement> result(new buzz::XmlElement( 173 std::unique_ptr<buzz::XmlElement> result(new buzz::XmlElement(
162 buzz::QName(kChromotingXmlNamespace, "authentication"))); 174 buzz::QName(kChromotingXmlNamespace, "authentication")));
163 buzz::XmlElement* id = new buzz::XmlElement( 175 buzz::XmlElement* id = new buzz::XmlElement(
164 buzz::QName(kChromotingXmlNamespace, "id")); 176 buzz::QName(kChromotingXmlNamespace, "id"));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 const std::string& local_jid, 221 const std::string& local_jid,
210 const std::string& remote_jid) { 222 const std::string& remote_jid) {
211 std::unique_ptr<FakeAuthenticator> authenticator(new FakeAuthenticator( 223 std::unique_ptr<FakeAuthenticator> authenticator(new FakeAuthenticator(
212 FakeAuthenticator::HOST, round_trips_, action_, async_)); 224 FakeAuthenticator::HOST, round_trips_, action_, async_));
213 authenticator->set_messages_till_started(messages_till_started_); 225 authenticator->set_messages_till_started(messages_till_started_);
214 return std::move(authenticator); 226 return std::move(authenticator);
215 } 227 }
216 228
217 } // namespace protocol 229 } // namespace protocol
218 } // namespace remoting 230 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698