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

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

Issue 1842223003: Remove outdated devices from Android device chooser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted two small unnecessary changes. Created 4 years, 5 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_mac.h » ('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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "device/bluetooth/bluetooth_adapter.h" 16 #include "device/bluetooth/bluetooth_adapter.h"
16 #include "device/bluetooth/bluetooth_gatt_connection.h" 17 #include "device/bluetooth/bluetooth_gatt_connection.h"
17 #include "device/bluetooth/bluetooth_remote_gatt_service.h" 18 #include "device/bluetooth/bluetooth_remote_gatt_service.h"
18 #include "grit/bluetooth_strings.h" 19 #include "grit/bluetooth_strings.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 21
21 namespace device { 22 namespace device {
22 23
23 BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter) 24 BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter)
24 : adapter_(adapter), 25 : adapter_(adapter),
25 gatt_services_discovery_complete_(false), 26 gatt_services_discovery_complete_(false),
26 services_data_(new base::DictionaryValue()) {} 27 services_data_(new base::DictionaryValue()),
28 last_update_time_(base::Time()) {}
27 29
28 BluetoothDevice::~BluetoothDevice() { 30 BluetoothDevice::~BluetoothDevice() {
29 for (BluetoothGattConnection* connection : gatt_connections_) { 31 for (BluetoothGattConnection* connection : gatt_connections_) {
30 connection->InvalidateConnectionReference(); 32 connection->InvalidateConnectionReference();
31 } 33 }
32 } 34 }
33 35
34 BluetoothDevice::ConnectionInfo::ConnectionInfo() 36 BluetoothDevice::ConnectionInfo::ConnectionInfo()
35 : rssi(kUnknownPower), 37 : rssi(kUnknownPower),
36 transmit_power(kUnknownPower), 38 transmit_power(kUnknownPower),
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 380 }
379 381
380 void BluetoothDevice::ClearServiceData() { services_data_->Clear(); } 382 void BluetoothDevice::ClearServiceData() { services_data_->Clear(); }
381 383
382 void BluetoothDevice::SetServiceData(BluetoothUUID serviceUUID, 384 void BluetoothDevice::SetServiceData(BluetoothUUID serviceUUID,
383 const char* buffer, size_t size) { 385 const char* buffer, size_t size) {
384 services_data_->Set(serviceUUID.value(), 386 services_data_->Set(serviceUUID.value(),
385 base::BinaryValue::CreateWithCopiedBuffer(buffer, size)); 387 base::BinaryValue::CreateWithCopiedBuffer(buffer, size));
386 } 388 }
387 389
390 void BluetoothDevice::SetAsExpiredForTesting() {
391 last_update_time_ =
392 base::Time::NowFromSystemTime() -
393 (BluetoothAdapter::timeoutSec + base::TimeDelta::FromSeconds(1));
394 }
395
388 void BluetoothDevice::Pair(PairingDelegate* pairing_delegate, 396 void BluetoothDevice::Pair(PairingDelegate* pairing_delegate,
389 const base::Closure& callback, 397 const base::Closure& callback,
390 const ConnectErrorCallback& error_callback) { 398 const ConnectErrorCallback& error_callback) {
391 NOTREACHED(); 399 NOTREACHED();
392 } 400 }
393 401
402 void BluetoothDevice::UpdateTimestamp() {
403 last_update_time_ = base::Time::NowFromSystemTime();
404 }
405
394 } // namespace device 406 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698