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

Unified Diff: content/browser/bluetooth/web_bluetooth_service_impl.cc

Issue 2059543002: bluetooth: Move FactoryWrapper to device and expose a function for testing in chooser controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Fix typo Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/bluetooth/web_bluetooth_service_impl.cc
diff --git a/content/browser/bluetooth/web_bluetooth_service_impl.cc b/content/browser/bluetooth/web_bluetooth_service_impl.cc
index 46c94f109ceaf62569af389968a7edaec44d75c4..a604e1e20655a4a6f540c0f7b112a5c3e661f7ff 100644
--- a/content/browser/bluetooth/web_bluetooth_service_impl.cc
+++ b/content/browser/bluetooth/web_bluetooth_service_impl.cc
@@ -15,7 +15,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
-#include "content/browser/bluetooth/bluetooth_adapter_factory_wrapper.h"
#include "content/browser/bluetooth/bluetooth_blacklist.h"
#include "content/browser/bluetooth/bluetooth_device_chooser_controller.h"
#include "content/browser/bluetooth/bluetooth_metrics.h"
@@ -25,8 +24,11 @@
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
+#include "device/bluetooth/bluetooth_adapter_factory_wrapper.h"
#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
+using device::BluetoothAdapterFactoryWrapper;
+
namespace content {
namespace {
@@ -296,8 +298,8 @@ void WebBluetoothServiceImpl::RequestDevice(
RecordRequestDeviceOptions(options);
if (!GetAdapter()) {
- if (GetBluetoothAdapterFactoryWrapper()->IsBluetoothAdapterAvailable()) {
- GetBluetoothAdapterFactoryWrapper()->AcquireAdapter(
+ if (BluetoothAdapterFactoryWrapper::Get().IsBluetoothAdapterAvailable()) {
+ BluetoothAdapterFactoryWrapper::Get().AcquireAdapter(
this, base::Bind(&WebBluetoothServiceImpl::RequestDeviceImpl,
weak_ptr_factory_.GetWeakPtr(),
base::Passed(std::move(options)), callback));
@@ -655,9 +657,8 @@ void WebBluetoothServiceImpl::RequestDeviceImpl(
// never get a request with an open chooser.
CHECK(!device_chooser_controller_.get());
- device_chooser_controller_.reset(new BluetoothDeviceChooserController(
- this, render_frame_host_, adapter,
- GetBluetoothAdapterFactoryWrapper()->GetScanDuration()));
+ device_chooser_controller_.reset(
+ new BluetoothDeviceChooserController(this, render_frame_host_, adapter));
device_chooser_controller_->GetDevice(
std::move(options),
@@ -926,15 +927,8 @@ RenderProcessHost* WebBluetoothServiceImpl::GetRenderProcessHost() {
return render_frame_host_->GetProcess();
}
-BluetoothAdapterFactoryWrapper*
-WebBluetoothServiceImpl::GetBluetoothAdapterFactoryWrapper() {
- RenderProcessHostImpl* render_process_host_impl =
- static_cast<RenderProcessHostImpl*>(GetRenderProcessHost());
- return render_process_host_impl->GetBluetoothAdapterFactoryWrapper();
-}
-
device::BluetoothAdapter* WebBluetoothServiceImpl::GetAdapter() {
- return GetBluetoothAdapterFactoryWrapper()->GetAdapter(this);
+ return BluetoothAdapterFactoryWrapper::Get().GetAdapter(this);
}
void WebBluetoothServiceImpl::CrashRendererAndClosePipe(
@@ -956,7 +950,7 @@ void WebBluetoothServiceImpl::ClearState() {
new FrameConnectedBluetoothDevices(render_frame_host_));
allowed_devices_map_ = BluetoothAllowedDevicesMap();
device_chooser_controller_.reset();
- GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this);
+ BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698