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

Side by Side Diff: extensions/renderer/gc_callback.cc

Issue 1887423002: Don't execute the fallback if we already started running the gc callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 4 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 | « no previous file | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "extensions/renderer/gc_callback.h" 5 #include "extensions/renderer/gc_callback.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "extensions/renderer/script_context.h" 9 #include "extensions/renderer/script_context.h"
10 10
(...skipping 23 matching lines...) Expand all
34 // DO NOT add any more work to this method. The only acceptable place to add 34 // DO NOT add any more work to this method. The only acceptable place to add
35 // code is RunCallback. 35 // code is RunCallback.
36 GCCallback* self = data.GetParameter(); 36 GCCallback* self = data.GetParameter();
37 self->object_.Reset(); 37 self->object_.Reset();
38 base::MessageLoop::current()->PostTask( 38 base::MessageLoop::current()->PostTask(
39 FROM_HERE, base::Bind(&GCCallback::RunCallback, 39 FROM_HERE, base::Bind(&GCCallback::RunCallback,
40 self->weak_ptr_factory_.GetWeakPtr())); 40 self->weak_ptr_factory_.GetWeakPtr()));
41 } 41 }
42 42
43 void GCCallback::RunCallback() { 43 void GCCallback::RunCallback() {
44 fallback_.Reset();
44 v8::Isolate* isolate = context_->isolate(); 45 v8::Isolate* isolate = context_->isolate();
45 v8::HandleScope handle_scope(isolate); 46 v8::HandleScope handle_scope(isolate);
46 context_->CallFunction(v8::Local<v8::Function>::New(isolate, callback_)); 47 context_->CallFunction(v8::Local<v8::Function>::New(isolate, callback_));
47 delete this; 48 delete this;
48 } 49 }
49 50
50 void GCCallback::OnContextInvalidated() { 51 void GCCallback::OnContextInvalidated() {
51 fallback_.Run(); 52 if (!fallback_.is_null()) {
52 delete this; 53 fallback_.Run();
54 delete this;
55 }
53 } 56 }
54 57
55 } // namespace extensions 58 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698