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

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

Issue 1534193004: Use std::move() instead of scoped_ptr<>::Pass(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_client_authenticator.h" 5 #include "remoting/protocol/negotiating_client_authenticator.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 13 matching lines...) Expand all
24 const std::string& shared_secret, 24 const std::string& shared_secret,
25 const std::string& authentication_tag, 25 const std::string& authentication_tag,
26 const FetchSecretCallback& fetch_secret_callback, 26 const FetchSecretCallback& fetch_secret_callback,
27 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher> token_fetcher, 27 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher> token_fetcher,
28 const std::vector<AuthenticationMethod>& methods) 28 const std::vector<AuthenticationMethod>& methods)
29 : NegotiatingAuthenticatorBase(MESSAGE_READY), 29 : NegotiatingAuthenticatorBase(MESSAGE_READY),
30 client_pairing_id_(client_pairing_id), 30 client_pairing_id_(client_pairing_id),
31 shared_secret_(shared_secret), 31 shared_secret_(shared_secret),
32 authentication_tag_(authentication_tag), 32 authentication_tag_(authentication_tag),
33 fetch_secret_callback_(fetch_secret_callback), 33 fetch_secret_callback_(fetch_secret_callback),
34 token_fetcher_(token_fetcher.Pass()), 34 token_fetcher_(std::move(token_fetcher)),
35 method_set_by_host_(false), 35 method_set_by_host_(false),
36 weak_factory_(this) { 36 weak_factory_(this) {
37 DCHECK(!methods.empty()); 37 DCHECK(!methods.empty());
38 for (std::vector<AuthenticationMethod>::const_iterator it = methods.begin(); 38 for (std::vector<AuthenticationMethod>::const_iterator it = methods.begin();
39 it != methods.end(); ++it) { 39 it != methods.end(); ++it) {
40 AddMethod(*it); 40 AddMethod(*it);
41 } 41 }
42 } 42 }
43 43
44 NegotiatingClientAuthenticator::~NegotiatingClientAuthenticator() { 44 NegotiatingClientAuthenticator::~NegotiatingClientAuthenticator() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // Include a list of supported methods. 98 // Include a list of supported methods.
99 std::stringstream supported_methods(std::stringstream::out); 99 std::stringstream supported_methods(std::stringstream::out);
100 for (std::vector<AuthenticationMethod>::iterator it = methods_.begin(); 100 for (std::vector<AuthenticationMethod>::iterator it = methods_.begin();
101 it != methods_.end(); ++it) { 101 it != methods_.end(); ++it) {
102 if (it != methods_.begin()) 102 if (it != methods_.begin())
103 supported_methods << kSupportedMethodsSeparator; 103 supported_methods << kSupportedMethodsSeparator;
104 supported_methods << it->ToString(); 104 supported_methods << it->ToString();
105 } 105 }
106 result->AddAttr(kSupportedMethodsAttributeQName, supported_methods.str()); 106 result->AddAttr(kSupportedMethodsAttributeQName, supported_methods.str());
107 state_ = WAITING_MESSAGE; 107 state_ = WAITING_MESSAGE;
108 return result.Pass(); 108 return result;
109 } 109 }
110 return GetNextMessageInternal(); 110 return GetNextMessageInternal();
111 } 111 }
112 112
113 void NegotiatingClientAuthenticator::CreateAuthenticatorForCurrentMethod( 113 void NegotiatingClientAuthenticator::CreateAuthenticatorForCurrentMethod(
114 Authenticator::State preferred_initial_state, 114 Authenticator::State preferred_initial_state,
115 const base::Closure& resume_callback) { 115 const base::Closure& resume_callback) {
116 DCHECK(current_method_.is_valid()); 116 DCHECK(current_method_.is_valid());
117 if (current_method_.type() == AuthenticationMethod::THIRD_PARTY) { 117 if (current_method_.type() == AuthenticationMethod::THIRD_PARTY) {
118 // |ThirdPartyClientAuthenticator| takes ownership of |token_fetcher_|. 118 // |ThirdPartyClientAuthenticator| takes ownership of |token_fetcher_|.
119 // The authentication method negotiation logic should guarantee that only 119 // The authentication method negotiation logic should guarantee that only
120 // one |ThirdPartyClientAuthenticator| will need to be created per session. 120 // one |ThirdPartyClientAuthenticator| will need to be created per session.
121 DCHECK(token_fetcher_); 121 DCHECK(token_fetcher_);
122 current_authenticator_.reset(new ThirdPartyClientAuthenticator( 122 current_authenticator_.reset(new ThirdPartyClientAuthenticator(
123 token_fetcher_.Pass())); 123 std::move(token_fetcher_)));
124 resume_callback.Run(); 124 resume_callback.Run();
125 } else { 125 } else {
126 DCHECK(current_method_.type() == AuthenticationMethod::SPAKE2 || 126 DCHECK(current_method_.type() == AuthenticationMethod::SPAKE2 ||
127 current_method_.type() == AuthenticationMethod::SPAKE2_PAIR); 127 current_method_.type() == AuthenticationMethod::SPAKE2_PAIR);
128 bool pairing_supported = 128 bool pairing_supported =
129 (current_method_.type() == AuthenticationMethod::SPAKE2_PAIR); 129 (current_method_.type() == AuthenticationMethod::SPAKE2_PAIR);
130 SecretFetchedCallback callback = base::Bind( 130 SecretFetchedCallback callback = base::Bind(
131 &NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret, 131 &NegotiatingClientAuthenticator::CreateV2AuthenticatorWithSecret,
132 weak_factory_.GetWeakPtr(), preferred_initial_state, resume_callback); 132 weak_factory_.GetWeakPtr(), preferred_initial_state, resume_callback);
133 fetch_secret_callback_.Run(pairing_supported, callback); 133 fetch_secret_callback_.Run(pairing_supported, callback);
(...skipping 19 matching lines...) Expand all
153 const std::string& shared_secret) { 153 const std::string& shared_secret) {
154 current_authenticator_ = V2Authenticator::CreateForClient( 154 current_authenticator_ = V2Authenticator::CreateForClient(
155 AuthenticationMethod::ApplyHashFunction( 155 AuthenticationMethod::ApplyHashFunction(
156 current_method_.hash_function(), authentication_tag_, shared_secret), 156 current_method_.hash_function(), authentication_tag_, shared_secret),
157 initial_state); 157 initial_state);
158 resume_callback.Run(); 158 resume_callback.Run();
159 } 159 }
160 160
161 } // namespace protocol 161 } // namespace protocol
162 } // namespace remoting 162 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698