Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 BluetoothAdapterFactory::GetAdapter( | 29 BluetoothAdapterFactory::GetAdapter( |
| 30 base::Bind(&BluetoothDispatcherHost::set_adapter, host)); | 30 base::Bind(&BluetoothDispatcherHost::set_adapter, host)); |
| 31 return host; | 31 return host; |
| 32 } | 32 } |
| 33 | 33 |
| 34 bool BluetoothDispatcherHost::OnMessageReceived(const IPC::Message& message) { | 34 bool BluetoothDispatcherHost::OnMessageReceived(const IPC::Message& message) { |
| 35 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 35 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 36 bool handled = true; | 36 bool handled = true; |
| 37 IPC_BEGIN_MESSAGE_MAP(BluetoothDispatcherHost, message) | 37 IPC_BEGIN_MESSAGE_MAP(BluetoothDispatcherHost, message) |
| 38 IPC_MESSAGE_HANDLER(BluetoothHostMsg_RequestDevice, OnRequestDevice) | 38 IPC_MESSAGE_HANDLER(BluetoothHostMsg_RequestDevice, OnRequestDevice) |
| 39 IPC_MESSAGE_HANDLER(BluetoothHostMsg_ConnectGATT, OnConnectGATT) | |
| 39 IPC_MESSAGE_HANDLER(BluetoothHostMsg_SetBluetoothMockDataSetForTesting, | 40 IPC_MESSAGE_HANDLER(BluetoothHostMsg_SetBluetoothMockDataSetForTesting, |
| 40 OnSetBluetoothMockDataSetForTesting) | 41 OnSetBluetoothMockDataSetForTesting) |
| 41 IPC_MESSAGE_UNHANDLED(handled = false) | 42 IPC_MESSAGE_UNHANDLED(handled = false) |
| 42 IPC_END_MESSAGE_MAP() | 43 IPC_END_MESSAGE_MAP() |
| 43 return handled; | 44 return handled; |
| 44 } | 45 } |
| 45 | 46 |
| 46 BluetoothDispatcherHost::BluetoothDispatcherHost() | 47 BluetoothDispatcherHost::BluetoothDispatcherHost() |
| 47 : BrowserMessageFilter(BluetoothMsgStart), | 48 : BrowserMessageFilter(BluetoothMsgStart), |
| 48 bluetooth_mock_data_set_(MockData::NOT_MOCKING), | 49 bluetooth_mock_data_set_(MockData::NOT_MOCKING), |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 false, // connected | 133 false, // connected |
| 133 uuids); // uuids | 134 uuids); // uuids |
| 134 Send(new BluetoothMsg_RequestDeviceSuccess(thread_id, request_id, | 135 Send(new BluetoothMsg_RequestDeviceSuccess(thread_id, request_id, |
| 135 device_ipc)); | 136 device_ipc)); |
| 136 return; | 137 return; |
| 137 } | 138 } |
| 138 } | 139 } |
| 139 NOTREACHED(); | 140 NOTREACHED(); |
| 140 } | 141 } |
| 141 | 142 |
| 143 void BluetoothDispatcherHost::OnConnectGATT(int thread_id, int request_id, | |
| 144 std::string instance_id) { | |
| 145 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 146 BrowserThread::PostTask(BrowserThread::UI, | |
| 147 FROM_HERE, | |
| 148 base::Bind( | |
| 149 &BluetoothDispatcherHost::OnConnectGATTOnUI, | |
| 150 this, thread_id, request_id, instance_id)); | |
| 151 } | |
| 152 | |
| 153 void BluetoothDispatcherHost::OnConnectGATTOnUI(int thread_id, int request_id, | |
| 154 std::string instance_id) { | |
| 155 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 156 // TODO(ortuno): Add actual implementation of connectGATT. | |
|
Tom Sepez
2015/04/20 15:54:00
Please CC me when you fix the TODO. I'd like to m
scheib
2015/04/20 16:50:12
Thanks Tom, good point:
Thread and request ID are
scheib
2015/04/20 16:51:21
Gio, please expand this TODO comment to clearly ca
ortuno
2015/04/20 20:09:33
Will do.
| |
| 157 Send(new BluetoothMsg_ConnectGATTSuccess(thread_id, request_id, instance_id)); | |
| 158 } | |
| 159 | |
| 142 void BluetoothDispatcherHost::OnSetBluetoothMockDataSetForTesting( | 160 void BluetoothDispatcherHost::OnSetBluetoothMockDataSetForTesting( |
| 143 const std::string& name) { | 161 const std::string& name) { |
| 144 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 162 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 145 if (name == "RejectRequestDevice_NotFoundError") { | 163 if (name == "RejectRequestDevice_NotFoundError") { |
| 146 bluetooth_mock_data_set_ = MockData::REJECT; | 164 bluetooth_mock_data_set_ = MockData::REJECT; |
| 147 bluetooth_request_device_reject_type_ = BluetoothError::NOT_FOUND; | 165 bluetooth_request_device_reject_type_ = BluetoothError::NOT_FOUND; |
| 148 } else if (name == "RejectRequestDevice_SecurityError") { | 166 } else if (name == "RejectRequestDevice_SecurityError") { |
| 149 bluetooth_mock_data_set_ = MockData::REJECT; | 167 bluetooth_mock_data_set_ = MockData::REJECT; |
| 150 bluetooth_request_device_reject_type_ = BluetoothError::SECURITY; | 168 bluetooth_request_device_reject_type_ = BluetoothError::SECURITY; |
| 151 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove. | 169 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove. |
| 152 name == "Single Empty Device") { | 170 name == "Single Empty Device") { |
| 153 bluetooth_mock_data_set_ = MockData::RESOLVE; | 171 bluetooth_mock_data_set_ = MockData::RESOLVE; |
| 154 } else { | 172 } else { |
| 155 bluetooth_mock_data_set_ = MockData::NOT_MOCKING; | 173 bluetooth_mock_data_set_ = MockData::NOT_MOCKING; |
| 156 } | 174 } |
| 157 } | 175 } |
| 158 | 176 |
| 159 } // namespace content | 177 } // namespace content |
| OLD | NEW |