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

Side by Side Diff: gin/modules/timer.cc

Issue 2830723003: Ignore fired timer if the object wrapper is no longer alive (Closed)
Patch Set: Ignore fired timer if the object wrapper is no longer alive Created 3 years, 8 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
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "gin/modules/timer.h" 5 #include "gin/modules/timer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "gin/object_template_builder.h" 8 #include "gin/object_template_builder.h"
9 #include "gin/per_context_data.h" 9 #include "gin/per_context_data.h"
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void Timer::OnTimerFired() { 60 void Timer::OnTimerFired() {
61 // This can happen in spite of the weak callback because it is possible for 61 // This can happen in spite of the weak callback because it is possible for
62 // a gin::Handle<> to keep this object alive past when the isolate it is part 62 // a gin::Handle<> to keep this object alive past when the isolate it is part
63 // of is destroyed. 63 // of is destroyed.
64 if (!runner_.get()) { 64 if (!runner_.get()) {
65 return; 65 return;
66 } 66 }
67 67
68 Runner::Scope scope(runner_.get()); 68 Runner::Scope scope(runner_.get());
69 v8::Isolate* isolate = runner_->GetContextHolder()->isolate(); 69 v8::Isolate* isolate = runner_->GetContextHolder()->isolate();
70
71 v8::Local<v8::Object> wrapper;
72 if (!GetWrapper(isolate).ToLocal(&wrapper)) {
73 return;
74 }
75
70 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 76 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
71 GetWrapper(isolate) 77 wrapper
72 .ToLocalChecked()
73 ->GetPrivate(runner_->GetContextHolder()->context(), 78 ->GetPrivate(runner_->GetContextHolder()->context(),
74 GetHiddenPropertyName(isolate)) 79 GetHiddenPropertyName(isolate))
75 .ToLocalChecked()); 80 .ToLocalChecked());
76 runner_->Call(function, v8::Undefined(isolate), 0, NULL); 81 runner_->Call(function, v8::Undefined(isolate), 0, NULL);
77 } 82 }
78 83
79 84
80 // TimerModule ================================================================= 85 // TimerModule =================================================================
81 86
82 const char TimerModule::kName[] = "timer"; 87 const char TimerModule::kName[] = "timer";
(...skipping 18 matching lines...) Expand all
101 ObjectTemplateBuilder TimerModule::GetObjectTemplateBuilder( 106 ObjectTemplateBuilder TimerModule::GetObjectTemplateBuilder(
102 v8::Isolate* isolate) { 107 v8::Isolate* isolate) {
103 return Wrappable<TimerModule>::GetObjectTemplateBuilder(isolate) 108 return Wrappable<TimerModule>::GetObjectTemplateBuilder(isolate)
104 .SetMethod("createOneShot", 109 .SetMethod("createOneShot",
105 base::Bind(&Timer::Create, Timer::TYPE_ONE_SHOT)) 110 base::Bind(&Timer::Create, Timer::TYPE_ONE_SHOT))
106 .SetMethod("createRepeating", 111 .SetMethod("createRepeating",
107 base::Bind(&Timer::Create, Timer::TYPE_REPEATING)); 112 base::Bind(&Timer::Create, Timer::TYPE_REPEATING));
108 } 113 }
109 114
110 } // namespace gin 115 } // namespace gin
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698