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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 } | 338 } |
339 continue; | 339 continue; |
340 } | 340 } |
341 | 341 |
342 result = BluetoothDiscoveryFilter::Merge(result.get(), curr_filter); | 342 result = BluetoothDiscoveryFilter::Merge(result.get(), curr_filter); |
343 } | 343 } |
344 | 344 |
345 return result; | 345 return result; |
346 } | 346 } |
347 | 347 |
348 void BluetoothAdapter::RemoveTimedOutDevices() { | |
349 std::set<std::string> removed_devices; | |
350 for (DevicesMap::const_iterator it = devices_.begin(); it != devices_.end(); | |
351 ++it) { | |
352 BluetoothDevice* device = it->second; | |
353 | |
354 if (device->IsPaired() || device->IsConnected()) | |
355 continue; | |
356 | |
357 base::Time last_update_time = device->GetLastUpdateTime(); | |
358 | |
359 bool device_expired = | |
360 (base::Time::NowFromSystemTime() - last_update_time) > timeoutSec; | |
361 VLOG(1) << "device: " << device->GetAddress() | |
362 << ", last_update: " << last_update_time | |
363 << ", exp: " << device_expired; | |
364 | |
365 if (!device_expired) | |
366 continue; | |
367 removed_devices.insert(it->first); | |
368 | |
369 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, | |
370 DeviceRemoved(this, device)); | |
371 removed_devices.insert(it->first); | |
372 } | |
373 | |
374 for (const std::string& device_address : removed_devices) { | |
375 size_t num_removed = devices_.erase(device_address); | |
376 DCHECK_EQ(num_removed, 1U); | |
377 } | |
378 } | |
379 | |
348 // static | 380 // static |
349 void BluetoothAdapter::RecordBluetoothDiscoverySessionStartOutcome( | 381 void BluetoothAdapter::RecordBluetoothDiscoverySessionStartOutcome( |
350 UMABluetoothDiscoverySessionOutcome outcome) { | 382 UMABluetoothDiscoverySessionOutcome outcome) { |
351 UMA_HISTOGRAM_ENUMERATION( | 383 UMA_HISTOGRAM_ENUMERATION( |
352 "Bluetooth.DiscoverySession.Start.Outcome", static_cast<int>(outcome), | 384 "Bluetooth.DiscoverySession.Start.Outcome", static_cast<int>(outcome), |
353 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); | 385 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); |
354 } | 386 } |
355 | 387 |
356 // static | 388 // static |
357 void BluetoothAdapter::RecordBluetoothDiscoverySessionStopOutcome( | 389 void BluetoothAdapter::RecordBluetoothDiscoverySessionStopOutcome( |
358 UMABluetoothDiscoverySessionOutcome outcome) { | 390 UMABluetoothDiscoverySessionOutcome outcome) { |
359 UMA_HISTOGRAM_ENUMERATION( | 391 UMA_HISTOGRAM_ENUMERATION( |
360 "Bluetooth.DiscoverySession.Stop.Outcome", static_cast<int>(outcome), | 392 "Bluetooth.DiscoverySession.Stop.Outcome", static_cast<int>(outcome), |
361 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); | 393 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); |
362 } | 394 } |
363 | 395 |
396 // static | |
397 const base::TimeDelta BluetoothAdapter::timeoutSec = | |
398 base::TimeDelta::FromSeconds(30); | |
scheib
2016/04/07 22:05:02
Why 30? Mac was using 180.
perja
2016/04/08 07:47:35
Only reason for this was that we thought 180 secon
| |
399 | |
364 } // namespace device | 400 } // namespace device |
OLD | NEW |