| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ |
| 7 | 7 |
| 8 #include <hash_set> | 8 #include <hash_set> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class BluetoothSocketThread; | 34 class BluetoothSocketThread; |
| 35 | 35 |
| 36 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterWin | 36 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterWin |
| 37 : public BluetoothAdapter, | 37 : public BluetoothAdapter, |
| 38 public BluetoothTaskManagerWin::Observer { | 38 public BluetoothTaskManagerWin::Observer { |
| 39 public: | 39 public: |
| 40 static base::WeakPtr<BluetoothAdapter> CreateAdapter( | 40 static base::WeakPtr<BluetoothAdapter> CreateAdapter( |
| 41 const InitCallback& init_callback); | 41 const InitCallback& init_callback); |
| 42 | 42 |
| 43 // BluetoothAdapter: | 43 // BluetoothAdapter: |
| 44 virtual std::string GetAddress() const override; | 44 std::string GetAddress() const override; |
| 45 virtual std::string GetName() const override; | 45 std::string GetName() const override; |
| 46 virtual void SetName(const std::string& name, | 46 void SetName(const std::string& name, |
| 47 const base::Closure& callback, |
| 48 const ErrorCallback& error_callback) override; |
| 49 bool IsInitialized() const override; |
| 50 bool IsPresent() const override; |
| 51 bool IsPowered() const override; |
| 52 void SetPowered(bool discoverable, |
| 53 const base::Closure& callback, |
| 54 const ErrorCallback& error_callback) override; |
| 55 bool IsDiscoverable() const override; |
| 56 void SetDiscoverable(bool discoverable, |
| 47 const base::Closure& callback, | 57 const base::Closure& callback, |
| 48 const ErrorCallback& error_callback) override; | 58 const ErrorCallback& error_callback) override; |
| 49 virtual bool IsInitialized() const override; | 59 bool IsDiscovering() const override; |
| 50 virtual bool IsPresent() const override; | 60 void CreateRfcommService( |
| 51 virtual bool IsPowered() const override; | |
| 52 virtual void SetPowered( | |
| 53 bool discoverable, | |
| 54 const base::Closure& callback, | |
| 55 const ErrorCallback& error_callback) override; | |
| 56 virtual bool IsDiscoverable() const override; | |
| 57 virtual void SetDiscoverable( | |
| 58 bool discoverable, | |
| 59 const base::Closure& callback, | |
| 60 const ErrorCallback& error_callback) override; | |
| 61 virtual bool IsDiscovering() const override; | |
| 62 virtual void CreateRfcommService( | |
| 63 const BluetoothUUID& uuid, | 61 const BluetoothUUID& uuid, |
| 64 const ServiceOptions& options, | 62 const ServiceOptions& options, |
| 65 const CreateServiceCallback& callback, | 63 const CreateServiceCallback& callback, |
| 66 const CreateServiceErrorCallback& error_callback) override; | 64 const CreateServiceErrorCallback& error_callback) override; |
| 67 virtual void CreateL2capService( | 65 void CreateL2capService( |
| 68 const BluetoothUUID& uuid, | 66 const BluetoothUUID& uuid, |
| 69 const ServiceOptions& options, | 67 const ServiceOptions& options, |
| 70 const CreateServiceCallback& callback, | 68 const CreateServiceCallback& callback, |
| 71 const CreateServiceErrorCallback& error_callback) override; | 69 const CreateServiceErrorCallback& error_callback) override; |
| 72 void RegisterAudioSink( | 70 void RegisterAudioSink( |
| 73 const BluetoothAudioSink::Options& options, | 71 const BluetoothAudioSink::Options& options, |
| 74 const AcquiredCallback& callback, | 72 const AcquiredCallback& callback, |
| 75 const BluetoothAudioSink::ErrorCallback& error_callback) override; | 73 const BluetoothAudioSink::ErrorCallback& error_callback) override; |
| 76 | 74 |
| 77 // BluetoothTaskManagerWin::Observer override | 75 // BluetoothTaskManagerWin::Observer override |
| 78 virtual void AdapterStateChanged( | 76 void AdapterStateChanged( |
| 79 const BluetoothTaskManagerWin::AdapterState& state) override; | 77 const BluetoothTaskManagerWin::AdapterState& state) override; |
| 80 virtual void DiscoveryStarted(bool success) override; | 78 void DiscoveryStarted(bool success) override; |
| 81 virtual void DiscoveryStopped() override; | 79 void DiscoveryStopped() override; |
| 82 virtual void DevicesPolled(const ScopedVector< | 80 void DevicesPolled(const ScopedVector<BluetoothTaskManagerWin::DeviceState>& |
| 83 BluetoothTaskManagerWin::DeviceState>& devices) override; | 81 devices) override; |
| 84 | 82 |
| 85 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner() const { | 83 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner() const { |
| 86 return ui_task_runner_; | 84 return ui_task_runner_; |
| 87 } | 85 } |
| 88 const scoped_refptr<BluetoothSocketThread>& socket_thread() const { | 86 const scoped_refptr<BluetoothSocketThread>& socket_thread() const { |
| 89 return socket_thread_; | 87 return socket_thread_; |
| 90 } | 88 } |
| 91 | 89 |
| 92 protected: | 90 protected: |
| 93 // BluetoothAdapter: | 91 // BluetoothAdapter: |
| 94 virtual void RemovePairingDelegateInternal( | 92 void RemovePairingDelegateInternal( |
| 95 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; | 93 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; |
| 96 | 94 |
| 97 private: | 95 private: |
| 98 friend class BluetoothAdapterWinTest; | 96 friend class BluetoothAdapterWinTest; |
| 99 | 97 |
| 100 enum DiscoveryStatus { | 98 enum DiscoveryStatus { |
| 101 NOT_DISCOVERING, | 99 NOT_DISCOVERING, |
| 102 DISCOVERY_STARTING, | 100 DISCOVERY_STARTING, |
| 103 DISCOVERING, | 101 DISCOVERING, |
| 104 DISCOVERY_STOPPING | 102 DISCOVERY_STOPPING |
| 105 }; | 103 }; |
| 106 | 104 |
| 107 explicit BluetoothAdapterWin(const InitCallback& init_callback); | 105 explicit BluetoothAdapterWin(const InitCallback& init_callback); |
| 108 virtual ~BluetoothAdapterWin(); | 106 ~BluetoothAdapterWin() override; |
| 109 | 107 |
| 110 // BluetoothAdapter: | 108 // BluetoothAdapter: |
| 111 virtual void AddDiscoverySession( | 109 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, |
| 112 BluetoothDiscoveryFilter* discovery_filter, | 110 const base::Closure& callback, |
| 113 const base::Closure& callback, | 111 const ErrorCallback& error_callback) override; |
| 114 const ErrorCallback& error_callback) override; | 112 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, |
| 115 virtual void RemoveDiscoverySession( | 113 const base::Closure& callback, |
| 116 BluetoothDiscoveryFilter* discovery_filter, | 114 const ErrorCallback& error_callback) override; |
| 117 const base::Closure& callback, | 115 void SetDiscoveryFilter(scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, |
| 118 const ErrorCallback& error_callback) override; | 116 const base::Closure& callback, |
| 119 virtual void SetDiscoveryFilter( | 117 const ErrorCallback& error_callback) override; |
| 120 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, | |
| 121 const base::Closure& callback, | |
| 122 const ErrorCallback& error_callback) override; | |
| 123 | 118 |
| 124 void Init(); | 119 void Init(); |
| 125 void InitForTest( | 120 void InitForTest( |
| 126 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | 121 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
| 127 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner); | 122 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner); |
| 128 | 123 |
| 129 void MaybePostStartDiscoveryTask(); | 124 void MaybePostStartDiscoveryTask(); |
| 130 void MaybePostStopDiscoveryTask(); | 125 void MaybePostStopDiscoveryTask(); |
| 131 | 126 |
| 132 InitCallback init_callback_; | 127 InitCallback init_callback_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 151 // NOTE: This should remain the last member so it'll be destroyed and | 146 // NOTE: This should remain the last member so it'll be destroyed and |
| 152 // invalidate its weak pointers before any other members are destroyed. | 147 // invalidate its weak pointers before any other members are destroyed. |
| 153 base::WeakPtrFactory<BluetoothAdapterWin> weak_ptr_factory_; | 148 base::WeakPtrFactory<BluetoothAdapterWin> weak_ptr_factory_; |
| 154 | 149 |
| 155 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterWin); | 150 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterWin); |
| 156 }; | 151 }; |
| 157 | 152 |
| 158 } // namespace device | 153 } // namespace device |
| 159 | 154 |
| 160 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ | 155 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ |
| OLD | NEW |