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

Side by Side Diff: device/u2f/u2f_register.cc

Issue 2839043002: Pass u2f message callback vector as a const reference (Closed)
Patch Set: Change response callback to const ref Created 3 years, 8 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
« no previous file with comments | « device/u2f/u2f_register.h ('k') | device/u2f/u2f_register_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
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
OLDNEW
« no previous file with comments | « device/u2f/u2f_register.h ('k') | device/u2f/u2f_register_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698