| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |