| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 GIN_V8_INITIALIZER_H_ | 5 #ifndef GIN_V8_INITIALIZER_H_ |
| 6 #define GIN_V8_INITIALIZER_H_ | 6 #define GIN_V8_INITIALIZER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 9 #include "base/files/memory_mapped_file.h" | 11 #include "base/files/memory_mapped_file.h" |
| 10 #include "gin/array_buffer.h" | 12 #include "gin/array_buffer.h" |
| 11 #include "gin/gin_export.h" | 13 #include "gin/gin_export.h" |
| 12 #include "gin/public/isolate_holder.h" | 14 #include "gin/public/isolate_holder.h" |
| 13 #include "gin/public/v8_platform.h" | 15 #include "gin/public/v8_platform.h" |
| 14 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
| 15 | 17 |
| 16 namespace gin { | 18 namespace gin { |
| 17 | 19 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 29 const char** snapshot_data_out, | 31 const char** snapshot_data_out, |
| 30 int* snapshot_size_out); | 32 int* snapshot_size_out); |
| 31 | 33 |
| 32 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 34 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 33 | 35 |
| 34 // Load V8 snapshot from user provided platform file descriptors. | 36 // Load V8 snapshot from user provided platform file descriptors. |
| 35 // The offset and size arguments, if non-zero, specify the portions | 37 // The offset and size arguments, if non-zero, specify the portions |
| 36 // of the files to be loaded. Since the VM can boot with or without | 38 // of the files to be loaded. Since the VM can boot with or without |
| 37 // the snapshot, this function does not return a status. | 39 // the snapshot, this function does not return a status. |
| 38 static void LoadV8SnapshotFromFD(base::PlatformFile snapshot_fd, | 40 static void LoadV8SnapshotFromFD(base::PlatformFile snapshot_fd, |
| 39 int64 snapshot_offset, | 41 int64_t snapshot_offset, |
| 40 int64 snapshot_size); | 42 int64_t snapshot_size); |
| 41 // Similar to LoadV8SnapshotFromFD, but for the source of the natives. | 43 // Similar to LoadV8SnapshotFromFD, but for the source of the natives. |
| 42 // Without the natives we cannot continue, so this function contains | 44 // Without the natives we cannot continue, so this function contains |
| 43 // release mode asserts and won't return if it fails. | 45 // release mode asserts and won't return if it fails. |
| 44 static void LoadV8NativesFromFD(base::PlatformFile natives_fd, | 46 static void LoadV8NativesFromFD(base::PlatformFile natives_fd, |
| 45 int64 natives_offset, | 47 int64_t natives_offset, |
| 46 int64 natives_size); | 48 int64_t natives_size); |
| 47 | 49 |
| 48 // Load V8 snapshot from default resources, if they are available. | 50 // Load V8 snapshot from default resources, if they are available. |
| 49 static void LoadV8Snapshot(); | 51 static void LoadV8Snapshot(); |
| 50 | 52 |
| 51 // Load V8 natives source from default resources. Contains asserts | 53 // Load V8 natives source from default resources. Contains asserts |
| 52 // so that it will not return if natives cannot be loaded. | 54 // so that it will not return if natives cannot be loaded. |
| 53 static void LoadV8Natives(); | 55 static void LoadV8Natives(); |
| 54 | 56 |
| 55 // Opens (unless already cached) and returns the V8 natives file. | 57 // Opens (unless already cached) and returns the V8 natives file. |
| 56 // Use with LoadV8NativesFromFD(). | 58 // Use with LoadV8NativesFromFD(). |
| 57 // Asserts if the file does not exist. | 59 // Asserts if the file does not exist. |
| 58 static base::PlatformFile GetOpenNativesFileForChildProcesses( | 60 static base::PlatformFile GetOpenNativesFileForChildProcesses( |
| 59 base::MemoryMappedFile::Region* region_out); | 61 base::MemoryMappedFile::Region* region_out); |
| 60 | 62 |
| 61 // Opens (unless already cached) and returns the V8 snapshot file. | 63 // Opens (unless already cached) and returns the V8 snapshot file. |
| 62 // Use with LoadV8SnapshotFromFD(). | 64 // Use with LoadV8SnapshotFromFD(). |
| 63 // Will return -1 if the file does not exist. | 65 // Will return -1 if the file does not exist. |
| 64 static base::PlatformFile GetOpenSnapshotFileForChildProcesses( | 66 static base::PlatformFile GetOpenSnapshotFileForChildProcesses( |
| 65 base::MemoryMappedFile::Region* region_out); | 67 base::MemoryMappedFile::Region* region_out); |
| 66 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 68 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 } // namespace gin | 71 } // namespace gin |
| 70 | 72 |
| 71 #endif // GIN_V8_INITIALIZER_H_ | 73 #endif // GIN_V8_INITIALIZER_H_ |
| OLD | NEW |