| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project 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 | 5 |
| 6 #ifndef V8_STARTUP_DATA_UTIL_H_ | 6 #ifndef V8_STARTUP_DATA_UTIL_H_ |
| 7 #define V8_STARTUP_DATA_UTIL_H_ | 7 #define V8_STARTUP_DATA_UTIL_H_ |
| 8 | 8 |
| 9 #include "include/v8.h" | 9 #include "include/v8.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { |
| 12 | 13 |
| 13 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 14 // Helper functions to load external startup data. |
| 14 // Helper class to load the startup data files from disk. | |
| 15 // | 15 // |
| 16 // This is meant as a convenience for stand-alone binaries like d8, cctest, | 16 // This is meant as a convenience for stand-alone binaries like d8, cctest, |
| 17 // unittest. A V8 embedder would likely either handle startup data on their | 17 // unittest. A V8 embedder would likely either handle startup data on their |
| 18 // own or just disable the feature if they don't want to handle it at all, | 18 // own or just disable the feature if they don't want to handle it at all, |
| 19 // while tools like cctest need to work in either configuration. Hence this is | 19 // while tools like cctest need to work in either configuration. |
| 20 // not meant for inclusion in the general v8 library. | |
| 21 class StartupDataHandler { | |
| 22 public: | |
| 23 // Load startup data, and call the v8::V8::Set*DataBlob API functions. | |
| 24 // | |
| 25 // natives_blob and snapshot_blob will be loaded realitive to exec_path, | |
| 26 // which would usually be the equivalent of argv[0]. | |
| 27 StartupDataHandler(const char* exec_path, const char* natives_blob, | |
| 28 const char* snapshot_blob); | |
| 29 ~StartupDataHandler(); | |
| 30 | 20 |
| 31 private: | 21 void InitializeExternalStartupData(const char* directory_path); |
| 32 static char* RelativePath(char** buffer, const char* exec_path, | |
| 33 const char* name); | |
| 34 | 22 |
| 35 void LoadFromFiles(const char* natives_blob, const char* snapshot_blob); | 23 void InitializeExternalStartupData(const char* natives_blob, |
| 24 const char* snapshot_blob); |
| 36 | 25 |
| 37 void Load(const char* blob_file, v8::StartupData* startup_data, | 26 } // namespace internal |
| 38 void (*setter_fn)(v8::StartupData*)); | |
| 39 | |
| 40 v8::StartupData natives_; | |
| 41 v8::StartupData snapshot_; | |
| 42 | |
| 43 // Disallow copy & assign. | |
| 44 StartupDataHandler(const StartupDataHandler& other); | |
| 45 void operator=(const StartupDataHandler& other); | |
| 46 }; | |
| 47 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
| 48 | |
| 49 } // namespace v8 | 27 } // namespace v8 |
| 50 | 28 |
| 51 #endif // V8_STARTUP_DATA_UTIL_H_ | 29 #endif // V8_STARTUP_DATA_UTIL_H_ |
| OLD | NEW |