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

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

Issue 2205693003: bluetooth: Replace old advertised uuids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Improve comments Created 4 years, 4 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_unittest.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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 // Indicates whether there is a call to Connect() ongoing. For this attribute, 282 // Indicates whether there is a call to Connect() ongoing. For this attribute,
283 // we consider a call is ongoing if none of the callbacks passed to Connect() 283 // we consider a call is ongoing if none of the callbacks passed to Connect()
284 // were called after the corresponding call to Connect(). 284 // were called after the corresponding call to Connect().
285 virtual bool IsConnecting() const = 0; 285 virtual bool IsConnecting() const = 0;
286 286
287 // Indicates whether the device can be trusted, based on device properties, 287 // Indicates whether the device can be trusted, based on device properties,
288 // such as vendor and product id. 288 // such as vendor and product id.
289 bool IsTrustable() const; 289 bool IsTrustable() const;
290 290
291 // Returns the set of UUIDs that this device supports. For classic Bluetooth 291 // Returns the set of UUIDs that this device supports.
292 // devices this data is collected from both the EIR data and SDP tables, 292 // * For classic Bluetooth devices this data is collected from both the EIR
293 // for Low Energy devices this data is collected from AD and GATT primary 293 // data and SDP tables.
294 // services, for dual mode devices this may be collected from both./ 294 // * For non-connected Low Energy Devices this returns the latest advertised
295 virtual UUIDList GetUUIDs() const = 0; 295 // UUIDs.
296 // * For connected Low Energy Devices for which services have not been
297 // discovered returns an empty list.
298 // * For connected Low Energy Devices for which services have been discovered
299 // returns the UUIDs of the device's services.
300 // * For dual mode devices this may be collected from both.
301 //
302 // Note: On ChromeOS and Linux, Bluez persists all services meaning if
303 // a device stops advertising a service this function will still return
304 // its UUID.
305 virtual UUIDList GetUUIDs() const;
296 306
297 // The received signal strength, in dBm. This field is avaliable and valid 307 // The received signal strength, in dBm. This field is avaliable and valid
298 // only during discovery. If not during discovery, or RSSI wasn't reported, 308 // only during discovery. If not during discovery, or RSSI wasn't reported,
299 // this method will return |kUnknownPower|. 309 // this method will return |kUnknownPower|.
300 virtual int16_t GetInquiryRSSI() const = 0; 310 virtual int16_t GetInquiryRSSI() const = 0;
301 311
302 // The transmitted power level. This field is avaliable only for LE devices 312 // The transmitted power level. This field is avaliable only for LE devices
303 // that include this field in AD. It is avaliable and valid only during 313 // that include this field in AD. It is avaliable and valid only during
304 // discovery. If not during discovery, or TxPower wasn't reported, this 314 // discovery. If not during discovery, or TxPower wasn't reported, this
305 // method will return |kUnknownPower|. 315 // method will return |kUnknownPower|.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 495
486 // Update the last time this device was seen. 496 // Update the last time this device was seen.
487 void UpdateTimestamp(); 497 void UpdateTimestamp();
488 498
489 // Return associated BluetoothAdapter. 499 // Return associated BluetoothAdapter.
490 BluetoothAdapter* GetAdapter() { return adapter_; } 500 BluetoothAdapter* GetAdapter() { return adapter_; }
491 501
492 protected: 502 protected:
493 // BluetoothGattConnection is a friend to call Add/RemoveGattConnection. 503 // BluetoothGattConnection is a friend to call Add/RemoveGattConnection.
494 friend BluetoothGattConnection; 504 friend BluetoothGattConnection;
505 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, GetUUIDs);
495 FRIEND_TEST_ALL_PREFIXES( 506 FRIEND_TEST_ALL_PREFIXES(
496 BluetoothTest, 507 BluetoothTest,
497 BluetoothGattConnection_DisconnectGatt_SimulateConnect); 508 BluetoothGattConnection_DisconnectGatt_SimulateConnect);
498 FRIEND_TEST_ALL_PREFIXES( 509 FRIEND_TEST_ALL_PREFIXES(
499 BluetoothTest, 510 BluetoothTest,
500 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect); 511 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect);
501 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, 512 FRIEND_TEST_ALL_PREFIXES(BluetoothTest,
502 BluetoothGattConnection_ErrorAfterConnection); 513 BluetoothGattConnection_ErrorAfterConnection);
503 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, 514 FRIEND_TEST_ALL_PREFIXES(BluetoothTest,
504 BluetoothGattConnection_DisconnectGatt_Cleanup); 515 BluetoothGattConnection_DisconnectGatt_Cleanup);
(...skipping 24 matching lines...) Expand all
529 void DidConnectGatt(); 540 void DidConnectGatt();
530 void DidFailToConnectGatt(ConnectErrorCode); 541 void DidFailToConnectGatt(ConnectErrorCode);
531 void DidDisconnectGatt(); 542 void DidDisconnectGatt();
532 543
533 // Tracks BluetoothGattConnection instances that act as a reference count 544 // Tracks BluetoothGattConnection instances that act as a reference count
534 // keeping the GATT connection open. Instances call Add/RemoveGattConnection 545 // keeping the GATT connection open. Instances call Add/RemoveGattConnection
535 // at creation & deletion. 546 // at creation & deletion.
536 void AddGattConnection(BluetoothGattConnection*); 547 void AddGattConnection(BluetoothGattConnection*);
537 void RemoveGattConnection(BluetoothGattConnection*); 548 void RemoveGattConnection(BluetoothGattConnection*);
538 549
550 void UpdateServiceUUIDs();
551
539 // Clears the list of service data. 552 // Clears the list of service data.
540 void ClearServiceData(); 553 void ClearServiceData();
541 554
542 // Set the data of a given service designated by its UUID. 555 // Set the data of a given service designated by its UUID.
543 void SetServiceData(BluetoothUUID serviceUUID, const char* buffer, 556 void SetServiceData(BluetoothUUID serviceUUID, const char* buffer,
544 size_t size); 557 size_t size);
545 558
546 // Update last_update_time_ so that the device appears as expired. 559 // Update last_update_time_ so that the device appears as expired.
547 void SetAsExpiredForTesting(); 560 void SetAsExpiredForTesting();
548 561
549 // Raw pointer to adapter owning this device object. Subclasses use platform 562 // Raw pointer to adapter owning this device object. Subclasses use platform
550 // specific pointers via adapter_. 563 // specific pointers via adapter_.
551 BluetoothAdapter* adapter_; 564 BluetoothAdapter* adapter_;
552 565
553 // Callbacks for pending success and error result of CreateGattConnection. 566 // Callbacks for pending success and error result of CreateGattConnection.
554 std::vector<GattConnectionCallback> create_gatt_connection_success_callbacks_; 567 std::vector<GattConnectionCallback> create_gatt_connection_success_callbacks_;
555 std::vector<ConnectErrorCallback> create_gatt_connection_error_callbacks_; 568 std::vector<ConnectErrorCallback> create_gatt_connection_error_callbacks_;
556 569
557 // BluetoothGattConnection objects keeping the GATT connection alive. 570 // BluetoothGattConnection objects keeping the GATT connection alive.
558 std::set<BluetoothGattConnection*> gatt_connections_; 571 std::set<BluetoothGattConnection*> gatt_connections_;
559 572
560 // Mapping from the platform-specific GATT service identifiers to 573 // Mapping from the platform-specific GATT service identifiers to
561 // BluetoothRemoteGattService objects. 574 // BluetoothRemoteGattService objects.
562 typedef base::ScopedPtrHashMap<std::string, 575 typedef base::ScopedPtrHashMap<std::string,
563 std::unique_ptr<BluetoothRemoteGattService>> 576 std::unique_ptr<BluetoothRemoteGattService>>
564 GattServiceMap; 577 GattServiceMap;
565 GattServiceMap gatt_services_; 578 GattServiceMap gatt_services_;
566 bool gatt_services_discovery_complete_; 579 bool gatt_services_discovery_complete_;
567 580
581 // Last advertised service UUIDs. Should be empty if the device is connected.
582 UUIDList advertised_uuids_;
583 // UUIDs of the device's services. Should be empty if the device is not
584 // connected or it's services have not been discovered yet.
585 UUIDList service_uuids_;
586
568 // Mapping from service UUID represented as a std::string of a bluetooth 587 // Mapping from service UUID represented as a std::string of a bluetooth
569 // service to 588 // service to
570 // the specific data. The data is stored as BinaryValue. 589 // the specific data. The data is stored as BinaryValue.
571 std::unique_ptr<base::DictionaryValue> services_data_; 590 std::unique_ptr<base::DictionaryValue> services_data_;
572 591
573 // Timestamp for when an advertisement was last seen. 592 // Timestamp for when an advertisement was last seen.
574 base::Time last_update_time_; 593 base::Time last_update_time_;
575 594
576 private: 595 private:
577 // Returns a localized string containing the device's bluetooth address and 596 // Returns a localized string containing the device's bluetooth address and
578 // a device type for display when |name_| is empty. 597 // a device type for display when |name_| is empty.
579 base::string16 GetAddressWithLocalizedDeviceTypeName() const; 598 base::string16 GetAddressWithLocalizedDeviceTypeName() const;
580 }; 599 };
581 600
582 } // namespace device 601 } // namespace device
583 602
584 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ 603 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_unittest.cc ('k') | device/bluetooth/bluetooth_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698