| Index: gin/isolate_holder.cc
|
| diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
|
| index 334c0e0ee5130c6e1c081cb40c9f0541b06a2da9..897316d8356e83fddaee1c03b1c3cc0f4172dcb1 100644
|
| --- a/gin/isolate_holder.cc
|
| +++ b/gin/isolate_holder.cc
|
| @@ -44,9 +44,14 @@ bool MapV8Files(base::FilePath* natives_path, base::FilePath* snapshot_path,
|
|
|
| g_mapped_natives = new base::MemoryMappedFile;
|
| if (!g_mapped_natives->IsValid()) {
|
| +#ifdef OS_ANDROID
|
| if (natives_fd == -1
|
| ? !g_mapped_natives->Initialize(base::File(*natives_path, flags))
|
| - : !g_mapped_natives->Initialize(base::File(natives_fd))) {
|
| + : !g_mapped_natives->Initialize(base::File(natives_fd))
|
| +#else
|
| + if (!g_mapped_natives->Initialize(base::File(*natives_path, flags))
|
| +#endif
|
| + ) {
|
| delete g_mapped_natives;
|
| g_mapped_natives = NULL;
|
| LOG(FATAL) << "Couldn't mmap v8 natives data file";
|
| @@ -56,9 +61,14 @@ bool MapV8Files(base::FilePath* natives_path, base::FilePath* snapshot_path,
|
|
|
| g_mapped_snapshot = new base::MemoryMappedFile;
|
| if (!g_mapped_snapshot->IsValid()) {
|
| +#ifdef OS_ANDROID
|
| if (snapshot_fd == -1
|
| ? !g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags))
|
| - : !g_mapped_snapshot->Initialize(base::File(snapshot_fd))) {
|
| + : !g_mapped_snapshot->Initialize(base::File(snapshot_fd))
|
| +#else
|
| + if (!g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags))
|
| +#endif
|
| + ) {
|
| delete g_mapped_snapshot;
|
| g_mapped_snapshot = NULL;
|
| LOG(ERROR) << "Couldn't mmap v8 snapshot data file";
|
| @@ -80,7 +90,13 @@ bool IsolateHolder::LoadV8Snapshot() {
|
| return true;
|
|
|
| base::FilePath data_path;
|
| - PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path);
|
| + PathService::Get(
|
| +#if defined(OS_ANDROID)
|
| + base::DIR_ANDROID_APP_DATA,
|
| +#elif defined(OS_POSIX)
|
| + base::DIR_EXE,
|
| +#endif
|
| + &data_path);
|
| DCHECK(!data_path.empty());
|
|
|
| base::FilePath natives_path = data_path.AppendASCII("natives_blob.bin");
|
| @@ -89,6 +105,7 @@ bool IsolateHolder::LoadV8Snapshot() {
|
| return MapV8Files(&natives_path, &snapshot_path);
|
| }
|
|
|
| +#ifdef OS_ANDROID
|
| //static
|
| bool IsolateHolder::LoadV8SnapshotFD(int natives_fd, int snapshot_fd) {
|
| if (g_mapped_natives && g_mapped_snapshot)
|
| @@ -96,6 +113,38 @@ bool IsolateHolder::LoadV8SnapshotFD(int natives_fd, int snapshot_fd) {
|
|
|
| return MapV8Files(NULL, NULL, natives_fd, snapshot_fd);
|
| }
|
| +#endif // OS_ANDROID
|
| +
|
| +#ifndef OS_ANDROID
|
| +//static
|
| +const char* IsolateHolder::GetV8NativesData() {
|
| + if (!g_mapped_natives)
|
| + return NULL;
|
| + return reinterpret_cast<const char*>(g_mapped_natives->data());
|
| +}
|
| +
|
| +//static
|
| +const char* IsolateHolder::GetV8SnapshotData() {
|
| + if (!g_mapped_snapshot)
|
| + return NULL;
|
| + return reinterpret_cast<const char*>(g_mapped_snapshot->data());
|
| +}
|
| +
|
| +//static
|
| +int IsolateHolder::GetV8NativesSize() {
|
| + if (!g_mapped_natives)
|
| + return 0;
|
| + return g_mapped_natives->length();
|
| +}
|
| +
|
| +//static
|
| +int IsolateHolder::GetV8SnapshotSize() {
|
| + if (!g_mapped_snapshot)
|
| + return 0;
|
| + return g_mapped_snapshot->length();
|
| +}
|
| +#endif // OS_ANDROID
|
| +
|
| #endif // V8_USE_EXTERNAL_STARTUP_DATA
|
|
|
| IsolateHolder::IsolateHolder() {
|
|
|