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

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

Issue 2157493003: Revert of bluetooth: Use WebBluetoothDeviceId instead of string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-uuid-typemap
Patch Set: Created 4 years, 5 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
« no previous file with comments | « content/browser/bluetooth/web_bluetooth_service_impl.h ('k') | content/common/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fe4d4b71cf96321e93601fa76ab4931b0972c9c7..355e344b471a234ced30d2860c79d9a83d9e6dbb 100644
--- a/content/browser/bluetooth/web_bluetooth_service_impl.cc
+++ b/content/browser/bluetooth/web_bluetooth_service_impl.cc
@@ -20,7 +20,6 @@
#include "content/browser/bluetooth/bluetooth_metrics.h"
#include "content/browser/bluetooth/frame_connected_bluetooth_devices.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
-#include "content/common/bluetooth/web_bluetooth_device_id.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
@@ -238,11 +237,13 @@
device::BluetoothDevice* device) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!device->IsGattConnected()) {
- base::Optional<WebBluetoothDeviceId> device_id =
+ std::string device_id =
connected_devices_->CloseConnectionToDeviceWithAddress(
device->GetAddress());
- if (device_id && client_) {
- client_->GattServerDisconnected(device_id.value());
+ if (!device_id.empty()) {
+ if (client_) {
+ client_->GattServerDisconnected(device_id);
+ }
}
}
}
@@ -330,7 +331,7 @@
}
void WebBluetoothServiceImpl::RemoteServerConnect(
- const WebBluetoothDeviceId& device_id,
+ const mojo::String& device_id,
const RemoteServerConnectCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::CONNECT_GATT);
@@ -364,23 +365,24 @@
weak_ptr_factory_.GetWeakPtr(), device_id, start_time,
callback),
base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionFailed,
- weak_ptr_factory_.GetWeakPtr(), start_time, callback));
+ weak_ptr_factory_.GetWeakPtr(), device_id, start_time,
+ callback));
}
void WebBluetoothServiceImpl::RemoteServerDisconnect(
- const WebBluetoothDeviceId& device_id) {
+ const mojo::String& device_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
RecordWebBluetoothFunctionCall(
UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT);
if (connected_devices_->IsConnectedToDeviceWithId(device_id)) {
- VLOG(1) << "Disconnecting device: " << device_id.str();
+ VLOG(1) << "Disconnecting device: " << device_id;
connected_devices_->CloseConnectionToDeviceWithId(device_id);
}
}
void WebBluetoothServiceImpl::RemoteServerGetPrimaryServices(
- const WebBluetoothDeviceId& device_id,
+ const mojo::String& device_id,
blink::mojom::WebBluetoothGATTQueryQuantity quantity,
const base::Optional<BluetoothUUID>& services_uuid,
const RemoteServerGetPrimaryServicesCallback& callback) {
@@ -689,7 +691,7 @@
}
void WebBluetoothServiceImpl::RemoteServerGetPrimaryServicesImpl(
- const WebBluetoothDeviceId& device_id,
+ const mojo::String& device_id,
blink::mojom::WebBluetoothGATTQueryQuantity quantity,
const base::Optional<BluetoothUUID>& services_uuid,
const RemoteServerGetPrimaryServicesCallback& callback,
@@ -761,7 +763,7 @@
return;
}
- const WebBluetoothDeviceId device_id_for_origin =
+ const std::string device_id_for_origin =
allowed_devices_map_.AddDevice(GetOrigin(), device_address, options);
VLOG(1) << "Device: " << device->GetNameForDisplay();
@@ -798,7 +800,7 @@
}
void WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess(
- const WebBluetoothDeviceId& device_id,
+ const std::string& device_id,
base::TimeTicks start_time,
const RemoteServerConnectCallback& callback,
std::unique_ptr<device::BluetoothGattConnection> connection) {
@@ -811,6 +813,7 @@
}
void WebBluetoothServiceImpl::OnCreateGATTConnectionFailed(
+ const std::string& device_id,
base::TimeTicks start_time,
const RemoteServerConnectCallback& callback,
device::BluetoothDevice::ConnectErrorCode error_code) {
@@ -882,7 +885,7 @@
}
CacheQueryResult WebBluetoothServiceImpl::QueryCacheForDevice(
- const WebBluetoothDeviceId& device_id) {
+ const std::string& device_id) {
const std::string& device_address =
allowed_devices_map_.GetDeviceAddress(GetOrigin(), device_id);
if (device_address.empty()) {
@@ -912,15 +915,15 @@
return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER);
}
- const WebBluetoothDeviceId* device_id =
+ const std::string& device_id =
allowed_devices_map_.GetDeviceId(GetOrigin(), device_iter->second);
// Kill the renderer if origin is not allowed to access the device.
- if (device_id == nullptr) {
+ if (device_id.empty()) {
CrashRendererAndClosePipe(bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN);
return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER);
}
- CacheQueryResult result = QueryCacheForDevice(*device_id);
+ CacheQueryResult result = QueryCacheForDevice(device_id);
if (result.outcome != CacheQueryOutcome::SUCCESS) {
return result;
}
@@ -929,7 +932,7 @@
if (result.service == nullptr) {
result.outcome = CacheQueryOutcome::NO_SERVICE;
} else if (!allowed_devices_map_.IsOriginAllowedToAccessService(
- GetOrigin(), *device_id, result.service->GetUUID())) {
+ GetOrigin(), device_id, result.service->GetUUID())) {
CrashRendererAndClosePipe(bad_message::BDH_SERVICE_NOT_ALLOWED_FOR_ORIGIN);
return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER);
}
« no previous file with comments | « content/browser/bluetooth/web_bluetooth_service_impl.h ('k') | content/common/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698