Chromium Code Reviews| Index: content/browser/bluetooth/bluetooth_dispatcher_host.cc |
| diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
| index f35103dfd1ebef5f254217bc9e0cb34440efa2be..5e4853d54d4d9a120b44e2c54bddaeb4deca235e 100644 |
| --- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
| +++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
| @@ -13,6 +13,7 @@ |
| #include "base/metrics/histogram.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "content/browser/bad_message.h" |
| +#include "content/browser/frame_host/render_frame_host_impl.h" |
| #include "content/common/bluetooth/bluetooth_messages.h" |
| #include "device/bluetooth/bluetooth_adapter.h" |
| #include "device/bluetooth/bluetooth_adapter_factory.h" |
| @@ -135,8 +136,9 @@ blink::WebBluetoothError TranslateGATTError( |
| namespace content { |
| -BluetoothDispatcherHost::BluetoothDispatcherHost() |
| +BluetoothDispatcherHost::BluetoothDispatcherHost(int render_process_id) |
| : BrowserMessageFilter(BluetoothMsgStart), |
| + render_process_id_(render_process_id), |
| weak_ptr_factory_(this) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| current_delay_time_ = kDelayTime; |
| @@ -187,10 +189,14 @@ BluetoothDispatcherHost::~BluetoothDispatcherHost() { |
| } |
| struct BluetoothDispatcherHost::RequestDeviceSession { |
| - RequestDeviceSession(const std::vector<BluetoothScanFilter>& filters, |
| + RequestDeviceSession(int frame_routing_id, |
|
ortuno
2015/07/15 23:00:46
This is called frame_routing_id but you call it ro
Jeffrey Yasskin
2015/07/17 01:32:44
Yep, this is undone now that it's no longer coming
|
| + const std::vector<BluetoothScanFilter>& filters, |
| const std::vector<BluetoothUUID>& optional_services) |
| - : filters(filters), optional_services(optional_services) {} |
| + : frame_routing_id(frame_routing_id), |
| + filters(filters), |
| + optional_services(optional_services) {} |
| + int frame_routing_id; |
|
scheib
2015/07/16 01:11:46
Perhaps add it when we need it? Or if you have a f
Jeffrey Yasskin
2015/07/17 01:32:44
I've undone this storage. We'll see how it needs t
|
| std::vector<BluetoothScanFilter> filters; |
| std::vector<BluetoothUUID> optional_services; |
| }; |
| @@ -223,16 +229,29 @@ static scoped_ptr<device::BluetoothDiscoveryFilter> ComputeScanFilter( |
| void BluetoothDispatcherHost::OnRequestDevice( |
| int thread_id, |
| int request_id, |
| + int routing_id, |
| const std::vector<BluetoothScanFilter>& filters, |
| const std::vector<BluetoothUUID>& optional_services) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + |
| + RenderFrameHostImpl* render_frame_host = |
| + RenderFrameHostImpl::FromID(render_process_id_, routing_id); |
| + |
| + if (!render_frame_host) { |
| + DLOG(WARNING) |
|
ortuno
2015/07/15 23:00:46
Should we add a histogram for this?
Jeffrey Yasskin
2015/07/17 01:32:44
Will do, but not today. I'll ping Monday when it's
Jeffrey Yasskin
2015/07/21 00:47:05
Done in https://codereview.chromium.org/1248573002
|
| + << "Got a requestDevice IPC without a matching RenderFrameHost: " |
| + << render_process_id_ << ", " << routing_id; |
| + Send(new BluetoothMsg_RequestDeviceError( |
| + thread_id, request_id, WebBluetoothError::RequestDeviceWithoutFrame)); |
| + } |
| + |
| // TODO(scheib): Device selection UI: crbug.com/436280 |
| // TODO(scheib): Utilize BluetoothAdapter::Observer::DeviceAdded/Removed. |
| if (adapter_.get()) { |
| if (!request_device_sessions_ |
| .insert(std::make_pair( |
| std::make_pair(thread_id, request_id), |
| - RequestDeviceSession(filters, optional_services))) |
| + RequestDeviceSession(routing_id, filters, optional_services))) |
| .second) { |
| LOG(ERROR) << "2 requestDevice() calls with the same thread_id (" |
| << thread_id << ") and request_id (" << request_id |