OLD | NEW |
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/negotiating_authenticator_base.h" | 5 #include "remoting/protocol/negotiating_authenticator_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // Verify that this is a valid state transition. | 120 // Verify that this is a valid state transition. |
121 DCHECK(state_ == MESSAGE_READY || state_ == ACCEPTED || state_ == REJECTED) | 121 DCHECK(state_ == MESSAGE_READY || state_ == ACCEPTED || state_ == REJECTED) |
122 << "State: " << state_; | 122 << "State: " << state_; |
123 | 123 |
124 if (state_ == REJECTED) | 124 if (state_ == REJECTED) |
125 rejection_reason_ = current_authenticator_->rejection_reason(); | 125 rejection_reason_ = current_authenticator_->rejection_reason(); |
126 | 126 |
127 resume_callback.Run(); | 127 resume_callback.Run(); |
128 } | 128 } |
129 | 129 |
130 scoped_ptr<buzz::XmlElement> | 130 std::unique_ptr<buzz::XmlElement> |
131 NegotiatingAuthenticatorBase::GetNextMessageInternal() { | 131 NegotiatingAuthenticatorBase::GetNextMessageInternal() { |
132 DCHECK_EQ(state(), MESSAGE_READY); | 132 DCHECK_EQ(state(), MESSAGE_READY); |
133 DCHECK(current_method_ != Method::INVALID); | 133 DCHECK(current_method_ != Method::INVALID); |
134 | 134 |
135 scoped_ptr<buzz::XmlElement> result; | 135 std::unique_ptr<buzz::XmlElement> result; |
136 if (current_authenticator_->state() == MESSAGE_READY) { | 136 if (current_authenticator_->state() == MESSAGE_READY) { |
137 result = current_authenticator_->GetNextMessage(); | 137 result = current_authenticator_->GetNextMessage(); |
138 } else { | 138 } else { |
139 result = CreateEmptyAuthenticatorMessage(); | 139 result = CreateEmptyAuthenticatorMessage(); |
140 } | 140 } |
141 state_ = current_authenticator_->state(); | 141 state_ = current_authenticator_->state(); |
142 DCHECK(state_ == ACCEPTED || state_ == WAITING_MESSAGE); | 142 DCHECK(state_ == ACCEPTED || state_ == WAITING_MESSAGE); |
143 result->AddAttr(kMethodAttributeQName, MethodToString(current_method_)); | 143 result->AddAttr(kMethodAttributeQName, MethodToString(current_method_)); |
144 return result; | 144 return result; |
145 } | 145 } |
146 | 146 |
147 void NegotiatingAuthenticatorBase::AddMethod(Method method) { | 147 void NegotiatingAuthenticatorBase::AddMethod(Method method) { |
148 DCHECK(method != Method::INVALID); | 148 DCHECK(method != Method::INVALID); |
149 methods_.push_back(method); | 149 methods_.push_back(method); |
150 } | 150 } |
151 | 151 |
152 const std::string& NegotiatingAuthenticatorBase::GetAuthKey() const { | 152 const std::string& NegotiatingAuthenticatorBase::GetAuthKey() const { |
153 DCHECK_EQ(state(), ACCEPTED); | 153 DCHECK_EQ(state(), ACCEPTED); |
154 return current_authenticator_->GetAuthKey(); | 154 return current_authenticator_->GetAuthKey(); |
155 } | 155 } |
156 | 156 |
157 scoped_ptr<ChannelAuthenticator> | 157 std::unique_ptr<ChannelAuthenticator> |
158 NegotiatingAuthenticatorBase::CreateChannelAuthenticator() const { | 158 NegotiatingAuthenticatorBase::CreateChannelAuthenticator() const { |
159 DCHECK_EQ(state(), ACCEPTED); | 159 DCHECK_EQ(state(), ACCEPTED); |
160 return current_authenticator_->CreateChannelAuthenticator(); | 160 return current_authenticator_->CreateChannelAuthenticator(); |
161 } | 161 } |
162 | 162 |
163 } // namespace protocol | 163 } // namespace protocol |
164 } // namespace remoting | 164 } // namespace remoting |
OLD | NEW |