Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" | |
| 6 | |
| 7 #include "content/common/bluetooth/bluetooth_messages.h" | |
| 8 | |
| 9 namespace content { | |
| 10 | |
| 11 BluetoothDispatcherHost::BluetoothDispatcherHost() | |
| 12 : BrowserMessageFilter(BluetoothMsgStart), | |
| 13 bluetooth_mock_data_set_(MockData::NOT_MOCKING), | |
| 14 bluetoothRequestDeviceRejectType_(BluetoothError::NOT_FOUND) { | |
| 15 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 16 } | |
| 17 | |
| 18 bool BluetoothDispatcherHost::OnMessageReceived(const IPC::Message& message) { | |
| 19 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 20 bool handled = true; | |
| 21 IPC_BEGIN_MESSAGE_MAP(BluetoothDispatcherHost, message) | |
| 22 IPC_MESSAGE_HANDLER(BluetoothHostMsg_RequestDevice, OnRequestDevice) | |
| 23 IPC_MESSAGE_HANDLER(BluetoothHostMsg_SetBluetoothMockDataSetForTesting, | |
| 24 OnSetBluetoothMockDataSetForTesting) | |
| 25 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 26 IPC_END_MESSAGE_MAP() | |
| 27 return handled; | |
| 28 } | |
| 29 | |
| 30 BluetoothDispatcherHost::~BluetoothDispatcherHost() { | |
| 31 } | |
| 32 | |
| 33 void BluetoothDispatcherHost::OnRequestDevice(int thread_id, int request_id) { | |
| 34 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 35 // Mock implementation util a more complete implementation is built out. | |
| 36 switch (bluetooth_mock_data_set_) { | |
| 37 case MockData::NOT_MOCKING: { | |
| 38 Send(new BluetoothMsg_RequestDeviceError(thread_id, request_id, | |
| 39 BluetoothError::NOT_FOUND)); | |
| 40 return; | |
| 41 } | |
| 42 case MockData::REJECT: { | |
| 43 Send(new BluetoothMsg_RequestDeviceError( | |
| 44 thread_id, request_id, bluetoothRequestDeviceRejectType_)); | |
| 45 return; | |
| 46 } | |
| 47 case MockData::RESOLVE: { | |
| 48 Send(new BluetoothMsg_RequestDeviceSuccess(thread_id, request_id, | |
| 49 "Empty Mock deviceId")); | |
| 50 return; | |
| 51 } | |
| 52 } | |
| 53 NOTREACHED(); | |
| 54 } | |
| 55 | |
| 56 void BluetoothDispatcherHost::OnSetBluetoothMockDataSetForTesting( | |
| 57 const std::string& name) { | |
| 58 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 59 if (name == "RejectRequestDevice_NotFoundError") { | |
| 60 bluetooth_mock_data_set_ = MockData::REJECT; | |
| 61 bluetoothRequestDeviceRejectType_ = BluetoothError::NOT_FOUND; | |
| 62 } else if (name == "RejectRequestDevice_SecurityError") { | |
| 63 bluetooth_mock_data_set_ = MockData::REJECT; | |
| 64 bluetoothRequestDeviceRejectType_ = BluetoothError::SECURITY; | |
| 65 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib) Remove. | |
|
nasko
2014/11/25 23:27:01
nit: The TODO still needs ":" after ")".
scheib
2014/11/26 00:46:34
Done.
| |
| 66 name == "Single Empty Device") { | |
| 67 bluetooth_mock_data_set_ = MockData::RESOLVE; | |
| 68 } else { | |
| 69 bluetooth_mock_data_set_ = MockData::NOT_MOCKING; | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 } // namespace content | |
| OLD | NEW |