Chromium Code Reviews| Index: content/child/bluetooth/web_bluetooth_impl.cc |
| diff --git a/content/child/bluetooth/web_bluetooth_impl.cc b/content/child/bluetooth/web_bluetooth_impl.cc |
| index 406ae7d3a594141c9d079ee02c89586d2afd84a8..5e905002f992034afac28637c5b4d5e0569d3908 100644 |
| --- a/content/child/bluetooth/web_bluetooth_impl.cc |
| +++ b/content/child/bluetooth/web_bluetooth_impl.cc |
| @@ -4,53 +4,39 @@ |
| #include "content/child/bluetooth/web_bluetooth_impl.h" |
| +#include "content/child/bluetooth/bluetooth_dispatcher.h" |
| +#include "content/child/thread_safe_sender.h" |
| + |
| namespace content { |
| -WebBluetoothImpl::WebBluetoothImpl() |
| - : m_bluetoothMockDataSet(MockData::NOT_MOCKING), |
| - m_bluetoothRequestDeviceRejectType( |
| - blink::WebBluetoothError::NotFoundError) { |
| +WebBluetoothImpl::WebBluetoothImpl(ThreadSafeSender* thread_safe_sender) |
| + : thread_safe_sender_(thread_safe_sender) { |
| +} |
| + |
| +WebBluetoothImpl::~WebBluetoothImpl() { |
| +} |
| + |
| +// TODO: Remove old void version after crrev.com/715613005 lands. |
|
nasko
2014/11/25 23:27:01
nit: TODO(username):
scheib
2014/11/26 00:46:34
Done.
|
| +void WebBluetoothImpl::requestDevice( |
| + blink::WebCallbacks<void, blink::WebBluetoothError>* callbacks) { |
| + GetDispatcher()->requestDevice(callbacks); |
| } |
| +// TODO: Remove old void version after crrev.com/715613005 lands. |
| void WebBluetoothImpl::requestDevice( |
| - blink::WebBluetoothRequestDeviceCallbacks* callbacks) { |
| - // Mock implementation of blink::WebBluetooth until a more complete |
| - // implementation is built out. |
| - switch (m_bluetoothMockDataSet) { |
| - case MockData::NOT_MOCKING: { |
| - blink::WebBluetoothError* error = new blink::WebBluetoothError( |
| - blink::WebBluetoothError::NotFoundError, ""); |
| - callbacks->onError(error); |
| - break; |
| - } |
| - case MockData::REJECT: { |
| - blink::WebBluetoothError* error = |
| - new blink::WebBluetoothError(m_bluetoothRequestDeviceRejectType, ""); |
| - callbacks->onError(error); |
| - break; |
| - } |
| - case MockData::RESOLVE: { |
| - callbacks->onSuccess(); |
| - break; |
| - } |
| - } |
| + blink::WebCallbacks<blink::WebBluetoothDevice, blink::WebBluetoothError>* |
| + callbacks) { |
| + GetDispatcher()->requestDevice(callbacks); |
| } |
| void WebBluetoothImpl::SetBluetoothMockDataSetForTesting( |
| const std::string& name) { |
| - if (name == "RejectRequestDevice_NotFoundError") { |
| - m_bluetoothMockDataSet = MockData::REJECT; |
| - m_bluetoothRequestDeviceRejectType = |
| - blink::WebBluetoothError::NotFoundError; |
| - } else if (name == "RejectRequestDevice_SecurityError") { |
| - m_bluetoothMockDataSet = MockData::REJECT; |
| - m_bluetoothRequestDeviceRejectType = |
| - blink::WebBluetoothError::SecurityError; |
| - } else if (name == "ResolveRequestDevice_Empty") { |
| - m_bluetoothMockDataSet = MockData::RESOLVE; |
| - } else { |
| - m_bluetoothMockDataSet = MockData::NOT_MOCKING; |
| - } |
| + GetDispatcher()->SetBluetoothMockDataSetForTesting(name); |
| +} |
| + |
| +BluetoothDispatcher* WebBluetoothImpl::GetDispatcher() { |
| + return BluetoothDispatcher::GetOrCreateThreadSpecificInstance( |
| + thread_safe_sender_.get()); |
| } |
| } // namespace content |