OLD | NEW |
---|---|
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_adapter.h" | 5 #include "device/bluetooth/bluetooth_adapter.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 } | 358 } |
359 continue; | 359 continue; |
360 } | 360 } |
361 | 361 |
362 result = BluetoothDiscoveryFilter::Merge(result.get(), curr_filter); | 362 result = BluetoothDiscoveryFilter::Merge(result.get(), curr_filter); |
363 } | 363 } |
364 | 364 |
365 return result; | 365 return result; |
366 } | 366 } |
367 | 367 |
368 void BluetoothAdapter::RemoveTimedOutDevices() { | |
369 std::set<std::string> removed_devices; | |
370 for (DevicesMap::const_iterator it = devices_.begin(); it != devices_.end(); | |
371 ++it) { | |
372 BluetoothDevice* device = it->second; | |
373 | |
374 if (device->IsPaired() || device->IsConnected()) | |
ortuno
2016/06/14 15:29:33
Also need device->IsGattConnected()
perja
2016/06/15 13:03:40
Acknowledged.
| |
375 continue; | |
376 | |
377 base::Time last_update_time = device->GetLastUpdateTime(); | |
378 | |
379 bool device_expired = | |
380 (base::Time::NowFromSystemTime() - last_update_time) > timeoutSec; | |
381 VLOG(1) << "device: " << device->GetAddress() | |
382 << ", last_update: " << last_update_time | |
383 << ", exp: " << device_expired; | |
384 | |
385 if (!device_expired) | |
386 continue; | |
387 removed_devices.insert(it->first); | |
388 | |
389 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, | |
390 DeviceRemoved(this, device)); | |
391 } | |
392 | |
393 for (const std::string& device_address : removed_devices) { | |
394 size_t num_removed = devices_.erase(device_address); | |
395 DCHECK_EQ(num_removed, 1U); | |
396 } | |
397 } | |
398 | |
368 // static | 399 // static |
369 void BluetoothAdapter::RecordBluetoothDiscoverySessionStartOutcome( | 400 void BluetoothAdapter::RecordBluetoothDiscoverySessionStartOutcome( |
370 UMABluetoothDiscoverySessionOutcome outcome) { | 401 UMABluetoothDiscoverySessionOutcome outcome) { |
371 UMA_HISTOGRAM_ENUMERATION( | 402 UMA_HISTOGRAM_ENUMERATION( |
372 "Bluetooth.DiscoverySession.Start.Outcome", static_cast<int>(outcome), | 403 "Bluetooth.DiscoverySession.Start.Outcome", static_cast<int>(outcome), |
373 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); | 404 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); |
374 } | 405 } |
375 | 406 |
376 // static | 407 // static |
377 void BluetoothAdapter::RecordBluetoothDiscoverySessionStopOutcome( | 408 void BluetoothAdapter::RecordBluetoothDiscoverySessionStopOutcome( |
378 UMABluetoothDiscoverySessionOutcome outcome) { | 409 UMABluetoothDiscoverySessionOutcome outcome) { |
379 UMA_HISTOGRAM_ENUMERATION( | 410 UMA_HISTOGRAM_ENUMERATION( |
380 "Bluetooth.DiscoverySession.Stop.Outcome", static_cast<int>(outcome), | 411 "Bluetooth.DiscoverySession.Stop.Outcome", static_cast<int>(outcome), |
381 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); | 412 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); |
382 } | 413 } |
383 | 414 |
415 // static | |
416 const base::TimeDelta BluetoothAdapter::timeoutSec = | |
417 base::TimeDelta::FromSeconds(180); | |
418 | |
384 } // namespace device | 419 } // namespace device |
OLD | NEW |