| 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" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "components/device_event_log/device_event_log.h" |
| 13 #include "device/bluetooth/bluetooth_device.h" | 14 #include "device/bluetooth/bluetooth_device.h" |
| 14 #include "device/bluetooth/bluetooth_discovery_session.h" | 15 #include "device/bluetooth/bluetooth_discovery_session.h" |
| 15 #include "device/bluetooth/bluetooth_discovery_session_outcome.h" | 16 #include "device/bluetooth/bluetooth_discovery_session_outcome.h" |
| 16 | 17 |
| 17 namespace device { | 18 namespace device { |
| 18 | 19 |
| 19 BluetoothAdapter::ServiceOptions::ServiceOptions() { | 20 BluetoothAdapter::ServiceOptions::ServiceOptions() { |
| 20 } | 21 } |
| 21 BluetoothAdapter::ServiceOptions::~ServiceOptions() { | 22 BluetoothAdapter::ServiceOptions::~ServiceOptions() { |
| 22 } | 23 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 158 |
| 158 BluetoothAdapter::BluetoothAdapter() : weak_ptr_factory_(this) { | 159 BluetoothAdapter::BluetoothAdapter() : weak_ptr_factory_(this) { |
| 159 } | 160 } |
| 160 | 161 |
| 161 BluetoothAdapter::~BluetoothAdapter() { | 162 BluetoothAdapter::~BluetoothAdapter() { |
| 162 } | 163 } |
| 163 | 164 |
| 164 void BluetoothAdapter::OnStartDiscoverySession( | 165 void BluetoothAdapter::OnStartDiscoverySession( |
| 165 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, | 166 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, |
| 166 const DiscoverySessionCallback& callback) { | 167 const DiscoverySessionCallback& callback) { |
| 167 VLOG(1) << "BluetoothAdapter::OnStartDiscoverySession"; | 168 BLUETOOTH_LOG(EVENT) << "BluetoothAdapter::OnStartDiscoverySession"; |
| 168 RecordBluetoothDiscoverySessionStartOutcome( | 169 RecordBluetoothDiscoverySessionStartOutcome( |
| 169 UMABluetoothDiscoverySessionOutcome::SUCCESS); | 170 UMABluetoothDiscoverySessionOutcome::SUCCESS); |
| 170 | 171 |
| 171 scoped_ptr<BluetoothDiscoverySession> discovery_session( | 172 scoped_ptr<BluetoothDiscoverySession> discovery_session( |
| 172 new BluetoothDiscoverySession(scoped_refptr<BluetoothAdapter>(this), | 173 new BluetoothDiscoverySession(scoped_refptr<BluetoothAdapter>(this), |
| 173 std::move(discovery_filter))); | 174 std::move(discovery_filter))); |
| 174 discovery_sessions_.insert(discovery_session.get()); | 175 discovery_sessions_.insert(discovery_session.get()); |
| 175 callback.Run(std::move(discovery_session)); | 176 callback.Run(std::move(discovery_session)); |
| 176 } | 177 } |
| 177 | 178 |
| 178 void BluetoothAdapter::OnStartDiscoverySessionError( | 179 void BluetoothAdapter::OnStartDiscoverySessionError( |
| 179 const ErrorCallback& callback, | 180 const ErrorCallback& callback, |
| 180 UMABluetoothDiscoverySessionOutcome outcome) { | 181 UMABluetoothDiscoverySessionOutcome outcome) { |
| 181 VLOG(1) << "OnStartDiscoverySessionError: " << static_cast<int>(outcome); | 182 BLUETOOTH_LOG(ERROR) << "OnStartDiscoverySessionError: " |
| 183 << static_cast<int>(outcome); |
| 182 RecordBluetoothDiscoverySessionStartOutcome(outcome); | 184 RecordBluetoothDiscoverySessionStartOutcome(outcome); |
| 183 callback.Run(); | 185 callback.Run(); |
| 184 } | 186 } |
| 185 | 187 |
| 186 void BluetoothAdapter::MarkDiscoverySessionsAsInactive() { | 188 void BluetoothAdapter::MarkDiscoverySessionsAsInactive() { |
| 187 // As sessions are marked as inactive they will notify the adapter that they | 189 // As sessions are marked as inactive they will notify the adapter that they |
| 188 // have become inactive, upon which the adapter will remove them from | 190 // have become inactive, upon which the adapter will remove them from |
| 189 // |discovery_sessions_|. To avoid invalidating the iterator, make a copy | 191 // |discovery_sessions_|. To avoid invalidating the iterator, make a copy |
| 190 // here. | 192 // here. |
| 191 std::set<BluetoothDiscoverySession*> temp(discovery_sessions_); | 193 std::set<BluetoothDiscoverySession*> temp(discovery_sessions_); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 256 |
| 255 // static | 257 // static |
| 256 void BluetoothAdapter::RecordBluetoothDiscoverySessionStopOutcome( | 258 void BluetoothAdapter::RecordBluetoothDiscoverySessionStopOutcome( |
| 257 UMABluetoothDiscoverySessionOutcome outcome) { | 259 UMABluetoothDiscoverySessionOutcome outcome) { |
| 258 UMA_HISTOGRAM_ENUMERATION( | 260 UMA_HISTOGRAM_ENUMERATION( |
| 259 "Bluetooth.DiscoverySession.Stop.Outcome", static_cast<int>(outcome), | 261 "Bluetooth.DiscoverySession.Stop.Outcome", static_cast<int>(outcome), |
| 260 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); | 262 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); |
| 261 } | 263 } |
| 262 | 264 |
| 263 } // namespace device | 265 } // namespace device |
| OLD | NEW |