| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // ID Not In Map Note: | 5 // ID Not In Map Note: |
| 6 // A service, characteristic, or descriptor ID not in the corresponding | 6 // A service, characteristic, or descriptor ID not in the corresponding |
| 7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_, | 7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_, |
| 8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer | 8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer |
| 9 // obtains the corresponding ID from this class and it will be added to the map | 9 // obtains the corresponding ID from this class and it will be added to the map |
| 10 // at that time. | 10 // at that time. |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 std::set<BluetoothUUID> services; | 333 std::set<BluetoothUUID> services; |
| 334 for (const BluetoothScanFilter& filter : filters) { | 334 for (const BluetoothScanFilter& filter : filters) { |
| 335 services.insert(filter.services.begin(), filter.services.end()); | 335 services.insert(filter.services.begin(), filter.services.end()); |
| 336 } | 336 } |
| 337 scoped_ptr<device::BluetoothDiscoveryFilter> discovery_filter( | 337 scoped_ptr<device::BluetoothDiscoveryFilter> discovery_filter( |
| 338 new device::BluetoothDiscoveryFilter( | 338 new device::BluetoothDiscoveryFilter( |
| 339 device::BluetoothDiscoveryFilter::TRANSPORT_DUAL)); | 339 device::BluetoothDiscoveryFilter::TRANSPORT_DUAL)); |
| 340 for (const BluetoothUUID& service : services) { | 340 for (const BluetoothUUID& service : services) { |
| 341 discovery_filter->AddUUID(service); | 341 discovery_filter->AddUUID(service); |
| 342 } | 342 } |
| 343 return discovery_filter.Pass(); | 343 return discovery_filter; |
| 344 } | 344 } |
| 345 | 345 |
| 346 const int thread_id; | 346 const int thread_id; |
| 347 const int request_id; | 347 const int request_id; |
| 348 const std::vector<BluetoothScanFilter> filters; | 348 const std::vector<BluetoothScanFilter> filters; |
| 349 const std::vector<BluetoothUUID> optional_services; | 349 const std::vector<BluetoothUUID> optional_services; |
| 350 scoped_ptr<BluetoothChooser> chooser; | 350 scoped_ptr<BluetoothChooser> chooser; |
| 351 scoped_ptr<device::BluetoothDiscoverySession> discovery_session; | 351 scoped_ptr<device::BluetoothDiscoverySession> discovery_session; |
| 352 }; | 352 }; |
| 353 | 353 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 | 437 |
| 438 void BluetoothDispatcherHost::StopDeviceDiscovery() { | 438 void BluetoothDispatcherHost::StopDeviceDiscovery() { |
| 439 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 439 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 440 for (IDMap<RequestDeviceSession, IDMapOwnPointer>::iterator iter( | 440 for (IDMap<RequestDeviceSession, IDMapOwnPointer>::iterator iter( |
| 441 &request_device_sessions_); | 441 &request_device_sessions_); |
| 442 !iter.IsAtEnd(); iter.Advance()) { | 442 !iter.IsAtEnd(); iter.Advance()) { |
| 443 RequestDeviceSession* session = iter.GetCurrentValue(); | 443 RequestDeviceSession* session = iter.GetCurrentValue(); |
| 444 if (session->discovery_session) { | 444 if (session->discovery_session) { |
| 445 StopDiscoverySession(session->discovery_session.Pass()); | 445 StopDiscoverySession(std::move(session->discovery_session)); |
| 446 } | 446 } |
| 447 if (session->chooser) { | 447 if (session->chooser) { |
| 448 session->chooser->ShowDiscoveryState( | 448 session->chooser->ShowDiscoveryState( |
| 449 BluetoothChooser::DiscoveryState::IDLE); | 449 BluetoothChooser::DiscoveryState::IDLE); |
| 450 } | 450 } |
| 451 } | 451 } |
| 452 } | 452 } |
| 453 | 453 |
| 454 void BluetoothDispatcherHost::AdapterPoweredChanged( | 454 void BluetoothDispatcherHost::AdapterPoweredChanged( |
| 455 device::BluetoothAdapter* adapter, | 455 device::BluetoothAdapter* adapter, |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 } | 984 } |
| 985 } | 985 } |
| 986 | 986 |
| 987 void BluetoothDispatcherHost::OnDiscoverySessionStarted( | 987 void BluetoothDispatcherHost::OnDiscoverySessionStarted( |
| 988 int chooser_id, | 988 int chooser_id, |
| 989 scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { | 989 scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { |
| 990 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 990 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 991 VLOG(1) << "Started discovery session for " << chooser_id; | 991 VLOG(1) << "Started discovery session for " << chooser_id; |
| 992 if (RequestDeviceSession* session = | 992 if (RequestDeviceSession* session = |
| 993 request_device_sessions_.Lookup(chooser_id)) { | 993 request_device_sessions_.Lookup(chooser_id)) { |
| 994 session->discovery_session = discovery_session.Pass(); | 994 session->discovery_session = std::move(discovery_session); |
| 995 | 995 |
| 996 // Arrange to stop discovery later. | 996 // Arrange to stop discovery later. |
| 997 discovery_session_timer_.Reset(); | 997 discovery_session_timer_.Reset(); |
| 998 } else { | 998 } else { |
| 999 VLOG(1) << "Chooser " << chooser_id | 999 VLOG(1) << "Chooser " << chooser_id |
| 1000 << " was closed before the session finished starting. Stopping."; | 1000 << " was closed before the session finished starting. Stopping."; |
| 1001 StopDiscoverySession(discovery_session.Pass()); | 1001 StopDiscoverySession(std::move(discovery_session)); |
| 1002 } | 1002 } |
| 1003 } | 1003 } |
| 1004 | 1004 |
| 1005 void BluetoothDispatcherHost::OnDiscoverySessionStartedError(int chooser_id) { | 1005 void BluetoothDispatcherHost::OnDiscoverySessionStartedError(int chooser_id) { |
| 1006 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1006 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1007 VLOG(1) << "Failed to start discovery session for " << chooser_id; | 1007 VLOG(1) << "Failed to start discovery session for " << chooser_id; |
| 1008 if (RequestDeviceSession* session = | 1008 if (RequestDeviceSession* session = |
| 1009 request_device_sessions_.Lookup(chooser_id)) { | 1009 request_device_sessions_.Lookup(chooser_id)) { |
| 1010 if (session->chooser && !session->discovery_session) { | 1010 if (session->chooser && !session->discovery_session) { |
| 1011 session->chooser->ShowDiscoveryState( | 1011 session->chooser->ShowDiscoveryState( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 request_device_sessions_.Remove(chooser_id); | 1132 request_device_sessions_.Remove(chooser_id); |
| 1133 } | 1133 } |
| 1134 | 1134 |
| 1135 void BluetoothDispatcherHost::OnGATTConnectionCreated( | 1135 void BluetoothDispatcherHost::OnGATTConnectionCreated( |
| 1136 int thread_id, | 1136 int thread_id, |
| 1137 int request_id, | 1137 int request_id, |
| 1138 const std::string& device_id, | 1138 const std::string& device_id, |
| 1139 base::TimeTicks start_time, | 1139 base::TimeTicks start_time, |
| 1140 scoped_ptr<device::BluetoothGattConnection> connection) { | 1140 scoped_ptr<device::BluetoothGattConnection> connection) { |
| 1141 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1141 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1142 connections_.push_back(connection.Pass()); | 1142 connections_.push_back(std::move(connection)); |
| 1143 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); | 1143 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); |
| 1144 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); | 1144 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); |
| 1145 Send(new BluetoothMsg_ConnectGATTSuccess(thread_id, request_id, device_id)); | 1145 Send(new BluetoothMsg_ConnectGATTSuccess(thread_id, request_id, device_id)); |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 void BluetoothDispatcherHost::OnCreateGATTConnectionError( | 1148 void BluetoothDispatcherHost::OnCreateGATTConnectionError( |
| 1149 int thread_id, | 1149 int thread_id, |
| 1150 int request_id, | 1150 int request_id, |
| 1151 const std::string& device_id, | 1151 const std::string& device_id, |
| 1152 base::TimeTicks start_time, | 1152 base::TimeTicks start_time, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 int thread_id, | 1222 int thread_id, |
| 1223 int request_id, | 1223 int request_id, |
| 1224 scoped_ptr<device::BluetoothGattNotifySession> notify_session) { | 1224 scoped_ptr<device::BluetoothGattNotifySession> notify_session) { |
| 1225 RecordStartNotificationsOutcome(UMAGATTOperationOutcome::SUCCESS); | 1225 RecordStartNotificationsOutcome(UMAGATTOperationOutcome::SUCCESS); |
| 1226 | 1226 |
| 1227 // Copy Characteristic Instance ID before passing scoped pointer because | 1227 // Copy Characteristic Instance ID before passing scoped pointer because |
| 1228 // compilers may evaluate arguments in any order. | 1228 // compilers may evaluate arguments in any order. |
| 1229 const std::string characteristic_instance_id = | 1229 const std::string characteristic_instance_id = |
| 1230 notify_session->GetCharacteristicIdentifier(); | 1230 notify_session->GetCharacteristicIdentifier(); |
| 1231 characteristic_id_to_notify_session_.insert( | 1231 characteristic_id_to_notify_session_.insert( |
| 1232 std::make_pair(characteristic_instance_id, notify_session.Pass())); | 1232 std::make_pair(characteristic_instance_id, std::move(notify_session))); |
| 1233 | 1233 |
| 1234 Send(new BluetoothMsg_StartNotificationsSuccess(thread_id, request_id)); | 1234 Send(new BluetoothMsg_StartNotificationsSuccess(thread_id, request_id)); |
| 1235 } | 1235 } |
| 1236 | 1236 |
| 1237 void BluetoothDispatcherHost::OnStartNotifySessionFailed( | 1237 void BluetoothDispatcherHost::OnStartNotifySessionFailed( |
| 1238 int thread_id, | 1238 int thread_id, |
| 1239 int request_id, | 1239 int request_id, |
| 1240 device::BluetoothGattService::GattErrorCode error_code) { | 1240 device::BluetoothGattService::GattErrorCode error_code) { |
| 1241 // TranslateGATTError calls RecordGATTOperationOutcome. | 1241 // TranslateGATTError calls RecordGATTOperationOutcome. |
| 1242 Send(new BluetoothMsg_StartNotificationsError( | 1242 Send(new BluetoothMsg_StartNotificationsError( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1346 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1347 NOTIMPLEMENTED(); | 1347 NOTIMPLEMENTED(); |
| 1348 } | 1348 } |
| 1349 | 1349 |
| 1350 void BluetoothDispatcherHost::ShowNeedLocationLink() { | 1350 void BluetoothDispatcherHost::ShowNeedLocationLink() { |
| 1351 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1351 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1352 NOTIMPLEMENTED(); | 1352 NOTIMPLEMENTED(); |
| 1353 } | 1353 } |
| 1354 | 1354 |
| 1355 } // namespace content | 1355 } // namespace content |
| OLD | NEW |