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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_ 5 #ifndef EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_
6 #define EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_ 6 #define EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
9 #include "extensions/renderer/object_backed_native_handler.h" 10 #include "extensions/renderer/object_backed_native_handler.h"
10 11
11 namespace extensions { 12 namespace extensions {
12 class ScriptContext; 13 class ScriptContext;
13 14
14 // Native functions for JS to run callbacks upon RenderFrame events. 15 // Native functions for JS to run callbacks upon RenderFrame events.
15 class RenderFrameObserverNatives : public ObjectBackedNativeHandler { 16 class RenderFrameObserverNatives : public ObjectBackedNativeHandler {
16 public: 17 public:
17 explicit RenderFrameObserverNatives(ScriptContext* context); 18 explicit RenderFrameObserverNatives(ScriptContext* context);
19 ~RenderFrameObserverNatives() override;
18 20
19 private: 21 private:
22 void Invalidate() override;
23
20 // Runs a callback upon creation of new document element inside a render frame 24 // Runs a callback upon creation of new document element inside a render frame
21 // (document.documentElement). 25 // (document.documentElement).
22 void OnDocumentElementCreated( 26 void OnDocumentElementCreated(
23 const v8::FunctionCallbackInfo<v8::Value>& args); 27 const v8::FunctionCallbackInfo<v8::Value>& args);
24 28
29 void InvokeCallback(v8::Global<v8::Function> callback, bool succeeded);
30
31 base::WeakPtrFactory<RenderFrameObserverNatives> weak_ptr_factory_;
32
25 DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverNatives); 33 DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverNatives);
26 }; 34 };
27 35
28 } // namespace extensions 36 } // namespace extensions
29 37
30 #endif // EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_ 38 #endif // EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698