Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "u2f_register.h" | 5 #include "u2f_register.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 | 8 |
| 9 namespace device { | 9 namespace device { |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 void U2fRegister::TryDevice() { | 32 void U2fRegister::TryDevice() { |
| 33 DCHECK(current_device_); | 33 DCHECK(current_device_); |
| 34 | 34 |
| 35 current_device_->Register( | 35 current_device_->Register( |
| 36 app_param_, challenge_hash_, | 36 app_param_, challenge_hash_, |
| 37 base::Bind(&U2fRegister::OnTryDevice, weak_factory_.GetWeakPtr())); | 37 base::Bind(&U2fRegister::OnTryDevice, weak_factory_.GetWeakPtr())); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void U2fRegister::OnTryDevice(U2fReturnCode return_code, | 40 void U2fRegister::OnTryDevice(U2fReturnCode return_code, |
| 41 std::vector<uint8_t> response_data) { | 41 const std::vector<uint8_t>& response_data) { |
| 42 switch (return_code) { | 42 switch (return_code) { |
| 43 case U2fReturnCode::SUCCESS: | 43 case U2fReturnCode::SUCCESS: |
| 44 state_ = State::COMPLETE; | 44 state_ = State::COMPLETE; |
| 45 cb_.Run(return_code, response_data); | 45 cb_.Run(return_code, response_data); |
|
Reilly Grant (use Gerrit)
2017/04/26 00:11:02
U2fRequest::ResponseCallback should also be update
piperc
2017/04/26 00:19:55
Will the caller need to do a move of the data befo
Reilly Grant (use Gerrit)
2017/04/26 00:28:00
The function bound to |cb_| is called from inside
Casey Piper
2017/04/26 00:39:05
Right. Makes sense.
Done.
| |
| 46 break; | 46 break; |
| 47 case U2fReturnCode::CONDITIONS_NOT_SATISFIED: | 47 case U2fReturnCode::CONDITIONS_NOT_SATISFIED: |
| 48 // Waiting for user touch, move on and try this device later | 48 // Waiting for user touch, move on and try this device later |
| 49 state_ = State::IDLE; | 49 state_ = State::IDLE; |
| 50 Transition(); | 50 Transition(); |
| 51 break; | 51 break; |
| 52 default: | 52 default: |
| 53 state_ = State::IDLE; | 53 state_ = State::IDLE; |
| 54 // An error has occured, quit trying this device | 54 // An error has occured, quit trying this device |
| 55 current_device_ = nullptr; | 55 current_device_ = nullptr; |
| 56 Transition(); | 56 Transition(); |
| 57 break; | 57 break; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace device | 61 } // namespace device |
| OLD | NEW |