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

Unified Diff: extensions/renderer/render_frame_observer_natives.h

Issue 1684953002: Fix re-entrancy and lifetime issue in RenderFrameObserverNatives::OnDocumentElementCreated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits + Invalidate weak ptrs upon Invalidate() Created 4 years, 10 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: extensions/renderer/render_frame_observer_natives.h
diff --git a/extensions/renderer/render_frame_observer_natives.h b/extensions/renderer/render_frame_observer_natives.h
index 946377d71dc09cda820b848fc47c4bd0cc02e6b8..4e81e3bc8b7729b3b70b2a0c70f6f5cbe5828a62 100644
--- a/extensions/renderer/render_frame_observer_natives.h
+++ b/extensions/renderer/render_frame_observer_natives.h
@@ -6,6 +6,7 @@
#define EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "extensions/renderer/object_backed_native_handler.h"
namespace extensions {
@@ -15,13 +16,20 @@ class ScriptContext;
class RenderFrameObserverNatives : public ObjectBackedNativeHandler {
public:
explicit RenderFrameObserverNatives(ScriptContext* context);
+ ~RenderFrameObserverNatives() override;
private:
+ void Invalidate() override;
+
// Runs a callback upon creation of new document element inside a render frame
// (document.documentElement).
void OnDocumentElementCreated(
const v8::FunctionCallbackInfo<v8::Value>& args);
+ void InvokeCallback(v8::Global<v8::Function> callback, bool succeeded);
+
+ base::WeakPtrFactory<RenderFrameObserverNatives> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverNatives);
};

Powered by Google App Engine
This is Rietveld 408576698