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

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

Issue 1565773002: Clear the BLE services list on disconnect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add requested improvements to the unittest 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_adapter_bluez.cc ('k') | device/bluetooth/bluetooth_device.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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // the underlying connection gets terminated, either due to a call to 417 // the underlying connection gets terminated, either due to a call to
418 // BluetoothDevice::Disconnect or other unexpected circumstances, the 418 // BluetoothDevice::Disconnect or other unexpected circumstances, the
419 // returned BluetoothGattConnection will be automatically marked as inactive. 419 // returned BluetoothGattConnection will be automatically marked as inactive.
420 // To monitor the state of the connection, observe the 420 // To monitor the state of the connection, observe the
421 // BluetoothAdapter::Observer::DeviceChanged method. 421 // BluetoothAdapter::Observer::DeviceChanged method.
422 typedef base::Callback<void(scoped_ptr<BluetoothGattConnection>)> 422 typedef base::Callback<void(scoped_ptr<BluetoothGattConnection>)>
423 GattConnectionCallback; 423 GattConnectionCallback;
424 virtual void CreateGattConnection(const GattConnectionCallback& callback, 424 virtual void CreateGattConnection(const GattConnectionCallback& callback,
425 const ConnectErrorCallback& error_callback); 425 const ConnectErrorCallback& error_callback);
426 426
427 // Set the gatt services discovery complete flag for this device.
ortuno 2016/01/13 18:22:02 nit: comment should be descriptive rather than imp
428 void SetGattServicesDiscoveryComplete(bool complete);
429
430 // Indicates whether service discovery is complete for this device.
431 bool IsGattServicesDiscoveryComplete() const;
432
427 // Returns the list of discovered GATT services. 433 // Returns the list of discovered GATT services.
428 virtual std::vector<BluetoothGattService*> GetGattServices() const; 434 virtual std::vector<BluetoothGattService*> GetGattServices() const;
429 435
430 // Returns the GATT service with device-specific identifier |identifier|. 436 // Returns the GATT service with device-specific identifier |identifier|.
431 // Returns NULL, if no such service exists. 437 // Returns NULL, if no such service exists.
432 virtual BluetoothGattService* GetGattService( 438 virtual BluetoothGattService* GetGattService(
433 const std::string& identifier) const; 439 const std::string& identifier) const;
434 440
435 // Returns service data of a service given its UUID. 441 // Returns service data of a service given its UUID.
436 virtual base::BinaryValue* GetServiceData(BluetoothUUID serviceUUID) const; 442 virtual base::BinaryValue* GetServiceData(BluetoothUUID serviceUUID) const;
(...skipping 10 matching lines...) Expand all
447 // BluetoothGattConnection is a friend to call Add/RemoveGattConnection. 453 // BluetoothGattConnection is a friend to call Add/RemoveGattConnection.
448 friend BluetoothGattConnection; 454 friend BluetoothGattConnection;
449 FRIEND_TEST_ALL_PREFIXES( 455 FRIEND_TEST_ALL_PREFIXES(
450 BluetoothTest, 456 BluetoothTest,
451 BluetoothGattConnection_DisconnectGatt_SimulateConnect); 457 BluetoothGattConnection_DisconnectGatt_SimulateConnect);
452 FRIEND_TEST_ALL_PREFIXES( 458 FRIEND_TEST_ALL_PREFIXES(
453 BluetoothTest, 459 BluetoothTest,
454 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect); 460 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect);
455 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, 461 FRIEND_TEST_ALL_PREFIXES(BluetoothTest,
456 BluetoothGattConnection_ErrorAfterConnection); 462 BluetoothGattConnection_ErrorAfterConnection);
463 FRIEND_TEST_ALL_PREFIXES(BluetoothTest,
464 BluetoothGattConnection_DisconnectGatt_Cleanup);
457 465
458 BluetoothDevice(BluetoothAdapter* adapter); 466 BluetoothDevice(BluetoothAdapter* adapter);
459 467
460 // Returns the internal name of the Bluetooth device, used by GetName(). 468 // Returns the internal name of the Bluetooth device, used by GetName().
461 virtual std::string GetDeviceName() const = 0; 469 virtual std::string GetDeviceName() const = 0;
462 470
463 // Implements platform specific operations to initiate a GATT connection. 471 // Implements platform specific operations to initiate a GATT connection.
464 // Subclasses must also call DidConnectGatt, DidFailToConnectGatt, or 472 // Subclasses must also call DidConnectGatt, DidFailToConnectGatt, or
465 // DidDisconnectGatt immediately or asynchronously as the connection state 473 // DidDisconnectGatt immediately or asynchronously as the connection state
466 // changes. 474 // changes.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 std::vector<ConnectErrorCallback> create_gatt_connection_error_callbacks_; 512 std::vector<ConnectErrorCallback> create_gatt_connection_error_callbacks_;
505 513
506 // BluetoothGattConnection objects keeping the GATT connection alive. 514 // BluetoothGattConnection objects keeping the GATT connection alive.
507 std::set<BluetoothGattConnection*> gatt_connections_; 515 std::set<BluetoothGattConnection*> gatt_connections_;
508 516
509 // Mapping from the platform-specific GATT service identifiers to 517 // Mapping from the platform-specific GATT service identifiers to
510 // BluetoothGattService objects. 518 // BluetoothGattService objects.
511 typedef base::ScopedPtrHashMap<std::string, scoped_ptr<BluetoothGattService>> 519 typedef base::ScopedPtrHashMap<std::string, scoped_ptr<BluetoothGattService>>
512 GattServiceMap; 520 GattServiceMap;
513 GattServiceMap gatt_services_; 521 GattServiceMap gatt_services_;
522 bool gatt_services_discovery_complete_;
514 523
515 // Mapping from service UUID represented as a std::string of a bluetooth 524 // Mapping from service UUID represented as a std::string of a bluetooth
516 // service to 525 // service to
517 // the specific data. The data is stored as BinaryValue. 526 // the specific data. The data is stored as BinaryValue.
518 scoped_ptr<base::DictionaryValue> services_data_; 527 scoped_ptr<base::DictionaryValue> services_data_;
519 528
520 private: 529 private:
521 // Returns a localized string containing the device's bluetooth address and 530 // Returns a localized string containing the device's bluetooth address and
522 // a device type for display when |name_| is empty. 531 // a device type for display when |name_| is empty.
523 base::string16 GetAddressWithLocalizedDeviceTypeName() const; 532 base::string16 GetAddressWithLocalizedDeviceTypeName() const;
524 }; 533 };
525 534
526 } // namespace device 535 } // namespace device
527 536
528 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ 537 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_bluez.cc ('k') | device/bluetooth/bluetooth_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698