OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/dbus/fake_bluetooth_device_client.h" | 5 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 property->ReplaceValueWithSetValue(); | 213 property->ReplaceValueWithSetValue(); |
214 } else { | 214 } else { |
215 callback.Run(false); | 215 callback.Run(false); |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 FakeBluetoothDeviceClient::FakeBluetoothDeviceClient() | 219 FakeBluetoothDeviceClient::FakeBluetoothDeviceClient() |
220 : simulation_interval_ms_(kSimulationIntervalMs), | 220 : simulation_interval_ms_(kSimulationIntervalMs), |
221 discovery_simulation_step_(0), | 221 discovery_simulation_step_(0), |
222 incoming_pairing_simulation_step_(0), | 222 incoming_pairing_simulation_step_(0), |
223 pairing_cancelled_(false) { | 223 pairing_cancelled_(false), |
| 224 connection_monitor_started_(false) { |
224 Properties* properties = new Properties(base::Bind( | 225 Properties* properties = new Properties(base::Bind( |
225 &FakeBluetoothDeviceClient::OnPropertyChanged, | 226 &FakeBluetoothDeviceClient::OnPropertyChanged, |
226 base::Unretained(this), | 227 base::Unretained(this), |
227 dbus::ObjectPath(kPairedDevicePath))); | 228 dbus::ObjectPath(kPairedDevicePath))); |
228 properties->address.ReplaceValue(kPairedDeviceAddress); | 229 properties->address.ReplaceValue(kPairedDeviceAddress); |
229 properties->bluetooth_class.ReplaceValue(kPairedDeviceClass); | 230 properties->bluetooth_class.ReplaceValue(kPairedDeviceClass); |
230 properties->name.ReplaceValue("Fake Device (Name)"); | 231 properties->name.ReplaceValue("Fake Device (Name)"); |
231 properties->alias.ReplaceValue(kPairedDeviceName); | 232 properties->alias.ReplaceValue(kPairedDeviceName); |
232 properties->paired.ReplaceValue(true); | 233 properties->paired.ReplaceValue(true); |
233 properties->trusted.ReplaceValue(true); | 234 properties->trusted.ReplaceValue(true); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 453 |
453 void FakeBluetoothDeviceClient::CancelPairing( | 454 void FakeBluetoothDeviceClient::CancelPairing( |
454 const dbus::ObjectPath& object_path, | 455 const dbus::ObjectPath& object_path, |
455 const base::Closure& callback, | 456 const base::Closure& callback, |
456 const ErrorCallback& error_callback) { | 457 const ErrorCallback& error_callback) { |
457 VLOG(1) << "CancelPairing: " << object_path.value(); | 458 VLOG(1) << "CancelPairing: " << object_path.value(); |
458 pairing_cancelled_ = true; | 459 pairing_cancelled_ = true; |
459 callback.Run(); | 460 callback.Run(); |
460 } | 461 } |
461 | 462 |
| 463 void FakeBluetoothDeviceClient::StartConnectionMonitor( |
| 464 const dbus::ObjectPath& object_path, |
| 465 const base::Closure& callback, |
| 466 const ErrorCallback& error_callback) { |
| 467 VLOG(1) << "StartConnectionMonitor: " << object_path.value(); |
| 468 connection_monitor_started_ = true; |
| 469 callback.Run(); |
| 470 } |
| 471 |
| 472 void FakeBluetoothDeviceClient::StopConnectionMonitor( |
| 473 const dbus::ObjectPath& object_path, |
| 474 const base::Closure& callback, |
| 475 const ErrorCallback& error_callback) { |
| 476 connection_monitor_started_ = false; |
| 477 callback.Run(); |
| 478 } |
462 | 479 |
463 void FakeBluetoothDeviceClient::BeginDiscoverySimulation( | 480 void FakeBluetoothDeviceClient::BeginDiscoverySimulation( |
464 const dbus::ObjectPath& adapter_path) { | 481 const dbus::ObjectPath& adapter_path) { |
465 VLOG(1) << "starting discovery simulation"; | 482 VLOG(1) << "starting discovery simulation"; |
466 | 483 |
467 discovery_simulation_step_ = 1; | 484 discovery_simulation_step_ = 1; |
468 | 485 |
469 base::MessageLoop::current()->PostDelayedTask( | 486 base::MessageLoop::current()->PostDelayedTask( |
470 FROM_HERE, | 487 FROM_HERE, |
471 base::Bind(&FakeBluetoothDeviceClient::DiscoverySimulationTimer, | 488 base::Bind(&FakeBluetoothDeviceClient::DiscoverySimulationTimer, |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 // TODO(keybuk): tear down this side of the connection | 1190 // TODO(keybuk): tear down this side of the connection |
1174 callback.Run(); | 1191 callback.Run(); |
1175 } else if (status == BluetoothProfileServiceProvider::Delegate::CANCELLED) { | 1192 } else if (status == BluetoothProfileServiceProvider::Delegate::CANCELLED) { |
1176 error_callback.Run(bluetooth_device::kErrorFailed, "Canceled"); | 1193 error_callback.Run(bluetooth_device::kErrorFailed, "Canceled"); |
1177 } else if (status == BluetoothProfileServiceProvider::Delegate::REJECTED) { | 1194 } else if (status == BluetoothProfileServiceProvider::Delegate::REJECTED) { |
1178 error_callback.Run(bluetooth_device::kErrorFailed, "Rejected"); | 1195 error_callback.Run(bluetooth_device::kErrorFailed, "Rejected"); |
1179 } | 1196 } |
1180 } | 1197 } |
1181 | 1198 |
1182 } // namespace chromeos | 1199 } // namespace chromeos |
OLD | NEW |