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

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

Issue 2839043002: Pass u2f message callback vector as a const reference (Closed)
Patch Set: Change response callback to const ref Created 3 years, 7 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_request.h ('k') | device/u2f/u2f_sign.h » ('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 <list> 5 #include <list>
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/test/test_io_thread.h" 9 #include "base/test/test_io_thread.h"
10 #include "device/base/mock_device_client.h" 10 #include "device/base/mock_device_client.h"
(...skipping 27 matching lines...) Expand all
38 }; 38 };
39 } // namespace 39 } // namespace
40 40
41 class TestResponseCallback { 41 class TestResponseCallback {
42 public: 42 public:
43 TestResponseCallback() 43 TestResponseCallback()
44 : callback_(base::Bind(&TestResponseCallback::ReceivedCallback, 44 : callback_(base::Bind(&TestResponseCallback::ReceivedCallback,
45 base::Unretained(this))) {} 45 base::Unretained(this))) {}
46 ~TestResponseCallback() {} 46 ~TestResponseCallback() {}
47 47
48 void ReceivedCallback(U2fReturnCode status, std::vector<uint8_t> data) { 48 void ReceivedCallback(U2fReturnCode status,
49 const std::vector<uint8_t>& data) {
49 closure_.Run(); 50 closure_.Run();
50 } 51 }
51 52
52 void WaitForCallback() { 53 void WaitForCallback() {
53 closure_ = run_loop_.QuitClosure(); 54 closure_ = run_loop_.QuitClosure();
54 run_loop_.Run(); 55 run_loop_.Run();
55 } 56 }
56 57
57 U2fRequest::ResponseCallback& callback() { return callback_; } 58 U2fRequest::ResponseCallback& callback() { return callback_; }
58 59
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 c_info.usage = HidUsageAndPage(1, static_cast<HidUsageAndPage::Page>(0xf1d0)); 151 c_info.usage = HidUsageAndPage(1, static_cast<HidUsageAndPage::Page>(0xf1d0));
151 scoped_refptr<HidDeviceInfo> u2f_device = make_scoped_refptr( 152 scoped_refptr<HidDeviceInfo> u2f_device = make_scoped_refptr(
152 new HidDeviceInfo(kTestDeviceId0, 0, 0, "Test Fido Device", "123FIDO", 153 new HidDeviceInfo(kTestDeviceId0, 0, 0, "Test Fido Device", "123FIDO",
153 kHIDBusTypeUSB, c_info, 64, 64, 0)); 154 kHIDBusTypeUSB, c_info, 64, 64, 0));
154 hid_service->AddDevice(u2f_device); 155 hid_service->AddDevice(u2f_device);
155 cb.WaitForCallback(); 156 cb.WaitForCallback();
156 EXPECT_EQ(U2fRequest::State::BUSY, request.state_); 157 EXPECT_EQ(U2fRequest::State::BUSY, request.state_);
157 } 158 }
158 159
159 } // namespace device 160 } // namespace device
OLDNEW
« no previous file with comments | « device/u2f/u2f_request.h ('k') | device/u2f/u2f_sign.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698