| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sky/engine/config.h" | |
| 6 #include "sky/engine/bindings2/dart_callback.h" | |
| 7 | |
| 8 #include "sky/engine/tonic/dart_converter.h" | |
| 9 #include "sky/engine/tonic/dart_error.h" | |
| 10 #include "sky/engine/tonic/dart_state.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 DartCallback::DartCallback(DartState* dart_state, | |
| 15 Dart_Handle callback, | |
| 16 Dart_Handle& exception) | |
| 17 : callback_(dart_state, callback) { | |
| 18 if (!Dart_IsClosure(callback)) { | |
| 19 exception = ToDart("Callback must be a function"); | |
| 20 callback_.Clear(); | |
| 21 } | |
| 22 } | |
| 23 | |
| 24 DartCallback::~DartCallback() { | |
| 25 } | |
| 26 | |
| 27 bool DartCallback::IsIsolateAlive() const { | |
| 28 return !!callback_.dart_state(); | |
| 29 } | |
| 30 | |
| 31 Dart_Isolate DartCallback::GetIsolate() const { | |
| 32 return callback_.dart_state()->isolate(); | |
| 33 } | |
| 34 | |
| 35 bool DartCallback::handleEvent(int argc, Dart_Handle* argv) { | |
| 36 LogIfError(Dart_InvokeClosure(callback_.value(), argc, argv)); | |
| 37 return true; | |
| 38 } | |
| 39 | |
| 40 } // namespace blink | |
| OLD | NEW |