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

Unified Diff: content/renderer/mus/render_widget_window_tree_client_factory.cc

Issue 2268603002: Avoid UAF on ConnectionFilter impls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/public/common/connection_filter.h ('k') | services/navigation/navigation.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/mus/render_widget_window_tree_client_factory.cc
diff --git a/content/renderer/mus/render_widget_window_tree_client_factory.cc b/content/renderer/mus/render_widget_window_tree_client_factory.cc
index 3df64afd9308ca0fea225820e934fae64b9124d2..52923eae18d41c25301d88b596847b259b5a3fd5 100644
--- a/content/renderer/mus/render_widget_window_tree_client_factory.cc
+++ b/content/renderer/mus/render_widget_window_tree_client_factory.cc
@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/sequenced_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/common/render_widget_window_tree_client_factory.mojom.h"
@@ -38,11 +39,9 @@ void BindMusConnectionOnMainThread(
// registered with it.
class RenderWidgetWindowTreeClientFactoryImpl
: public ConnectionFilter,
- public shell::InterfaceFactory<
- mojom::RenderWidgetWindowTreeClientFactory>,
public mojom::RenderWidgetWindowTreeClientFactory {
public:
- RenderWidgetWindowTreeClientFactoryImpl() {
+ RenderWidgetWindowTreeClientFactoryImpl() : weak_factory_(this) {
main_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get();
}
@@ -53,17 +52,12 @@ class RenderWidgetWindowTreeClientFactoryImpl
bool OnConnect(const shell::Identity& remote_identity,
shell::InterfaceRegistry* registry,
shell::Connector* connector) override {
- registry->AddInterface<mojom::RenderWidgetWindowTreeClientFactory>(this);
+ registry->AddInterface(
+ base::Bind(&RenderWidgetWindowTreeClientFactoryImpl::CreateFactory,
+ weak_factory_.GetWeakPtr()));
return true;
}
- // shell::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>:
- void Create(const shell::Identity& remote_identity,
- mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory>
- request) override {
- bindings_.AddBinding(this, std::move(request));
- }
-
// mojom::RenderWidgetWindowTreeClientFactory implementation.
void CreateWindowTreeClientForRenderWidget(
uint32_t routing_id,
@@ -73,8 +67,14 @@ class RenderWidgetWindowTreeClientFactoryImpl
base::Passed(&request)));
}
+ void CreateFactory(
+ mojom::RenderWidgetWindowTreeClientFactoryRequest request) {
+ bindings_.AddBinding(this, std::move(request));
+ }
+
scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner_;
mojo::BindingSet<mojom::RenderWidgetWindowTreeClientFactory> bindings_;
+ base::WeakPtrFactory<RenderWidgetWindowTreeClientFactoryImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetWindowTreeClientFactoryImpl);
};
« no previous file with comments | « content/public/common/connection_filter.h ('k') | services/navigation/navigation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698