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 #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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 // See class comment: UI Thread Note. | 43 // See class comment: UI Thread Note. |
44 *thread = BrowserThread::UI; | 44 *thread = BrowserThread::UI; |
45 } | 45 } |
46 | 46 |
47 bool BluetoothDispatcherHost::OnMessageReceived(const IPC::Message& message) { | 47 bool BluetoothDispatcherHost::OnMessageReceived(const IPC::Message& message) { |
48 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 48 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
49 bool handled = true; | 49 bool handled = true; |
50 IPC_BEGIN_MESSAGE_MAP(BluetoothDispatcherHost, message) | 50 IPC_BEGIN_MESSAGE_MAP(BluetoothDispatcherHost, message) |
51 IPC_MESSAGE_HANDLER(BluetoothHostMsg_RequestDevice, OnRequestDevice) | 51 IPC_MESSAGE_HANDLER(BluetoothHostMsg_RequestDevice, OnRequestDevice) |
52 IPC_MESSAGE_HANDLER(BluetoothHostMsg_ConnectGATT, OnConnectGATT) | 52 IPC_MESSAGE_HANDLER(BluetoothHostMsg_ConnectGATT, OnConnectGATT) |
53 IPC_MESSAGE_HANDLER(BluetoothHostMsg_SetBluetoothMockDataSetForTesting, | |
54 OnSetBluetoothMockDataSetForTesting) | |
55 IPC_MESSAGE_UNHANDLED(handled = false) | 53 IPC_MESSAGE_UNHANDLED(handled = false) |
56 IPC_END_MESSAGE_MAP() | 54 IPC_END_MESSAGE_MAP() |
57 return handled; | 55 return handled; |
58 } | 56 } |
59 | 57 |
60 BluetoothDispatcherHost::~BluetoothDispatcherHost() { | 58 BluetoothDispatcherHost::~BluetoothDispatcherHost() { |
61 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 59 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
62 // Clear adapter, releasing observer references. | 60 // Clear adapter, releasing observer references. |
63 set_adapter(scoped_refptr<device::BluetoothAdapter>()); | 61 set_adapter(scoped_refptr<device::BluetoothAdapter>()); |
64 } | 62 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 int thread_id, | 126 int thread_id, |
129 int request_id, | 127 int request_id, |
130 const std::string& device_instance_id) { | 128 const std::string& device_instance_id) { |
131 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 129 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
132 // TODO(ortuno): Add actual implementation of connectGATT. This needs to be | 130 // TODO(ortuno): Add actual implementation of connectGATT. This needs to be |
133 // done after the "allowed devices map" is implemented. | 131 // done after the "allowed devices map" is implemented. |
134 Send(new BluetoothMsg_ConnectGATTSuccess(thread_id, request_id, | 132 Send(new BluetoothMsg_ConnectGATTSuccess(thread_id, request_id, |
135 device_instance_id)); | 133 device_instance_id)); |
136 } | 134 } |
137 | 135 |
138 void BluetoothDispatcherHost::OnSetBluetoothMockDataSetForTesting( | 136 void BluetoothDispatcherHost::SetBluetoothAdapterForTesting( |
scheib
2015/05/16 01:00:34
Move to match declaration order.
ortuno
2015/05/18 17:40:17
Done.
| |
139 const std::string& name) { | 137 const std::string& name) { |
140 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 138 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
141 if (name == "RejectRequestDevice_NotFoundError") { | 139 if (name == "RejectRequestDevice_NotFoundError") { |
142 bluetooth_mock_data_set_ = MockData::REJECT; | 140 bluetooth_mock_data_set_ = MockData::REJECT; |
143 bluetooth_request_device_reject_type_ = BluetoothError::NOT_FOUND; | 141 bluetooth_request_device_reject_type_ = BluetoothError::NOT_FOUND; |
144 } else if (name == "RejectRequestDevice_SecurityError") { | 142 } else if (name == "RejectRequestDevice_SecurityError") { |
145 bluetooth_mock_data_set_ = MockData::REJECT; | 143 bluetooth_mock_data_set_ = MockData::REJECT; |
146 bluetooth_request_device_reject_type_ = BluetoothError::SECURITY; | 144 bluetooth_request_device_reject_type_ = BluetoothError::SECURITY; |
147 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove. | 145 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove. |
148 name == "Single Empty Device") { | 146 name == "Single Empty Device") { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 | 210 |
213 void BluetoothDispatcherHost::OnDiscoverySessionStoppedError(int thread_id, | 211 void BluetoothDispatcherHost::OnDiscoverySessionStoppedError(int thread_id, |
214 int request_id) { | 212 int request_id) { |
215 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 213 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
216 DLOG(WARNING) << "BluetoothDispatcherHost::OnDiscoverySessionStoppedError"; | 214 DLOG(WARNING) << "BluetoothDispatcherHost::OnDiscoverySessionStoppedError"; |
217 Send(new BluetoothMsg_RequestDeviceError(thread_id, request_id, | 215 Send(new BluetoothMsg_RequestDeviceError(thread_id, request_id, |
218 BluetoothError::NOT_FOUND)); | 216 BluetoothError::NOT_FOUND)); |
219 } | 217 } |
220 | 218 |
221 } // namespace content | 219 } // namespace content |
OLD | NEW |