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

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

Issue 1592733002: Clear the BLE services list on disconnect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the bluetooth/getPrimaryService.html timeout issue Created 4 years, 11 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
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_android.cc » ('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 (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 #include "device/bluetooth/bluetooth_device.h" 5 #include "device/bluetooth/bluetooth_device.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "device/bluetooth/bluetooth_adapter.h" 13 #include "device/bluetooth/bluetooth_adapter.h"
14 #include "device/bluetooth/bluetooth_gatt_connection.h" 14 #include "device/bluetooth/bluetooth_gatt_connection.h"
15 #include "device/bluetooth/bluetooth_gatt_service.h" 15 #include "device/bluetooth/bluetooth_gatt_service.h"
16 #include "grit/bluetooth_strings.h" 16 #include "grit/bluetooth_strings.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 18
19 namespace device { 19 namespace device {
20 20
21 BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter) 21 BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter)
22 : adapter_(adapter), services_data_(new base::DictionaryValue()) {} 22 : adapter_(adapter),
23 gatt_services_discovery_complete_(false),
24 services_data_(new base::DictionaryValue()) {}
23 25
24 BluetoothDevice::~BluetoothDevice() { 26 BluetoothDevice::~BluetoothDevice() {
25 DidDisconnectGatt(); 27 DidDisconnectGatt();
26 } 28 }
27 29
28 BluetoothDevice::ConnectionInfo::ConnectionInfo() 30 BluetoothDevice::ConnectionInfo::ConnectionInfo()
29 : rssi(kUnknownPower), 31 : rssi(kUnknownPower),
30 transmit_power(kUnknownPower), 32 transmit_power(kUnknownPower),
31 max_transmit_power(kUnknownPower) {} 33 max_transmit_power(kUnknownPower) {}
32 34
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 const ConnectErrorCallback& error_callback) { 209 const ConnectErrorCallback& error_callback) {
208 create_gatt_connection_success_callbacks_.push_back(callback); 210 create_gatt_connection_success_callbacks_.push_back(callback);
209 create_gatt_connection_error_callbacks_.push_back(error_callback); 211 create_gatt_connection_error_callbacks_.push_back(error_callback);
210 212
211 if (IsGattConnected()) 213 if (IsGattConnected())
212 return DidConnectGatt(); 214 return DidConnectGatt();
213 215
214 CreateGattConnectionImpl(); 216 CreateGattConnectionImpl();
215 } 217 }
216 218
219 void BluetoothDevice::SetGattServicesDiscoveryComplete(bool complete) {
220 gatt_services_discovery_complete_ = complete;
221 }
222
223 bool BluetoothDevice::IsGattServicesDiscoveryComplete() const {
224 return gatt_services_discovery_complete_;
225 }
226
217 std::vector<BluetoothGattService*> 227 std::vector<BluetoothGattService*>
218 BluetoothDevice::GetGattServices() const { 228 BluetoothDevice::GetGattServices() const {
219 std::vector<BluetoothGattService*> services; 229 std::vector<BluetoothGattService*> services;
220 for (const auto& iter : gatt_services_) 230 for (const auto& iter : gatt_services_)
221 services.push_back(iter.second); 231 services.push_back(iter.second);
222 return services; 232 return services;
223 } 233 }
224 234
225 BluetoothGattService* BluetoothDevice::GetGattService( 235 BluetoothGattService* BluetoothDevice::GetGattService(
226 const std::string& identifier) const { 236 const std::string& identifier) const {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 base::BinaryValue::CreateWithCopiedBuffer(buffer, size)); 347 base::BinaryValue::CreateWithCopiedBuffer(buffer, size));
338 } 348 }
339 349
340 void BluetoothDevice::Pair(PairingDelegate* pairing_delegate, 350 void BluetoothDevice::Pair(PairingDelegate* pairing_delegate,
341 const base::Closure& callback, 351 const base::Closure& callback,
342 const ConnectErrorCallback& error_callback) { 352 const ConnectErrorCallback& error_callback) {
343 NOTREACHED(); 353 NOTREACHED();
344 } 354 }
345 355
346 } // namespace device 356 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698