| 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..5616b746a6f59fc29a16397c14d546956f1f3583 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(scheib): Remove old void version after crrev.com/715613005 lands.
|
| +void WebBluetoothImpl::requestDevice(
|
| + blink::WebCallbacks<void, blink::WebBluetoothError>* callbacks) {
|
| + GetDispatcher()->requestDevice(callbacks);
|
| }
|
|
|
| +// TODO(scheib): 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
|
|
|