Commit 6993ff96 authored by mohan.reddy's avatar mohan.reddy Committed by Commit bot

Changing the order of initialization WeakPtrFactory

Changing in the intialization order of WeakPtrFactory such that all
member variables should appear before the WeakPtrFactory to ensure
that any WeakPtrs to Controller are invalidated before its members
variable's destructors are executed, rendering them invalid.

BUG=303818

Review URL: https://codereview.chromium.org/565013003

Cr-Commit-Position: refs/heads/master@{#294567}
parent 66f9d03f
...@@ -38,8 +38,8 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout) ...@@ -38,8 +38,8 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout)
arm_cpu_time_(), arm_cpu_time_(),
#endif #endif
task_observer_(this), task_observer_(this),
weak_factory_(this), suspended_(false),
suspended_(false) { weak_factory_(this) {
DCHECK(timeout >= 0); DCHECK(timeout >= 0);
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -88,14 +88,14 @@ class GpuWatchdogThread : public base::Thread, ...@@ -88,14 +88,14 @@ class GpuWatchdogThread : public base::Thread,
// the task was posted. // the task was posted.
base::Time suspension_timeout_; base::Time suspension_timeout_;
base::WeakPtrFactory<GpuWatchdogThread> weak_factory_;
bool suspended_; bool suspended_;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
FILE* tty_file_; FILE* tty_file_;
#endif #endif
base::WeakPtrFactory<GpuWatchdogThread> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread);
}; };
......
...@@ -82,9 +82,9 @@ void IPCEchoBindings::Install(base::WeakPtr<IPCEcho> echo, ...@@ -82,9 +82,9 @@ void IPCEchoBindings::Install(base::WeakPtr<IPCEcho> echo,
IPCEcho::IPCEcho(blink::WebDocument document, IPCEcho::IPCEcho(blink::WebDocument document,
IPC::Sender* sender, IPC::Sender* sender,
int routing_id) int routing_id)
: weak_factory_(this), : document_(document), sender_(sender), routing_id_(routing_id),
document_(document), sender_(sender), routing_id_(routing_id), last_echo_id_(0),
last_echo_id_(0) { weak_factory_(this) {
} }
IPCEcho::~IPCEcho() { IPCEcho::~IPCEcho() {
......
...@@ -41,12 +41,14 @@ class IPCEcho : public base::SupportsWeakPtr<IPCEcho> { ...@@ -41,12 +41,14 @@ class IPCEcho : public base::SupportsWeakPtr<IPCEcho> {
int last_echo_id() const { return last_echo_id_; } int last_echo_id() const { return last_echo_id_; }
int last_echo_size() const { return last_echo_size_; } int last_echo_size() const { return last_echo_size_; }
base::WeakPtrFactory<IPCEcho> weak_factory_;
blink::WebDocument document_; blink::WebDocument document_;
IPC::Sender* sender_; IPC::Sender* sender_;
int routing_id_; int routing_id_;
int last_echo_id_; int last_echo_id_;
int last_echo_size_; int last_echo_size_;
base::WeakPtrFactory<IPCEcho> weak_factory_;
}; };
} // namespace content } // namespace content
......
...@@ -23,8 +23,8 @@ namespace content { ...@@ -23,8 +23,8 @@ namespace content {
AccessibilityNotificationWaiter::AccessibilityNotificationWaiter(Shell* shell) AccessibilityNotificationWaiter::AccessibilityNotificationWaiter(Shell* shell)
: event_to_wait_for_(ui::AX_EVENT_NONE), : event_to_wait_for_(ui::AX_EVENT_NONE),
loop_runner_(new MessageLoopRunner()), loop_runner_(new MessageLoopRunner()),
weak_factory_(this), event_target_id_(0),
event_target_id_(0) { weak_factory_(this) {
WebContents* web_contents = shell->web_contents(); WebContents* web_contents = shell->web_contents();
frame_host_ = static_cast<RenderFrameHostImpl*>( frame_host_ = static_cast<RenderFrameHostImpl*>(
web_contents->GetMainFrame()); web_contents->GetMainFrame());
...@@ -39,8 +39,8 @@ AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( ...@@ -39,8 +39,8 @@ AccessibilityNotificationWaiter::AccessibilityNotificationWaiter(
ui::AXEvent event_type) ui::AXEvent event_type)
: event_to_wait_for_(event_type), : event_to_wait_for_(event_type),
loop_runner_(new MessageLoopRunner()), loop_runner_(new MessageLoopRunner()),
weak_factory_(this), event_target_id_(0),
event_target_id_(0) { weak_factory_(this) {
WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
shell->web_contents()); shell->web_contents());
frame_host_ = static_cast<RenderFrameHostImpl*>( frame_host_ = static_cast<RenderFrameHostImpl*>(
...@@ -57,8 +57,8 @@ AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( ...@@ -57,8 +57,8 @@ AccessibilityNotificationWaiter::AccessibilityNotificationWaiter(
: frame_host_(frame_host), : frame_host_(frame_host),
event_to_wait_for_(event_type), event_to_wait_for_(event_type),
loop_runner_(new MessageLoopRunner()), loop_runner_(new MessageLoopRunner()),
weak_factory_(this), event_target_id_(0),
event_target_id_(0) { weak_factory_(this) {
frame_host_->SetAccessibilityCallbackForTesting( frame_host_->SetAccessibilityCallbackForTesting(
base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent, base::Bind(&AccessibilityNotificationWaiter::OnAccessibilityEvent,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
......
...@@ -57,9 +57,10 @@ class AccessibilityNotificationWaiter { ...@@ -57,9 +57,10 @@ class AccessibilityNotificationWaiter {
RenderFrameHostImpl* frame_host_; RenderFrameHostImpl* frame_host_;
ui::AXEvent event_to_wait_for_; ui::AXEvent event_to_wait_for_;
scoped_refptr<MessageLoopRunner> loop_runner_; scoped_refptr<MessageLoopRunner> loop_runner_;
base::WeakPtrFactory<AccessibilityNotificationWaiter> weak_factory_;
int event_target_id_; int event_target_id_;
base::WeakPtrFactory<AccessibilityNotificationWaiter> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AccessibilityNotificationWaiter); DISALLOW_COPY_AND_ASSIGN(AccessibilityNotificationWaiter);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment