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

Side by Side Diff: components/proximity_auth/remote_device_life_cycle_impl.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/proximity_auth/remote_device_life_cycle_impl.h" 5 #include "components/proximity_auth/remote_device_life_cycle_impl.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/location.h" 10 #include "base/location.h"
9 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
10 #include "base/time/default_tick_clock.h" 12 #include "base/time/default_tick_clock.h"
11 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h" 13 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h"
12 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h " 14 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h "
13 #include "components/proximity_auth/bluetooth_connection.h" 15 #include "components/proximity_auth/bluetooth_connection.h"
14 #include "components/proximity_auth/bluetooth_connection_finder.h" 16 #include "components/proximity_auth/bluetooth_connection_finder.h"
15 #include "components/proximity_auth/bluetooth_throttler_impl.h" 17 #include "components/proximity_auth/bluetooth_throttler_impl.h"
16 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" 18 #include "components/proximity_auth/cryptauth/secure_message_delegate.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 connection_finder_ = CreateConnectionFinder(); 113 connection_finder_ = CreateConnectionFinder();
112 connection_finder_->Find( 114 connection_finder_->Find(
113 base::Bind(&RemoteDeviceLifeCycleImpl::OnConnectionFound, 115 base::Bind(&RemoteDeviceLifeCycleImpl::OnConnectionFound,
114 weak_ptr_factory_.GetWeakPtr())); 116 weak_ptr_factory_.GetWeakPtr()));
115 TransitionToState(RemoteDeviceLifeCycle::State::FINDING_CONNECTION); 117 TransitionToState(RemoteDeviceLifeCycle::State::FINDING_CONNECTION);
116 } 118 }
117 119
118 void RemoteDeviceLifeCycleImpl::OnConnectionFound( 120 void RemoteDeviceLifeCycleImpl::OnConnectionFound(
119 scoped_ptr<Connection> connection) { 121 scoped_ptr<Connection> connection) {
120 DCHECK(state_ == RemoteDeviceLifeCycle::State::FINDING_CONNECTION); 122 DCHECK(state_ == RemoteDeviceLifeCycle::State::FINDING_CONNECTION);
121 connection_ = connection.Pass(); 123 connection_ = std::move(connection);
122 authenticator_ = CreateAuthenticator(); 124 authenticator_ = CreateAuthenticator();
123 authenticator_->Authenticate( 125 authenticator_->Authenticate(
124 base::Bind(&RemoteDeviceLifeCycleImpl::OnAuthenticationResult, 126 base::Bind(&RemoteDeviceLifeCycleImpl::OnAuthenticationResult,
125 weak_ptr_factory_.GetWeakPtr())); 127 weak_ptr_factory_.GetWeakPtr()));
126 TransitionToState(RemoteDeviceLifeCycle::State::AUTHENTICATING); 128 TransitionToState(RemoteDeviceLifeCycle::State::AUTHENTICATING);
127 } 129 }
128 130
129 void RemoteDeviceLifeCycleImpl::OnAuthenticationResult( 131 void RemoteDeviceLifeCycleImpl::OnAuthenticationResult(
130 Authenticator::Result result, 132 Authenticator::Result result,
131 scoped_ptr<SecureContext> secure_context) { 133 scoped_ptr<SecureContext> secure_context) {
132 DCHECK(state_ == RemoteDeviceLifeCycle::State::AUTHENTICATING); 134 DCHECK(state_ == RemoteDeviceLifeCycle::State::AUTHENTICATING);
133 authenticator_.reset(); 135 authenticator_.reset();
134 if (result != Authenticator::Result::SUCCESS) { 136 if (result != Authenticator::Result::SUCCESS) {
135 PA_LOG(WARNING) << "Waiting " << kAuthenticationRecoveryTimeSeconds 137 PA_LOG(WARNING) << "Waiting " << kAuthenticationRecoveryTimeSeconds
136 << " seconds to retry after authentication failure."; 138 << " seconds to retry after authentication failure.";
137 connection_->Disconnect(); 139 connection_->Disconnect();
138 authentication_recovery_timer_.Start( 140 authentication_recovery_timer_.Start(
139 FROM_HERE, 141 FROM_HERE,
140 base::TimeDelta::FromSeconds(kAuthenticationRecoveryTimeSeconds), this, 142 base::TimeDelta::FromSeconds(kAuthenticationRecoveryTimeSeconds), this,
141 &RemoteDeviceLifeCycleImpl::FindConnection); 143 &RemoteDeviceLifeCycleImpl::FindConnection);
142 TransitionToState(RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED); 144 TransitionToState(RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED);
143 return; 145 return;
144 } 146 }
145 147
146 // Create the MessengerImpl asynchronously. |messenger_| registers itself as 148 // Create the MessengerImpl asynchronously. |messenger_| registers itself as
147 // an observer of |connection_|, so creating it synchronously would trigger 149 // an observer of |connection_|, so creating it synchronously would trigger
148 // |OnSendCompleted()| as an observer call for |messenger_|. 150 // |OnSendCompleted()| as an observer call for |messenger_|.
149 secure_context_ = secure_context.Pass(); 151 secure_context_ = std::move(secure_context);
150 base::ThreadTaskRunnerHandle::Get()->PostTask( 152 base::ThreadTaskRunnerHandle::Get()->PostTask(
151 FROM_HERE, base::Bind(&RemoteDeviceLifeCycleImpl::CreateMessenger, 153 FROM_HERE, base::Bind(&RemoteDeviceLifeCycleImpl::CreateMessenger,
152 weak_ptr_factory_.GetWeakPtr())); 154 weak_ptr_factory_.GetWeakPtr()));
153 } 155 }
154 156
155 void RemoteDeviceLifeCycleImpl::CreateMessenger() { 157 void RemoteDeviceLifeCycleImpl::CreateMessenger() {
156 DCHECK(state_ == RemoteDeviceLifeCycle::State::AUTHENTICATING); 158 DCHECK(state_ == RemoteDeviceLifeCycle::State::AUTHENTICATING);
157 DCHECK(secure_context_); 159 DCHECK(secure_context_);
158 messenger_.reset( 160 messenger_.reset(
159 new MessengerImpl(connection_.Pass(), secure_context_.Pass())); 161 new MessengerImpl(std::move(connection_), std::move(secure_context_)));
160 messenger_->AddObserver(this); 162 messenger_->AddObserver(this);
161 163
162 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); 164 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED);
163 } 165 }
164 166
165 void RemoteDeviceLifeCycleImpl::OnDisconnected() { 167 void RemoteDeviceLifeCycleImpl::OnDisconnected() {
166 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); 168 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED);
167 messenger_.reset(); 169 messenger_.reset();
168 FindConnection(); 170 FindConnection();
169 } 171 }
170 172
171 } // namespace proximity_auth 173 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698