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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2565913002: [Onion Soup] Move WebBluetoothImpl from //content/renderer/bluetooth to Blink's bluetooth module (Closed)
Patch Set: address comments Created 4 years 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/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 07fc76005bd703b1b9a19dadc775e921fefab82b..4a8f226edba719bcbfe86f831f393d9e2c2d111c 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -14,6 +14,7 @@
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/process/kill.h"
+#include "base/stl_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "content/browser/accessibility/ax_tree_id_registry.h"
@@ -3208,19 +3209,24 @@ void RenderFrameHostImpl::AXContentTreeDataToAXTreeData(
WebBluetoothServiceImpl* RenderFrameHostImpl::CreateWebBluetoothService(
blink::mojom::WebBluetoothServiceRequest request) {
- DCHECK(!web_bluetooth_service_);
- web_bluetooth_service_.reset(
- new WebBluetoothServiceImpl(this, std::move(request)));
- // RFHI owns web_bluetooth_service_ and web_bluetooth_service owns the
- // binding_ which may run the error handler. binding_ can't run the error
+ // RFHI owns |web_bluetooth_services_| and |web_bluetooth_service| owns the
+ // |binding_| which may run the error handler. |binding_| can't run the error
// handler after it's destroyed so it can't run after the RFHI is destroyed.
- web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind(
- &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this)));
- return web_bluetooth_service_.get();
-}
-
-void RenderFrameHostImpl::DeleteWebBluetoothService() {
- web_bluetooth_service_.reset();
+ std::unique_ptr<WebBluetoothServiceImpl> web_bluetooth_service =
+ base::MakeUnique<WebBluetoothServiceImpl>(this, std::move(request));
+ web_bluetooth_service->SetClientConnectionErrorHandler(
+ base::Bind(&RenderFrameHostImpl::DeleteWebBluetoothService,
+ base::Unretained(this), web_bluetooth_service.get()));
+ auto it = web_bluetooth_services_.insert(std::move(web_bluetooth_service));
+ return it.first->get();
+}
+
+void RenderFrameHostImpl::DeleteWebBluetoothService(
+ WebBluetoothServiceImpl* web_bluetooth_service) {
+ auto it = web_bluetooth_services_.find(
+ base::FakeUniquePtr<WebBluetoothServiceImpl>(web_bluetooth_service));
Reilly Grant (use Gerrit) 2016/12/20 02:08:16 Add a helper method base::MakeFakeUniquePtr() so t
juncai 2016/12/20 22:33:42 Discussed offline with reillyg@, using base::FakeU
+ DCHECK(it != web_bluetooth_services_.end());
+ web_bluetooth_services_.erase(it);
}
void RenderFrameHostImpl::Create(

Powered by Google App Engine
This is Rietveld 408576698