Commit 71a12a87 authored by kulkarni.a's avatar kulkarni.a Committed by Commit bot

Code re-factor related to WeakPtrFactory in src/gin module

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

BUG=303818

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

Cr-Commit-Position: refs/heads/master@{#295709}
parent 89b276fb
...@@ -41,10 +41,10 @@ ObjectTemplateBuilder Timer::GetObjectTemplateBuilder(v8::Isolate* isolate) { ...@@ -41,10 +41,10 @@ ObjectTemplateBuilder Timer::GetObjectTemplateBuilder(v8::Isolate* isolate) {
Timer::Timer(v8::Isolate* isolate, bool repeating, int delay_ms, Timer::Timer(v8::Isolate* isolate, bool repeating, int delay_ms,
v8::Handle<v8::Function> function) v8::Handle<v8::Function> function)
: weak_factory_(this), : timer_(false, repeating),
timer_(false, repeating),
runner_(PerContextData::From( runner_(PerContextData::From(
isolate->GetCurrentContext())->runner()->GetWeakPtr()) { isolate->GetCurrentContext())->runner()->GetWeakPtr()),
weak_factory_(this) {
GetWrapper(runner_->GetContextHolder()->isolate())->SetHiddenValue( GetWrapper(runner_->GetContextHolder()->isolate())->SetHiddenValue(
GetHiddenPropertyName(isolate), function); GetHiddenPropertyName(isolate), function);
timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay_ms), timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay_ms),
......
...@@ -38,9 +38,10 @@ class GIN_EXPORT Timer : public Wrappable<Timer> { ...@@ -38,9 +38,10 @@ class GIN_EXPORT Timer : public Wrappable<Timer> {
virtual ~Timer(); virtual ~Timer();
void OnTimerFired(); void OnTimerFired();
base::WeakPtrFactory<Timer> weak_factory_;
base::Timer timer_; base::Timer timer_;
base::WeakPtr<gin::Runner> runner_; base::WeakPtr<gin::Runner> runner_;
base::WeakPtrFactory<Timer> weak_factory_;
}; };
......
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