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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 } | 350 } |
351 continue; | 351 continue; |
352 } | 352 } |
353 | 353 |
354 result = BluetoothDiscoveryFilter::Merge(result.get(), curr_filter); | 354 result = BluetoothDiscoveryFilter::Merge(result.get(), curr_filter); |
355 } | 355 } |
356 | 356 |
357 return result; | 357 return result; |
358 } | 358 } |
359 | 359 |
360 void BluetoothAdapter::RemoveTimedOutDevices() { | |
361 std::set<std::string> removed_devices; | |
362 for (DevicesMap::const_iterator it = devices_.begin(); it != devices_.end(); | |
363 ++it) { | |
364 BluetoothDevice* device = it->second; | |
365 | |
366 if (device->IsPaired() || device->IsConnected()) | |
367 continue; | |
368 | |
369 base::Time last_update_time = device->GetLastUpdateTime(); | |
370 | |
371 bool device_expired = | |
372 (base::Time::NowFromSystemTime() - last_update_time) > timeoutSec; | |
373 VLOG(1) << "device: " << device->GetAddress() | |
374 << ", last_update: " << last_update_time | |
375 << ", exp: " << device_expired; | |
376 | |
377 if (!device_expired) | |
378 continue; | |
379 removed_devices.insert(it->first); | |
380 | |
381 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, | |
382 DeviceRemoved(this, device)); | |
383 removed_devices.insert(it->first); | |
scheib
2016/05/06 00:41:50
This line is duplicated above.
| |
384 } | |
385 | |
386 for (const std::string& device_address : removed_devices) { | |
387 size_t num_removed = devices_.erase(device_address); | |
388 DCHECK_EQ(num_removed, 1U); | |
389 } | |
390 } | |
391 | |
360 // static | 392 // static |
361 void BluetoothAdapter::RecordBluetoothDiscoverySessionStartOutcome( | 393 void BluetoothAdapter::RecordBluetoothDiscoverySessionStartOutcome( |
362 UMABluetoothDiscoverySessionOutcome outcome) { | 394 UMABluetoothDiscoverySessionOutcome outcome) { |
363 UMA_HISTOGRAM_ENUMERATION( | 395 UMA_HISTOGRAM_ENUMERATION( |
364 "Bluetooth.DiscoverySession.Start.Outcome", static_cast<int>(outcome), | 396 "Bluetooth.DiscoverySession.Start.Outcome", static_cast<int>(outcome), |
365 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); | 397 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); |
366 } | 398 } |
367 | 399 |
368 // static | 400 // static |
369 void BluetoothAdapter::RecordBluetoothDiscoverySessionStopOutcome( | 401 void BluetoothAdapter::RecordBluetoothDiscoverySessionStopOutcome( |
370 UMABluetoothDiscoverySessionOutcome outcome) { | 402 UMABluetoothDiscoverySessionOutcome outcome) { |
371 UMA_HISTOGRAM_ENUMERATION( | 403 UMA_HISTOGRAM_ENUMERATION( |
372 "Bluetooth.DiscoverySession.Stop.Outcome", static_cast<int>(outcome), | 404 "Bluetooth.DiscoverySession.Stop.Outcome", static_cast<int>(outcome), |
373 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); | 405 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); |
374 } | 406 } |
375 | 407 |
408 // static | |
409 const base::TimeDelta BluetoothAdapter::timeoutSec = | |
410 base::TimeDelta::FromSeconds(180); | |
411 | |
376 } // namespace device | 412 } // namespace device |
OLD | NEW |