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

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

Issue 1842223003: Remove outdated devices from Android device chooser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased on master Created 4 years, 7 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
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
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/containers/scoped_ptr_hash_map.h" 17 #include "base/containers/scoped_ptr_hash_map.h"
18 #include "base/gtest_prod_util.h" 18 #include "base/gtest_prod_util.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/strings/string16.h" 20 #include "base/strings/string16.h"
21 #include "base/time/time.h"
21 #include "device/bluetooth/bluetooth_export.h" 22 #include "device/bluetooth/bluetooth_export.h"
22 #include "device/bluetooth/bluetooth_uuid.h" 23 #include "device/bluetooth/bluetooth_uuid.h"
23 #include "net/log/net_log.h" 24 #include "net/log/net_log.h"
24 25
25 namespace base { 26 namespace base {
26 class BinaryValue; 27 class BinaryValue;
27 } 28 }
28 29
29 namespace device { 30 namespace device {
30 31
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 virtual base::BinaryValue* GetServiceData(BluetoothUUID serviceUUID) const; 462 virtual base::BinaryValue* GetServiceData(BluetoothUUID serviceUUID) const;
462 463
463 // Returns the list UUIDs of services that have service data. 464 // Returns the list UUIDs of services that have service data.
464 virtual UUIDList GetServiceDataUUIDs() const; 465 virtual UUIDList GetServiceDataUUIDs() const;
465 466
466 // Returns the |address| in the canonical format: XX:XX:XX:XX:XX:XX, where 467 // Returns the |address| in the canonical format: XX:XX:XX:XX:XX:XX, where
467 // each 'X' is a hex digit. If the input |address| is invalid, returns an 468 // each 'X' is a hex digit. If the input |address| is invalid, returns an
468 // empty string. 469 // empty string.
469 static std::string CanonicalizeAddress(const std::string& address); 470 static std::string CanonicalizeAddress(const std::string& address);
470 471
472 // Return the timestamp for when this device was last seen.
473 base::Time GetLastUpdateTime() const { return last_update_time_; }
474
475 // Update the last time this device was seen.
476 void UpdateTimestamp();
477
471 // Return associated BluetoothAdapter. 478 // Return associated BluetoothAdapter.
472 BluetoothAdapter* GetAdapter() { return adapter_; } 479 BluetoothAdapter* GetAdapter() { return adapter_; }
473 480
474 protected: 481 protected:
475 // BluetoothGattConnection is a friend to call Add/RemoveGattConnection. 482 // BluetoothGattConnection is a friend to call Add/RemoveGattConnection.
476 friend BluetoothGattConnection; 483 friend BluetoothGattConnection;
477 FRIEND_TEST_ALL_PREFIXES( 484 FRIEND_TEST_ALL_PREFIXES(
478 BluetoothTest, 485 BluetoothTest,
479 BluetoothGattConnection_DisconnectGatt_SimulateConnect); 486 BluetoothGattConnection_DisconnectGatt_SimulateConnect);
480 FRIEND_TEST_ALL_PREFIXES( 487 FRIEND_TEST_ALL_PREFIXES(
481 BluetoothTest, 488 BluetoothTest,
482 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect); 489 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect);
483 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, 490 FRIEND_TEST_ALL_PREFIXES(BluetoothTest,
484 BluetoothGattConnection_ErrorAfterConnection); 491 BluetoothGattConnection_ErrorAfterConnection);
485 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, 492 FRIEND_TEST_ALL_PREFIXES(BluetoothTest,
486 BluetoothGattConnection_DisconnectGatt_Cleanup); 493 BluetoothGattConnection_DisconnectGatt_Cleanup);
487 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, GetDeviceName_NullName); 494 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, GetDeviceName_NullName);
495 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, RemoveOutdatedDevices);
488 496
489 BluetoothDevice(BluetoothAdapter* adapter); 497 BluetoothDevice(BluetoothAdapter* adapter);
490 498
491 // Returns the internal name of the Bluetooth device, used by GetName(). 499 // Returns the internal name of the Bluetooth device, used by GetName().
492 virtual std::string GetDeviceName() const = 0; 500 virtual std::string GetDeviceName() const = 0;
493 501
494 // Implements platform specific operations to initiate a GATT connection. 502 // Implements platform specific operations to initiate a GATT connection.
495 // Subclasses must also call DidConnectGatt, DidFailToConnectGatt, or 503 // Subclasses must also call DidConnectGatt, DidFailToConnectGatt, or
496 // DidDisconnectGatt immediately or asynchronously as the connection state 504 // DidDisconnectGatt immediately or asynchronously as the connection state
497 // changes. 505 // changes.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 std::unique_ptr<BluetoothRemoteGattService>> 551 std::unique_ptr<BluetoothRemoteGattService>>
544 GattServiceMap; 552 GattServiceMap;
545 GattServiceMap gatt_services_; 553 GattServiceMap gatt_services_;
546 bool gatt_services_discovery_complete_; 554 bool gatt_services_discovery_complete_;
547 555
548 // Mapping from service UUID represented as a std::string of a bluetooth 556 // Mapping from service UUID represented as a std::string of a bluetooth
549 // service to 557 // service to
550 // the specific data. The data is stored as BinaryValue. 558 // the specific data. The data is stored as BinaryValue.
551 std::unique_ptr<base::DictionaryValue> services_data_; 559 std::unique_ptr<base::DictionaryValue> services_data_;
552 560
561 // Timestamp for when an advertisement was last seen.
562 base::Time last_update_time_;
563
553 private: 564 private:
554 // Returns a localized string containing the device's bluetooth address and 565 // Returns a localized string containing the device's bluetooth address and
555 // a device type for display when |name_| is empty. 566 // a device type for display when |name_| is empty.
556 base::string16 GetAddressWithLocalizedDeviceTypeName() const; 567 base::string16 GetAddressWithLocalizedDeviceTypeName() const;
557 }; 568 };
558 569
559 } // namespace device 570 } // namespace device
560 571
561 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ 572 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698