OLD | NEW |
---|---|
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 "device/bluetooth/test/bluetooth_test.h" | 5 #include "device/bluetooth/test/bluetooth_test.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "device/bluetooth/bluetooth_adapter.h" | 10 #include "device/bluetooth/bluetooth_adapter.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 void BluetoothTestBase::Callback() { | 34 void BluetoothTestBase::Callback() { |
35 ++callback_count_; | 35 ++callback_count_; |
36 } | 36 } |
37 | 37 |
38 void BluetoothTestBase::DiscoverySessionCallback( | 38 void BluetoothTestBase::DiscoverySessionCallback( |
39 scoped_ptr<BluetoothDiscoverySession> discovery_session) { | 39 scoped_ptr<BluetoothDiscoverySession> discovery_session) { |
40 ++callback_count_; | 40 ++callback_count_; |
41 discovery_sessions_.push_back(discovery_session.release()); | 41 discovery_sessions_.push_back(discovery_session.release()); |
42 } | 42 } |
43 | 43 |
44 void BluetoothTestBase::GattConnectionCallback( | |
45 scoped_ptr<BluetoothGattConnection> connection) { | |
46 ++callback_count_; | |
47 gatt_connections_.push_back(connection.release()); | |
48 } | |
49 | |
44 void BluetoothTestBase::ErrorCallback() { | 50 void BluetoothTestBase::ErrorCallback() { |
45 ++error_callback_count_; | 51 ++error_callback_count_; |
46 } | 52 } |
47 | 53 |
54 void BluetoothTestBase::ConnectErrorCallback( | |
55 enum BluetoothDevice::ConnectErrorCode error_code) { | |
56 ++error_callback_count_; | |
57 last_connect_error_code_ = error_code; | |
58 } | |
59 | |
48 base::Closure BluetoothTestBase::GetCallback() { | 60 base::Closure BluetoothTestBase::GetCallback() { |
49 return base::Bind(&BluetoothTestBase::Callback, base::Unretained(this)); | 61 return base::Bind(&BluetoothTestBase::Callback, base::Unretained(this)); |
50 } | 62 } |
51 | 63 |
52 BluetoothAdapter::DiscoverySessionCallback | 64 BluetoothAdapter::DiscoverySessionCallback |
53 BluetoothTestBase::GetDiscoverySessionCallback() { | 65 BluetoothTestBase::GetDiscoverySessionCallback() { |
54 return base::Bind(&BluetoothTestBase::DiscoverySessionCallback, | 66 return base::Bind(&BluetoothTestBase::DiscoverySessionCallback, |
55 base::Unretained(this)); | 67 base::Unretained(this)); |
56 } | 68 } |
57 | 69 |
70 BluetoothDevice::GattConnectionCallback | |
71 BluetoothTestBase::GetGattConnectionCallback() { | |
72 return base::Bind(&BluetoothTestBase::GattConnectionCallback, | |
73 base::Unretained(this)); | |
Jeffrey Yasskin
2015/08/20 21:35:14
Generally comment why base::Unretained calls are c
scheib
2015/09/13 02:41:01
Done - moved to weak pointers.
| |
74 } | |
75 | |
58 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback() { | 76 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback() { |
59 return base::Bind(&BluetoothTestBase::ErrorCallback, base::Unretained(this)); | 77 return base::Bind(&BluetoothTestBase::ErrorCallback, base::Unretained(this)); |
60 } | 78 } |
61 | 79 |
80 BluetoothDevice::ConnectErrorCallback | |
81 BluetoothTestBase::GetConnectErrorCallback() { | |
82 return base::Bind(&BluetoothTestBase::ConnectErrorCallback, | |
83 base::Unretained(this)); | |
84 } | |
85 | |
62 } // namespace device | 86 } // namespace device |
OLD | NEW |