Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: content/browser/bluetooth/bluetooth_dispatcher_host.cc

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
11 11
12 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" 12 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h"
13 13
14 #include <stddef.h>
15
14 #include <utility> 16 #include <utility>
15 17
16 #include "base/bind.h" 18 #include "base/bind.h"
17 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
18 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
19 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
20 #include "content/browser/bad_message.h" 22 #include "content/browser/bad_message.h"
21 #include "content/browser/bluetooth/bluetooth_metrics.h" 23 #include "content/browser/bluetooth/bluetooth_metrics.h"
22 #include "content/browser/bluetooth/first_device_bluetooth_chooser.h" 24 #include "content/browser/bluetooth/first_device_bluetooth_chooser.h"
23 #include "content/browser/frame_host/render_frame_host_impl.h" 25 #include "content/browser/frame_host/render_frame_host_impl.h"
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 break; 532 break;
531 } 533 }
532 } 534 }
533 DCHECK(!ContainsKey(pending_primary_services_requests_, device_id)) 535 DCHECK(!ContainsKey(pending_primary_services_requests_, device_id))
534 << "Sending get-service responses unexpectedly queued another request."; 536 << "Sending get-service responses unexpectedly queued another request.";
535 } 537 }
536 538
537 void BluetoothDispatcherHost::GattCharacteristicValueChanged( 539 void BluetoothDispatcherHost::GattCharacteristicValueChanged(
538 device::BluetoothAdapter* adapter, 540 device::BluetoothAdapter* adapter,
539 device::BluetoothGattCharacteristic* characteristic, 541 device::BluetoothGattCharacteristic* characteristic,
540 const std::vector<uint8>& value) { 542 const std::vector<uint8_t>& value) {
541 VLOG(1) << "Characteristic updated: " << characteristic->GetIdentifier(); 543 VLOG(1) << "Characteristic updated: " << characteristic->GetIdentifier();
542 auto iter = 544 auto iter =
543 active_characteristic_threads_.find(characteristic->GetIdentifier()); 545 active_characteristic_threads_.find(characteristic->GetIdentifier());
544 546
545 if (iter == active_characteristic_threads_.end()) { 547 if (iter == active_characteristic_threads_.end()) {
546 return; 548 return;
547 } 549 }
548 550
549 for (int thread_id : iter->second) { 551 for (int thread_id : iter->second) {
550 // Yield to the event loop so that the event gets dispatched after the 552 // Yield to the event loop so that the event gets dispatched after the
551 // readValue promise resolves. 553 // readValue promise resolves.
552 // TODO(ortuno): Make sure the order of fulfulling promises and triggering 554 // TODO(ortuno): Make sure the order of fulfulling promises and triggering
553 // events matches the spec and that events don't get lost. 555 // events matches the spec and that events don't get lost.
554 // https://crbug.com/543882 556 // https://crbug.com/543882
555 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( 557 if (!base::ThreadTaskRunnerHandle::Get()->PostTask(
556 FROM_HERE, 558 FROM_HERE,
557 base::Bind(&BluetoothDispatcherHost::NotifyActiveCharacteristic, 559 base::Bind(&BluetoothDispatcherHost::NotifyActiveCharacteristic,
558 weak_ptr_on_ui_thread_, thread_id, 560 weak_ptr_on_ui_thread_, thread_id,
559 characteristic->GetIdentifier(), value))) { 561 characteristic->GetIdentifier(), value))) {
560 LOG(WARNING) << "No TaskRunner."; 562 LOG(WARNING) << "No TaskRunner.";
561 } 563 }
562 } 564 }
563 } 565 }
564 566
565 void BluetoothDispatcherHost::NotifyActiveCharacteristic( 567 void BluetoothDispatcherHost::NotifyActiveCharacteristic(
566 int thread_id, 568 int thread_id,
567 const std::string& characteristic_instance_id, 569 const std::string& characteristic_instance_id,
568 const std::vector<uint8>& value) { 570 const std::vector<uint8_t>& value) {
569 Send(new BluetoothMsg_CharacteristicValueChanged( 571 Send(new BluetoothMsg_CharacteristicValueChanged(
570 thread_id, characteristic_instance_id, value)); 572 thread_id, characteristic_instance_id, value));
571 } 573 }
572 574
573 void BluetoothDispatcherHost::OnRequestDevice( 575 void BluetoothDispatcherHost::OnRequestDevice(
574 int thread_id, 576 int thread_id,
575 int request_id, 577 int request_id,
576 int frame_routing_id, 578 int frame_routing_id,
577 const std::vector<BluetoothScanFilter>& filters, 579 const std::vector<BluetoothScanFilter>& filters,
578 const std::vector<BluetoothUUID>& optional_services) { 580 const std::vector<BluetoothUUID>& optional_services) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 814
813 // If value is already in map, DCHECK it's valid. 815 // If value is already in map, DCHECK it's valid.
814 if (!insert_result.second) 816 if (!insert_result.second)
815 DCHECK(insert_result.first->second == service_instance_id); 817 DCHECK(insert_result.first->second == service_instance_id);
816 818
817 RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::SUCCESS); 819 RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::SUCCESS);
818 // TODO(ortuno): Use generated instance ID instead. 820 // TODO(ortuno): Use generated instance ID instead.
819 // https://crbug.com/495379 821 // https://crbug.com/495379
820 Send(new BluetoothMsg_GetCharacteristicSuccess( 822 Send(new BluetoothMsg_GetCharacteristicSuccess(
821 thread_id, request_id, characteristic_instance_id, 823 thread_id, request_id, characteristic_instance_id,
822 static_cast<uint32>(characteristic->GetProperties()))); 824 static_cast<uint32_t>(characteristic->GetProperties())));
823 return; 825 return;
824 } 826 }
825 } 827 }
826 RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::NOT_FOUND); 828 RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::NOT_FOUND);
827 Send(new BluetoothMsg_GetCharacteristicError( 829 Send(new BluetoothMsg_GetCharacteristicError(
828 thread_id, request_id, WebBluetoothError::CharacteristicNotFound)); 830 thread_id, request_id, WebBluetoothError::CharacteristicNotFound));
829 } 831 }
830 832
831 void BluetoothDispatcherHost::OnReadValue( 833 void BluetoothDispatcherHost::OnReadValue(
832 int thread_id, 834 int thread_id,
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 DCHECK_EQ(insert_result.first->second, device_id); 1175 DCHECK_EQ(insert_result.first->second, device_id);
1174 1176
1175 RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::SUCCESS); 1177 RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::SUCCESS);
1176 Send(new BluetoothMsg_GetPrimaryServiceSuccess(thread_id, request_id, 1178 Send(new BluetoothMsg_GetPrimaryServiceSuccess(thread_id, request_id,
1177 service_identifier)); 1179 service_identifier));
1178 } 1180 }
1179 1181
1180 void BluetoothDispatcherHost::OnCharacteristicValueRead( 1182 void BluetoothDispatcherHost::OnCharacteristicValueRead(
1181 int thread_id, 1183 int thread_id,
1182 int request_id, 1184 int request_id,
1183 const std::vector<uint8>& value) { 1185 const std::vector<uint8_t>& value) {
1184 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1186 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1185 RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome::SUCCESS); 1187 RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome::SUCCESS);
1186 Send(new BluetoothMsg_ReadCharacteristicValueSuccess(thread_id, request_id, 1188 Send(new BluetoothMsg_ReadCharacteristicValueSuccess(thread_id, request_id,
1187 value)); 1189 value));
1188 } 1190 }
1189 1191
1190 void BluetoothDispatcherHost::OnCharacteristicReadValueError( 1192 void BluetoothDispatcherHost::OnCharacteristicReadValueError(
1191 int thread_id, 1193 int thread_id,
1192 int request_id, 1194 int request_id,
1193 device::BluetoothGattService::GattErrorCode error_code) { 1195 device::BluetoothGattService::GattErrorCode error_code) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1346 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1345 NOTIMPLEMENTED(); 1347 NOTIMPLEMENTED();
1346 } 1348 }
1347 1349
1348 void BluetoothDispatcherHost::ShowNeedLocationLink() { 1350 void BluetoothDispatcherHost::ShowNeedLocationLink() {
1349 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1351 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1350 NOTIMPLEMENTED(); 1352 NOTIMPLEMENTED();
1351 } 1353 }
1352 1354
1353 } // namespace content 1355 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bluetooth/bluetooth_dispatcher_host.h ('k') | content/browser/bluetooth/bluetooth_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698