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

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

Issue 1082273006: bluetooth: Impl uses new WebBluetoothGATTRemoteServer content/browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes based on comments 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 18 matching lines...) Expand all
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
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(
144 int thread_id,
145 int request_id,
146 const std::string& device_instance_id) {
147 DCHECK_CURRENTLY_ON(BrowserThread::IO);
148 BrowserThread::PostTask(BrowserThread::UI,
149 FROM_HERE,
150 base::Bind(
151 &BluetoothDispatcherHost::OnConnectGATTOnUI,
152 this, thread_id, request_id, device_instance_id));
153 }
154
155 void BluetoothDispatcherHost::OnConnectGATTOnUI(
156 int thread_id,
157 int request_id,
158 const std::string& device_instance_id) {
159 DCHECK_CURRENTLY_ON(BrowserThread::UI);
160 // TODO(ortuno): Add actual implementation of connectGATT. This needs to be
161 // done after the "allowed devices map" is implemented.
162 Send(new BluetoothMsg_ConnectGATTSuccess(thread_id, request_id,
163 device_instance_id));
164 }
165
142 void BluetoothDispatcherHost::OnSetBluetoothMockDataSetForTesting( 166 void BluetoothDispatcherHost::OnSetBluetoothMockDataSetForTesting(
143 const std::string& name) { 167 const std::string& name) {
144 DCHECK_CURRENTLY_ON(BrowserThread::IO); 168 DCHECK_CURRENTLY_ON(BrowserThread::IO);
145 if (name == "RejectRequestDevice_NotFoundError") { 169 if (name == "RejectRequestDevice_NotFoundError") {
146 bluetooth_mock_data_set_ = MockData::REJECT; 170 bluetooth_mock_data_set_ = MockData::REJECT;
147 bluetooth_request_device_reject_type_ = BluetoothError::NOT_FOUND; 171 bluetooth_request_device_reject_type_ = BluetoothError::NOT_FOUND;
148 } else if (name == "RejectRequestDevice_SecurityError") { 172 } else if (name == "RejectRequestDevice_SecurityError") {
149 bluetooth_mock_data_set_ = MockData::REJECT; 173 bluetooth_mock_data_set_ = MockData::REJECT;
150 bluetooth_request_device_reject_type_ = BluetoothError::SECURITY; 174 bluetooth_request_device_reject_type_ = BluetoothError::SECURITY;
151 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove. 175 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove.
152 name == "Single Empty Device") { 176 name == "Single Empty Device") {
153 bluetooth_mock_data_set_ = MockData::RESOLVE; 177 bluetooth_mock_data_set_ = MockData::RESOLVE;
154 } else { 178 } else {
155 bluetooth_mock_data_set_ = MockData::NOT_MOCKING; 179 bluetooth_mock_data_set_ = MockData::NOT_MOCKING;
156 } 180 }
157 } 181 }
158 182
159 } // namespace content 183 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bluetooth/bluetooth_dispatcher_host.h ('k') | content/child/bluetooth/bluetooth_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698