| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef TONIC_DART_VM_H_ | 5 #ifndef TONIC_DART_VM_H_ |
| 6 #define TONIC_DART_VM_H_ | 6 #define TONIC_DART_VM_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "dart/runtime/include/dart_api.h" | 10 #include "dart/runtime/include/dart_api.h" |
| 11 | 11 |
| 12 namespace tonic { | 12 namespace tonic { |
| 13 | 13 |
| 14 // Initialize and Cleanup the Dart VM. | 14 // Initialize and Cleanup the Dart VM. |
| 15 class DartVM { | 15 class DartVM { |
| 16 public: | 16 public: |
| 17 struct Config { | 17 struct Config { |
| 18 Config(); | 18 Config(); |
| 19 | 19 |
| 20 const uint8_t* vm_isolate_snapshot; | 20 const uint8_t* vm_isolate_snapshot; |
| 21 const uint8_t* instructions_snapshot; | 21 const uint8_t* instructions_snapshot; |
| 22 const uint8_t* data_snapshot; | 22 const uint8_t* data_snapshot; |
| 23 Dart_IsolateCreateCallback create; | 23 Dart_IsolateCreateCallback create; |
| 24 Dart_IsolateInterruptCallback interrupt; | 24 Dart_IsolateInterruptCallback interrupt; |
| 25 Dart_IsolateUnhandledExceptionCallback unhandled_exception; | 25 Dart_IsolateUnhandledExceptionCallback unhandled_exception; |
| 26 Dart_IsolateShutdownCallback shutdown; | 26 Dart_IsolateShutdownCallback shutdown; |
| 27 Dart_ThreadExitCallback thread_exit; |
| 27 Dart_FileOpenCallback file_open; | 28 Dart_FileOpenCallback file_open; |
| 28 Dart_FileReadCallback file_read; | 29 Dart_FileReadCallback file_read; |
| 29 Dart_FileWriteCallback file_write; | 30 Dart_FileWriteCallback file_write; |
| 30 Dart_FileCloseCallback file_close; | 31 Dart_FileCloseCallback file_close; |
| 31 Dart_EntropySource entropy_source; | 32 Dart_EntropySource entropy_source; |
| 32 Dart_GetVMServiceAssetsArchive get_service_assets; | 33 Dart_GetVMServiceAssetsArchive get_service_assets; |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 // Initialize the Dart VM using |config| and |flags|. Returns |false| on | 36 // Initialize the Dart VM using |config| and |flags|. Returns |false| on |
| 36 // error and then the error message can be retrieved by calling |error|. | 37 // error and then the error message can be retrieved by calling |error|. |
| 37 static bool Initialize(const Config& config, | 38 static bool Initialize(const Config& config, |
| 38 const std::vector<const char*>& flags); | 39 const std::vector<const char*>& flags); |
| 39 | 40 |
| 40 // Cleanup the Dart VM. Returns |false| on error and then the error message | 41 // Cleanup the Dart VM. Returns |false| on error and then the error message |
| 41 // can be retrieved by calling |error|. | 42 // can be retrieved by calling |error|. |
| 42 static bool Cleanup(); | 43 static bool Cleanup(); |
| 43 | 44 |
| 44 // Returns the error string after a failing call to |Cleanup| or |Initialize|. | 45 // Returns the error string after a failing call to |Cleanup| or |Initialize|. |
| 45 static const char* error(); | 46 static const char* error(); |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 } // namespace tonic | 49 } // namespace tonic |
| 49 | 50 |
| 50 #endif // TONIC_DART_VM_H_ | 51 #endif // TONIC_DART_VM_H_ |
| OLD | NEW |