| 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> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 10 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 11 #include "device/bluetooth/bluetooth_device.h" | 13 #include "device/bluetooth/bluetooth_device.h" |
| 12 #include "device/bluetooth/bluetooth_discovery_session.h" | 14 #include "device/bluetooth/bluetooth_discovery_session.h" |
| 13 #include "device/bluetooth/bluetooth_discovery_session_outcome.h" | 15 #include "device/bluetooth/bluetooth_discovery_session_outcome.h" |
| 14 | 16 |
| 15 namespace device { | 17 namespace device { |
| 16 | 18 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 163 |
| 162 void BluetoothAdapter::OnStartDiscoverySession( | 164 void BluetoothAdapter::OnStartDiscoverySession( |
| 163 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, | 165 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, |
| 164 const DiscoverySessionCallback& callback) { | 166 const DiscoverySessionCallback& callback) { |
| 165 VLOG(1) << "BluetoothAdapter::OnStartDiscoverySession"; | 167 VLOG(1) << "BluetoothAdapter::OnStartDiscoverySession"; |
| 166 RecordBluetoothDiscoverySessionStartOutcome( | 168 RecordBluetoothDiscoverySessionStartOutcome( |
| 167 UMABluetoothDiscoverySessionOutcome::SUCCESS); | 169 UMABluetoothDiscoverySessionOutcome::SUCCESS); |
| 168 | 170 |
| 169 scoped_ptr<BluetoothDiscoverySession> discovery_session( | 171 scoped_ptr<BluetoothDiscoverySession> discovery_session( |
| 170 new BluetoothDiscoverySession(scoped_refptr<BluetoothAdapter>(this), | 172 new BluetoothDiscoverySession(scoped_refptr<BluetoothAdapter>(this), |
| 171 discovery_filter.Pass())); | 173 std::move(discovery_filter))); |
| 172 discovery_sessions_.insert(discovery_session.get()); | 174 discovery_sessions_.insert(discovery_session.get()); |
| 173 callback.Run(discovery_session.Pass()); | 175 callback.Run(std::move(discovery_session)); |
| 174 } | 176 } |
| 175 | 177 |
| 176 void BluetoothAdapter::OnStartDiscoverySessionError( | 178 void BluetoothAdapter::OnStartDiscoverySessionError( |
| 177 const ErrorCallback& callback, | 179 const ErrorCallback& callback, |
| 178 UMABluetoothDiscoverySessionOutcome outcome) { | 180 UMABluetoothDiscoverySessionOutcome outcome) { |
| 179 VLOG(1) << "OnStartDiscoverySessionError: " << static_cast<int>(outcome); | 181 VLOG(1) << "OnStartDiscoverySessionError: " << static_cast<int>(outcome); |
| 180 RecordBluetoothDiscoverySessionStartOutcome(outcome); | 182 RecordBluetoothDiscoverySessionStartOutcome(outcome); |
| 181 callback.Run(); | 183 callback.Run(); |
| 182 } | 184 } |
| 183 | 185 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 result.reset(new BluetoothDiscoveryFilter( | 234 result.reset(new BluetoothDiscoveryFilter( |
| 233 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL)); | 235 BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL)); |
| 234 result->CopyFrom(*curr_filter); | 236 result->CopyFrom(*curr_filter); |
| 235 } | 237 } |
| 236 continue; | 238 continue; |
| 237 } | 239 } |
| 238 | 240 |
| 239 result = BluetoothDiscoveryFilter::Merge(result.get(), curr_filter); | 241 result = BluetoothDiscoveryFilter::Merge(result.get(), curr_filter); |
| 240 } | 242 } |
| 241 | 243 |
| 242 return result.Pass(); | 244 return result; |
| 243 } | 245 } |
| 244 | 246 |
| 245 // static | 247 // static |
| 246 void BluetoothAdapter::RecordBluetoothDiscoverySessionStartOutcome( | 248 void BluetoothAdapter::RecordBluetoothDiscoverySessionStartOutcome( |
| 247 UMABluetoothDiscoverySessionOutcome outcome) { | 249 UMABluetoothDiscoverySessionOutcome outcome) { |
| 248 UMA_HISTOGRAM_ENUMERATION( | 250 UMA_HISTOGRAM_ENUMERATION( |
| 249 "Bluetooth.DiscoverySession.Start.Outcome", static_cast<int>(outcome), | 251 "Bluetooth.DiscoverySession.Start.Outcome", static_cast<int>(outcome), |
| 250 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); | 252 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); |
| 251 } | 253 } |
| 252 | 254 |
| 253 // static | 255 // static |
| 254 void BluetoothAdapter::RecordBluetoothDiscoverySessionStopOutcome( | 256 void BluetoothAdapter::RecordBluetoothDiscoverySessionStopOutcome( |
| 255 UMABluetoothDiscoverySessionOutcome outcome) { | 257 UMABluetoothDiscoverySessionOutcome outcome) { |
| 256 UMA_HISTOGRAM_ENUMERATION( | 258 UMA_HISTOGRAM_ENUMERATION( |
| 257 "Bluetooth.DiscoverySession.Stop.Outcome", static_cast<int>(outcome), | 259 "Bluetooth.DiscoverySession.Stop.Outcome", static_cast<int>(outcome), |
| 258 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); | 260 static_cast<int>(UMABluetoothDiscoverySessionOutcome::COUNT)); |
| 259 } | 261 } |
| 260 | 262 |
| 261 } // namespace device | 263 } // namespace device |
| OLD | NEW |