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

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

Issue 418483003: device/bluetooth: Move GATT observer methods to BluetoothAdapter::Observer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « device/bluetooth/bluetooth_adapter_chromeos.h ('k') | device/bluetooth/bluetooth_device.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "device/bluetooth/bluetooth_adapter_chromeos.h" 5 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/sys_info.h" 14 #include "base/sys_info.h"
15 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
16 #include "chromeos/dbus/bluetooth_adapter_client.h" 16 #include "chromeos/dbus/bluetooth_adapter_client.h"
17 #include "chromeos/dbus/bluetooth_agent_manager_client.h" 17 #include "chromeos/dbus/bluetooth_agent_manager_client.h"
18 #include "chromeos/dbus/bluetooth_agent_service_provider.h" 18 #include "chromeos/dbus/bluetooth_agent_service_provider.h"
19 #include "chromeos/dbus/bluetooth_device_client.h" 19 #include "chromeos/dbus/bluetooth_device_client.h"
20 #include "chromeos/dbus/bluetooth_input_client.h" 20 #include "chromeos/dbus/bluetooth_input_client.h"
21 #include "chromeos/dbus/dbus_thread_manager.h" 21 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "device/bluetooth/bluetooth_device.h" 22 #include "device/bluetooth/bluetooth_device.h"
23 #include "device/bluetooth/bluetooth_device_chromeos.h" 23 #include "device/bluetooth/bluetooth_device_chromeos.h"
24 #include "device/bluetooth/bluetooth_pairing_chromeos.h" 24 #include "device/bluetooth/bluetooth_pairing_chromeos.h"
25 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h"
26 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h"
27 #include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h"
25 #include "device/bluetooth/bluetooth_socket_chromeos.h" 28 #include "device/bluetooth/bluetooth_socket_chromeos.h"
26 #include "device/bluetooth/bluetooth_socket_thread.h" 29 #include "device/bluetooth/bluetooth_socket_thread.h"
27 #include "device/bluetooth/bluetooth_uuid.h" 30 #include "device/bluetooth/bluetooth_uuid.h"
28 #include "third_party/cros_system_api/dbus/service_constants.h" 31 #include "third_party/cros_system_api/dbus/service_constants.h"
29 32
30 using device::BluetoothAdapter; 33 using device::BluetoothAdapter;
31 using device::BluetoothDevice; 34 using device::BluetoothDevice;
32 using device::BluetoothSocket; 35 using device::BluetoothSocket;
33 using device::BluetoothUUID; 36 using device::BluetoothUUID;
34 37
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 } 748 }
746 749
747 void BluetoothAdapterChromeOS::NotifyDeviceChanged( 750 void BluetoothAdapterChromeOS::NotifyDeviceChanged(
748 BluetoothDeviceChromeOS* device) { 751 BluetoothDeviceChromeOS* device) {
749 DCHECK(device->adapter_ == this); 752 DCHECK(device->adapter_ == this);
750 753
751 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 754 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
752 DeviceChanged(this, device)); 755 DeviceChanged(this, device));
753 } 756 }
754 757
758 void BluetoothAdapterChromeOS::NotifyGattServiceAdded(
759 BluetoothRemoteGattServiceChromeOS* service) {
760 DCHECK_EQ(service->GetAdapter(), this);
761 DCHECK_EQ(
762 static_cast<BluetoothDeviceChromeOS*>(service->GetDevice())->adapter_,
763 this);
764
765 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
766 observers_,
767 GattServiceAdded(this, service->GetDevice(), service));
768 }
769
770 void BluetoothAdapterChromeOS::NotifyGattServiceRemoved(
771 BluetoothRemoteGattServiceChromeOS* service) {
772 DCHECK_EQ(service->GetAdapter(), this);
773 DCHECK_EQ(
774 static_cast<BluetoothDeviceChromeOS*>(service->GetDevice())->adapter_,
775 this);
776
777 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
778 observers_,
779 GattServiceRemoved(this, service->GetDevice(), service));
780 }
781
782 void BluetoothAdapterChromeOS::NotifyGattServiceChanged(
783 BluetoothRemoteGattServiceChromeOS* service) {
784 DCHECK_EQ(service->GetAdapter(), this);
785
786 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
787 observers_,
788 GattServiceChanged(this, service));
789 }
790
791 void BluetoothAdapterChromeOS::NotifyGattDiscoveryComplete(
792 BluetoothRemoteGattServiceChromeOS* service) {
793 DCHECK_EQ(service->GetAdapter(), this);
794
795 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
796 observers_,
797 GattDiscoveryCompleteForService(this, service));
798 }
799
800 void BluetoothAdapterChromeOS::NotifyGattCharacteristicAdded(
801 BluetoothRemoteGattCharacteristicChromeOS* characteristic) {
802 DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>(
803 characteristic->GetService())->GetAdapter(),
804 this);
805
806 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
807 observers_,
808 GattCharacteristicAdded(this, characteristic));
809 }
810
811 void BluetoothAdapterChromeOS::NotifyGattCharacteristicRemoved(
812 BluetoothRemoteGattCharacteristicChromeOS* characteristic) {
813 DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>(
814 characteristic->GetService())->GetAdapter(),
815 this);
816
817 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
818 observers_,
819 GattCharacteristicRemoved(this, characteristic));
820 }
821
822 void BluetoothAdapterChromeOS::NotifyGattDescriptorAdded(
823 BluetoothRemoteGattDescriptorChromeOS* descriptor) {
824 DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>(
825 descriptor->GetCharacteristic()->GetService())->GetAdapter(),
826 this);
827
828 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
829 observers_,
830 GattDescriptorAdded(this, descriptor));
831 }
832
833 void BluetoothAdapterChromeOS::NotifyGattDescriptorRemoved(
834 BluetoothRemoteGattDescriptorChromeOS* descriptor) {
835 DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>(
836 descriptor->GetCharacteristic()->GetService())->GetAdapter(),
837 this);
838
839 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
840 observers_,
841 GattDescriptorRemoved(this, descriptor));
842 }
843
844 void BluetoothAdapterChromeOS::NotifyGattCharacteristicValueChanged(
845 BluetoothRemoteGattCharacteristicChromeOS* characteristic,
846 const std::vector<uint8>& value) {
847 DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>(
848 characteristic->GetService())->GetAdapter(),
849 this);
850
851 FOR_EACH_OBSERVER(
852 BluetoothAdapter::Observer,
853 observers_,
854 GattCharacteristicValueChanged(this, characteristic, value));
855 }
856
857 void BluetoothAdapterChromeOS::NotifyGattDescriptorValueChanged(
858 BluetoothRemoteGattDescriptorChromeOS* descriptor,
859 const std::vector<uint8>& value) {
860 DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>(
861 descriptor->GetCharacteristic()->GetService())->GetAdapter(),
862 this);
863
864 FOR_EACH_OBSERVER(BluetoothAdapter::Observer,
865 observers_,
866 GattDescriptorValueChanged(this, descriptor, value));
867 }
868
755 void BluetoothAdapterChromeOS::OnSetDiscoverable( 869 void BluetoothAdapterChromeOS::OnSetDiscoverable(
756 const base::Closure& callback, 870 const base::Closure& callback,
757 const ErrorCallback& error_callback, 871 const ErrorCallback& error_callback,
758 bool success) { 872 bool success) {
759 // Set the discoverable_timeout property to zero so the adapter remains 873 // Set the discoverable_timeout property to zero so the adapter remains
760 // discoverable forever. 874 // discoverable forever.
761 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> 875 DBusThreadManager::Get()->GetBluetoothAdapterClient()->
762 GetProperties(object_path_)->discoverable_timeout.Set( 876 GetProperties(object_path_)->discoverable_timeout.Set(
763 0, 877 0,
764 base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted, 878 base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 1057
944 // If the queued request resulted in a pending call, then let it 1058 // If the queued request resulted in a pending call, then let it
945 // asynchonously process the remaining queued requests once the pending 1059 // asynchonously process the remaining queued requests once the pending
946 // call returns. 1060 // call returns.
947 if (discovery_request_pending_) 1061 if (discovery_request_pending_)
948 return; 1062 return;
949 } 1063 }
950 } 1064 }
951 1065
952 } // namespace chromeos 1066 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_chromeos.h ('k') | device/bluetooth/bluetooth_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698