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

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

Issue 2403873003: [Extensions] Convert some callers of ScriptContext::CallFunction (Closed)
Patch Set: Created 4 years, 2 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 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/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 28 matching lines...) Expand all
39 self->object_.Reset(); 39 self->object_.Reset();
40 base::ThreadTaskRunnerHandle::Get()->PostTask( 40 base::ThreadTaskRunnerHandle::Get()->PostTask(
41 FROM_HERE, base::Bind(&GCCallback::RunCallback, 41 FROM_HERE, base::Bind(&GCCallback::RunCallback,
42 self->weak_ptr_factory_.GetWeakPtr())); 42 self->weak_ptr_factory_.GetWeakPtr()));
43 } 43 }
44 44
45 void GCCallback::RunCallback() { 45 void GCCallback::RunCallback() {
46 fallback_.Reset(); 46 fallback_.Reset();
47 v8::Isolate* isolate = context_->isolate(); 47 v8::Isolate* isolate = context_->isolate();
48 v8::HandleScope handle_scope(isolate); 48 v8::HandleScope handle_scope(isolate);
49 context_->CallFunction(v8::Local<v8::Function>::New(isolate, callback_)); 49 context_->SafeCallFunction(v8::Local<v8::Function>::New(isolate, callback_),
50 0, nullptr);
50 delete this; 51 delete this;
51 } 52 }
52 53
53 void GCCallback::OnContextInvalidated() { 54 void GCCallback::OnContextInvalidated() {
54 if (!fallback_.is_null()) { 55 if (!fallback_.is_null()) {
55 fallback_.Run(); 56 fallback_.Run();
56 delete this; 57 delete this;
57 } 58 }
58 } 59 }
59 60
60 } // namespace extensions 61 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/cast_streaming_native_handler.cc ('k') | extensions/renderer/wake_event_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698