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

Side by Side Diff: content/renderer/bluetooth/bluetooth_dispatcher.cc

Issue 1228113004: Put the RenderFrame's ID into a per-frame WebBluetooth, and plumb that back to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@store-request-device-state-in-dispatcher
Patch Set: Rebase Created 5 years, 5 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/renderer/bluetooth/bluetooth_dispatcher.h" 5 #include "content/renderer/bluetooth/bluetooth_dispatcher.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 IPC_MESSAGE_HANDLER(BluetoothMsg_WriteCharacteristicValueSuccess, 142 IPC_MESSAGE_HANDLER(BluetoothMsg_WriteCharacteristicValueSuccess,
143 OnWriteValueSuccess); 143 OnWriteValueSuccess);
144 IPC_MESSAGE_HANDLER(BluetoothMsg_WriteCharacteristicValueError, 144 IPC_MESSAGE_HANDLER(BluetoothMsg_WriteCharacteristicValueError,
145 OnWriteValueError); 145 OnWriteValueError);
146 IPC_MESSAGE_UNHANDLED(handled = false) 146 IPC_MESSAGE_UNHANDLED(handled = false)
147 IPC_END_MESSAGE_MAP() 147 IPC_END_MESSAGE_MAP()
148 DCHECK(handled) << "Unhandled message:" << msg.type(); 148 DCHECK(handled) << "Unhandled message:" << msg.type();
149 } 149 }
150 150
151 void BluetoothDispatcher::requestDevice( 151 void BluetoothDispatcher::requestDevice(
152 int frame_routing_id,
152 const WebRequestDeviceOptions& options, 153 const WebRequestDeviceOptions& options,
153 blink::WebBluetoothRequestDeviceCallbacks* callbacks) { 154 blink::WebBluetoothRequestDeviceCallbacks* callbacks) {
154 int request_id = pending_requests_.Add(callbacks); 155 int request_id = pending_requests_.Add(callbacks);
155 156
156 // Convert |options| to its IPC form. 157 // Convert |options| to its IPC form.
157 std::vector<content::BluetoothScanFilter> filters(options.filters.size()); 158 std::vector<content::BluetoothScanFilter> filters(options.filters.size());
158 for (size_t i = 0; i < options.filters.size(); ++i) { 159 for (size_t i = 0; i < options.filters.size(); ++i) {
159 const WebBluetoothScanFilter& web_filter = options.filters[i]; 160 const WebBluetoothScanFilter& web_filter = options.filters[i];
160 BluetoothScanFilter& filter = filters[i]; 161 BluetoothScanFilter& filter = filters[i];
161 filter.services.reserve(web_filter.services.size()); 162 filter.services.reserve(web_filter.services.size());
162 for (const WebString& service : web_filter.services) { 163 for (const WebString& service : web_filter.services) {
163 filter.services.push_back(device::BluetoothUUID(service.utf8())); 164 filter.services.push_back(device::BluetoothUUID(service.utf8()));
164 } 165 }
165 } 166 }
166 std::vector<device::BluetoothUUID> optional_services; 167 std::vector<device::BluetoothUUID> optional_services;
167 optional_services.reserve(options.optionalServices.size()); 168 optional_services.reserve(options.optionalServices.size());
168 for (const WebString& optional_service : options.optionalServices) { 169 for (const WebString& optional_service : options.optionalServices) {
169 optional_services.push_back(device::BluetoothUUID(optional_service.utf8())); 170 optional_services.push_back(device::BluetoothUUID(optional_service.utf8()));
170 } 171 }
171 172
172 Send(new BluetoothHostMsg_RequestDevice(CurrentWorkerId(), request_id, 173 Send(new BluetoothHostMsg_RequestDevice(CurrentWorkerId(), request_id,
173 filters, optional_services)); 174 frame_routing_id, filters,
175 optional_services));
174 } 176 }
175 177
176 void BluetoothDispatcher::connectGATT( 178 void BluetoothDispatcher::connectGATT(
177 const blink::WebString& device_instance_id, 179 const blink::WebString& device_instance_id,
178 blink::WebBluetoothConnectGATTCallbacks* callbacks) { 180 blink::WebBluetoothConnectGATTCallbacks* callbacks) {
179 int request_id = pending_connect_requests_.Add(callbacks); 181 int request_id = pending_connect_requests_.Add(callbacks);
180 Send(new BluetoothHostMsg_ConnectGATT(CurrentWorkerId(), request_id, 182 Send(new BluetoothHostMsg_ConnectGATT(CurrentWorkerId(), request_id,
181 device_instance_id.utf8())); 183 device_instance_id.utf8()));
182 } 184 }
183 185
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 WebBluetoothError error) { 380 WebBluetoothError error) {
379 DCHECK(pending_write_value_requests_.Lookup(request_id)) << request_id; 381 DCHECK(pending_write_value_requests_.Lookup(request_id)) << request_id;
380 382
381 pending_write_value_requests_.Lookup(request_id) 383 pending_write_value_requests_.Lookup(request_id)
382 ->onError(new WebBluetoothError(error)); 384 ->onError(new WebBluetoothError(error));
383 385
384 pending_write_value_requests_.Remove(request_id); 386 pending_write_value_requests_.Remove(request_id);
385 } 387 }
386 388
387 } // namespace content 389 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/bluetooth/bluetooth_dispatcher.h ('k') | content/renderer/bluetooth/web_bluetooth_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698