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

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

Issue 1315093002: Implement a bluetooth picker dialog for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 // NETWORK_ERROR Note: 5 // NETWORK_ERROR Note:
6 // When a device can't be found in the BluetoothAdapter, that generally 6 // When a device can't be found in the BluetoothAdapter, that generally
7 // indicates that it's gone out of range. We reject with a NetworkError in that 7 // indicates that it's gone out of range. We reject with a NetworkError in that
8 // case. 8 // case.
9 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-conne ctgatt 9 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-conne ctgatt
10 10
(...skipping 25 matching lines...) Expand all
36 using device::BluetoothUUID; 36 using device::BluetoothUUID;
37 37
38 namespace content { 38 namespace content {
39 39
40 namespace { 40 namespace {
41 41
42 // TODO(ortuno): Once we have a chooser for scanning, a way to control that 42 // TODO(ortuno): Once we have a chooser for scanning, a way to control that
43 // chooser from tests, and the right callback for discovered services we should 43 // chooser from tests, and the right callback for discovered services we should
44 // delete these constants. 44 // delete these constants.
45 // https://crbug.com/436280 and https://crbug.com/484504 45 // https://crbug.com/436280 and https://crbug.com/484504
46 const int kDelayTime = 5; // 5 seconds for scanning and discovering 46 const int kDelayTime = 20; // 20 seconds for scanning and discovering
scheib 2015/08/29 20:15:18 This constant also affects the delay for GetPrimar
Finnur 2015/08/31 15:25:22 OK, reverted and I'll leave this up to you guys wi
47 const int kTestingDelayTime = 0; // No need to wait during tests 47 const int kTestingDelayTime = 0; // No need to wait during tests
48 48
49 // Defined at 49 // Defined at
50 // https://webbluetoothchrome.github.io/web-bluetooth/#dfn-matches-a-filter 50 // https://webbluetoothchrome.github.io/web-bluetooth/#dfn-matches-a-filter
51 bool MatchesFilter(const std::set<BluetoothUUID>& device_uuids, 51 bool MatchesFilter(const std::set<BluetoothUUID>& device_uuids,
52 const content::BluetoothScanFilter& filter) { 52 const content::BluetoothScanFilter& filter) {
53 if (filter.services.empty()) 53 if (filter.services.empty())
54 return false; 54 return false;
55 for (const BluetoothUUID& service : filter.services) { 55 for (const BluetoothUUID& service : filter.services) {
56 if (!ContainsKey(device_uuids, service)) { 56 if (!ContainsKey(device_uuids, service)) {
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 } 701 }
702 // Ignore discovery session start errors when the dialog was already closed by 702 // Ignore discovery session start errors when the dialog was already closed by
703 // the time they happen. 703 // the time they happen.
704 } 704 }
705 705
706 void BluetoothDispatcherHost::OnBluetoothChooserEvent( 706 void BluetoothDispatcherHost::OnBluetoothChooserEvent(
707 int chooser_id, 707 int chooser_id,
708 BluetoothChooser::Event event, 708 BluetoothChooser::Event event,
709 const std::string& device_id) { 709 const std::string& device_id) {
710 switch (event) { 710 switch (event) {
711 case BluetoothChooser::Event::RESTART:
712 // TODO(jyasskin): Implement restarting.
713 NOTIMPLEMENTED();
714 break;
711 case BluetoothChooser::Event::CANCELLED: 715 case BluetoothChooser::Event::CANCELLED:
712 case BluetoothChooser::Event::SELECTED: 716 case BluetoothChooser::Event::SELECTED:
713 RequestDeviceSession* session = 717 RequestDeviceSession* session =
714 request_device_sessions_.Lookup(chooser_id); 718 request_device_sessions_.Lookup(chooser_id);
715 DCHECK(session) << "Shouldn't close the dialog twice."; 719 DCHECK(session) << "Shouldn't close the dialog twice.";
716 CHECK(session->chooser) << "Shouldn't close the dialog twice."; 720 CHECK(session->chooser) << "Shouldn't close the dialog twice.";
717 721
718 // Synchronously ensure nothing else calls into the chooser after it has 722 // Synchronously ensure nothing else calls into the chooser after it has
719 // asked to be closed. 723 // asked to be closed.
720 session->chooser.reset(); 724 session->chooser.reset();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 int thread_id, 884 int thread_id,
881 int request_id, 885 int request_id,
882 device::BluetoothGattService::GattErrorCode error_code) { 886 device::BluetoothGattService::GattErrorCode error_code) {
883 // TranslateGATTError calls RecordGATTOperationOutcome. 887 // TranslateGATTError calls RecordGATTOperationOutcome.
884 Send(new BluetoothMsg_WriteCharacteristicValueError( 888 Send(new BluetoothMsg_WriteCharacteristicValueError(
885 thread_id, request_id, 889 thread_id, request_id,
886 TranslateGATTError(error_code, UMAGATTOperation::CHARACTERISTIC_WRITE))); 890 TranslateGATTError(error_code, UMAGATTOperation::CHARACTERISTIC_WRITE)));
887 } 891 }
888 892
889 } // namespace content 893 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698