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

Unified Diff: components/dom_distiller/content/browser/distillability_driver.cc

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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: components/dom_distiller/content/browser/distillability_driver.cc
diff --git a/components/dom_distiller/content/browser/distillability_driver.cc b/components/dom_distiller/content/browser/distillability_driver.cc
index f2275b34a9bf6d9c248c6ba5142488532f56793a..d87d36d0b6590f34c5418a37470f17e7ad75f291 100644
--- a/components/dom_distiller/content/browser/distillability_driver.cc
+++ b/components/dom_distiller/content/browser/distillability_driver.cc
@@ -8,6 +8,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/shell/public/cpp/interface_registry.h"
DEFINE_WEB_CONTENTS_USER_DATA_KEY(
@@ -19,11 +20,9 @@ namespace dom_distiller {
// renderer to notify the browser that a page is distillable.
class DistillabilityServiceImpl : public mojom::DistillabilityService {
public:
- DistillabilityServiceImpl(
- mojo::InterfaceRequest<mojom::DistillabilityService> request,
+ explicit DistillabilityServiceImpl(
base::WeakPtr<DistillabilityDriver> distillability_driver)
- : binding_(this, std::move(request)),
- distillability_driver_(distillability_driver) {}
+ : distillability_driver_(distillability_driver) {}
~DistillabilityServiceImpl() override {
if (!distillability_driver_) return;
@@ -36,7 +35,6 @@ class DistillabilityServiceImpl : public mojom::DistillabilityService {
}
private:
- mojo::StrongBinding<mojom::DistillabilityService> binding_;
base::WeakPtr<DistillabilityDriver> distillability_driver_;
};
@@ -55,7 +53,9 @@ DistillabilityDriver::~DistillabilityDriver() {
void DistillabilityDriver::CreateDistillabilityService(
mojo::InterfaceRequest<mojom::DistillabilityService> request) {
- new DistillabilityServiceImpl(std::move(request), weak_factory_.GetWeakPtr());
+ mojo::MakeStrongBinding(
+ base::MakeUnique<DistillabilityServiceImpl>(weak_factory_.GetWeakPtr()),
+ std::move(request));
}
void DistillabilityDriver::SetDelegate(

Powered by Google App Engine
This is Rietveld 408576698