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

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

Issue 1058373002: bluetooth: Move requestDevice() to UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" 5 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/common/bluetooth/bluetooth_messages.h" 8 #include "content/common/bluetooth/bluetooth_messages.h"
9 #include "device/bluetooth/bluetooth_adapter.h" 9 #include "device/bluetooth/bluetooth_adapter.h"
10 #include "device/bluetooth/bluetooth_adapter_factory.h" 10 #include "device/bluetooth/bluetooth_adapter_factory.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 scoped_refptr<device::BluetoothAdapter> adapter) { 59 scoped_refptr<device::BluetoothAdapter> adapter) {
60 if (adapter_.get()) 60 if (adapter_.get())
61 adapter_->RemoveObserver(this); 61 adapter_->RemoveObserver(this);
62 adapter_ = adapter; 62 adapter_ = adapter;
63 if (adapter_.get()) 63 if (adapter_.get())
64 adapter_->AddObserver(this); 64 adapter_->AddObserver(this);
65 } 65 }
66 66
67 void BluetoothDispatcherHost::OnRequestDevice(int thread_id, int request_id) { 67 void BluetoothDispatcherHost::OnRequestDevice(int thread_id, int request_id) {
68 DCHECK_CURRENTLY_ON(BrowserThread::IO); 68 DCHECK_CURRENTLY_ON(BrowserThread::IO);
69 BrowserThread::PostTask(BrowserThread::UI,
70 FROM_HERE,
71 base::Bind(&BluetoothDispatcherHost::OnRequestDeviceUI ,
72 this, thread_id, request_id));
73 }
74
75 void BluetoothDispatcherHost::OnRequestDeviceUI(int thread_id, int request_id) {
76 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
69 // TODO(scheib) Extend this very simple mock implementation by using 77 // TODO(scheib) Extend this very simple mock implementation by using
70 // device/bluetooth/test mock adapter and related classes. 78 // device/bluetooth/test mock adapter and related classes.
71 switch (bluetooth_mock_data_set_) { 79 switch (bluetooth_mock_data_set_) {
72 case MockData::NOT_MOCKING: { 80 case MockData::NOT_MOCKING: {
73 // TODO(scheib): Filter devices by services: crbug.com/440594 81 // TODO(scheib): Filter devices by services: crbug.com/440594
74 // TODO(scheib): Device selection UI: crbug.com/436280 82 // TODO(scheib): Device selection UI: crbug.com/436280
75 // TODO(scheib): Utilize BluetoothAdapter::Observer::DeviceAdded/Removed. 83 // TODO(scheib): Utilize BluetoothAdapter::Observer::DeviceAdded/Removed.
76 BluetoothAdapter::DeviceList devices; 84 BluetoothAdapter::DeviceList devices;
77 if (adapter_.get()) 85 if (adapter_.get())
78 devices = adapter_->GetDevices(); 86 devices = adapter_->GetDevices();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 bluetooth_request_device_reject_type_ = BluetoothError::SECURITY; 148 bluetooth_request_device_reject_type_ = BluetoothError::SECURITY;
141 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove. 149 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove.
142 name == "Single Empty Device") { 150 name == "Single Empty Device") {
143 bluetooth_mock_data_set_ = MockData::RESOLVE; 151 bluetooth_mock_data_set_ = MockData::RESOLVE;
144 } else { 152 } else {
145 bluetooth_mock_data_set_ = MockData::NOT_MOCKING; 153 bluetooth_mock_data_set_ = MockData::NOT_MOCKING;
146 } 154 }
147 } 155 }
148 156
149 } // namespace content 157 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698