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/dbus/bluetooth_le_advertising_manager_client.h" | 5 #include "device/bluetooth/dbus/bluetooth_le_advertising_manager_client.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/macros.h" | 9 #include "base/macros.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 dbus::ObjectProxy* object_proxy = | 102 dbus::ObjectProxy* object_proxy = |
103 object_manager_->GetObjectProxy(manager_object_path); | 103 object_manager_->GetObjectProxy(manager_object_path); |
104 object_proxy->CallMethodWithErrorCallback( | 104 object_proxy->CallMethodWithErrorCallback( |
105 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 105 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
106 base::Bind(&BluetoothAdvertisementManagerClientImpl::OnSuccess, | 106 base::Bind(&BluetoothAdvertisementManagerClientImpl::OnSuccess, |
107 weak_ptr_factory_.GetWeakPtr(), callback), | 107 weak_ptr_factory_.GetWeakPtr(), callback), |
108 base::Bind(&BluetoothAdvertisementManagerClientImpl::OnError, | 108 base::Bind(&BluetoothAdvertisementManagerClientImpl::OnError, |
109 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 109 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
110 } | 110 } |
111 | 111 |
112 void SetAdvertisingInterval(const dbus::ObjectPath& manager_object_path, | |
113 uint16_t min_interval_ms, | |
114 uint16_t max_interval_ms, | |
115 const base::Closure& callback, | |
116 const ErrorCallback& error_callback) override { | |
117 // TODO(rkc): Replace the string "SetAdvertisingInterval" with the correct | |
118 // constant in service_constants.h once cros_system_api DEPS are rolled. | |
ortuno
2016/09/22 03:02:25
nit: There are a lot of TODO(username) that are le
| |
119 dbus::MethodCall method_call( | |
120 bluetooth_advertising_manager::kBluetoothAdvertisingManagerInterface, | |
121 "SetAdvertisingIntervals"); | |
122 | |
123 dbus::MessageWriter writer(&method_call); | |
124 writer.AppendUint16(min_interval_ms); | |
125 writer.AppendUint16(max_interval_ms); | |
126 | |
127 DCHECK(object_manager_); | |
128 dbus::ObjectProxy* object_proxy = | |
129 object_manager_->GetObjectProxy(manager_object_path); | |
130 object_proxy->CallMethodWithErrorCallback( | |
131 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
132 base::Bind(&BluetoothAdvertisementManagerClientImpl::OnSuccess, | |
133 weak_ptr_factory_.GetWeakPtr(), callback), | |
134 base::Bind(&BluetoothAdvertisementManagerClientImpl::OnError, | |
135 weak_ptr_factory_.GetWeakPtr(), error_callback)); | |
136 } | |
137 | |
112 protected: | 138 protected: |
113 void Init(dbus::Bus* bus) override { | 139 void Init(dbus::Bus* bus) override { |
114 DCHECK(bus); | 140 DCHECK(bus); |
115 object_manager_ = bus->GetObjectManager( | 141 object_manager_ = bus->GetObjectManager( |
116 bluetooth_object_manager::kBluetoothObjectManagerServiceName, | 142 bluetooth_object_manager::kBluetoothObjectManagerServiceName, |
117 dbus::ObjectPath( | 143 dbus::ObjectPath( |
118 bluetooth_object_manager::kBluetoothObjectManagerServicePath)); | 144 bluetooth_object_manager::kBluetoothObjectManagerServicePath)); |
119 object_manager_->RegisterInterface( | 145 object_manager_->RegisterInterface( |
120 bluetooth_advertising_manager::kBluetoothAdvertisingManagerInterface, | 146 bluetooth_advertising_manager::kBluetoothAdvertisingManagerInterface, |
121 this); | 147 this); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 BluetoothLEAdvertisingManagerClient::BluetoothLEAdvertisingManagerClient() {} | 205 BluetoothLEAdvertisingManagerClient::BluetoothLEAdvertisingManagerClient() {} |
180 | 206 |
181 BluetoothLEAdvertisingManagerClient::~BluetoothLEAdvertisingManagerClient() {} | 207 BluetoothLEAdvertisingManagerClient::~BluetoothLEAdvertisingManagerClient() {} |
182 | 208 |
183 BluetoothLEAdvertisingManagerClient* | 209 BluetoothLEAdvertisingManagerClient* |
184 BluetoothLEAdvertisingManagerClient::Create() { | 210 BluetoothLEAdvertisingManagerClient::Create() { |
185 return new BluetoothAdvertisementManagerClientImpl(); | 211 return new BluetoothAdvertisementManagerClientImpl(); |
186 } | 212 } |
187 | 213 |
188 } // namespace bluez | 214 } // namespace bluez |
OLD | NEW |