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

Side by Side Diff: device/bluetooth/bluetooth_gatt_connection_chromeos.cc

Issue 1292263002: bluetooth: Create base class BluetoothDevice::CreateGattConnection impl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-adapter-
Patch Set: fix ProximityAuthBluetoothLowEnergyConnectionTest Created 5 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/bluetooth_gatt_connection_chromeos.h" 5 #include "device/bluetooth/bluetooth_gatt_connection_chromeos.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 "chromeos/dbus/dbus_thread_manager.h" 9 #include "chromeos/dbus/dbus_thread_manager.h"
10 #include "device/bluetooth/bluetooth_adapter.h" 10 #include "device/bluetooth/bluetooth_adapter.h"
11 #include "device/bluetooth/bluetooth_device.h" 11 #include "device/bluetooth/bluetooth_device.h"
12 12
13 namespace chromeos { 13 namespace chromeos {
14 14
15 BluetoothGattConnectionChromeOS::BluetoothGattConnectionChromeOS( 15 BluetoothGattConnectionChromeOS::BluetoothGattConnectionChromeOS(
16 scoped_refptr<device::BluetoothAdapter> adapter, 16 scoped_refptr<device::BluetoothAdapter> adapter,
17 const std::string& device_address, 17 const std::string& device_address,
18 const dbus::ObjectPath& object_path) 18 const dbus::ObjectPath& object_path)
19 : connected_(true), 19 : BluetoothGattConnection(adapter.get(), device_address),
20 adapter_(adapter), 20 connected_(true),
21 device_address_(device_address),
22 object_path_(object_path) { 21 object_path_(object_path) {
23 DCHECK(adapter_.get()); 22 DCHECK(adapter_.get());
24 DCHECK(!device_address_.empty()); 23 DCHECK(!device_address_.empty());
25 DCHECK(object_path_.IsValid()); 24 DCHECK(object_path_.IsValid());
26 25
27 DBusThreadManager::Get()->GetBluetoothDeviceClient()->AddObserver(this); 26 DBusThreadManager::Get()->GetBluetoothDeviceClient()->AddObserver(this);
28 } 27 }
29 28
30 BluetoothGattConnectionChromeOS::~BluetoothGattConnectionChromeOS() { 29 BluetoothGattConnectionChromeOS::~BluetoothGattConnectionChromeOS() {
31 DBusThreadManager::Get()->GetBluetoothDeviceClient()->RemoveObserver(this); 30 DBusThreadManager::Get()->GetBluetoothDeviceClient()->RemoveObserver(this);
32 Disconnect(); 31 Disconnect();
33 } 32 }
34 33
35 std::string BluetoothGattConnectionChromeOS::GetDeviceAddress() const {
36 return device_address_;
37 }
38
39 bool BluetoothGattConnectionChromeOS::IsConnected() { 34 bool BluetoothGattConnectionChromeOS::IsConnected() {
40 // Lazily determine the activity state of the connection. If already 35 // Lazily determine the activity state of the connection. If already
41 // marked as inactive, then return false. Otherwise, explicitly mark 36 // marked as inactive, then return false. Otherwise, explicitly mark
42 // |connected_| as false if the device is removed or disconnected. We do this, 37 // |connected_| as false if the device is removed or disconnected. We do this,
43 // so that if this method is called during a call to DeviceRemoved or 38 // so that if this method is called during a call to DeviceRemoved or
44 // DeviceChanged somewhere else, it returns the correct status. 39 // DeviceChanged somewhere else, it returns the correct status.
45 if (!connected_) 40 if (!connected_)
46 return false; 41 return false;
47 42
48 BluetoothDeviceClient::Properties* properties = 43 BluetoothDeviceClient::Properties* properties =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 connected_ = false; 90 connected_ = false;
96 return; 91 return;
97 } 92 }
98 93
99 if (property_name == properties->connected.name() && 94 if (property_name == properties->connected.name() &&
100 !properties->connected.value()) 95 !properties->connected.value())
101 connected_ = false; 96 connected_ = false;
102 } 97 }
103 98
104 } // namespace chromeos 99 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_gatt_connection_chromeos.h ('k') | device/bluetooth/bluetooth_low_energy_device_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698