| 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 #include "gin/public/isolate_holder.h" | 5 #include "gin/public/isolate_holder.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "base/files/memory_mapped_file.h" | 10 #include "base/files/memory_mapped_file.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 base::MemoryMappedFile* g_mapped_natives = NULL; | 40 base::MemoryMappedFile* g_mapped_natives = NULL; |
| 41 base::MemoryMappedFile* g_mapped_snapshot = NULL; | 41 base::MemoryMappedFile* g_mapped_snapshot = NULL; |
| 42 | 42 |
| 43 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 43 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 44 bool MapV8Files(base::FilePath* natives_path, base::FilePath* snapshot_path, | 44 bool MapV8Files(base::FilePath* natives_path, base::FilePath* snapshot_path, |
| 45 int natives_fd = -1, int snapshot_fd = -1) { | 45 int natives_fd = -1, int snapshot_fd = -1) { |
| 46 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 46 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
| 47 | 47 |
| 48 g_mapped_natives = new base::MemoryMappedFile; | 48 g_mapped_natives = new base::MemoryMappedFile; |
| 49 if (!g_mapped_natives->IsValid()) { | 49 if (!g_mapped_natives->IsValid()) { |
| 50 #ifndef OS_WIN |
| 50 if (natives_fd == -1 | 51 if (natives_fd == -1 |
| 51 ? !g_mapped_natives->Initialize(base::File(*natives_path, flags)) | 52 ? !g_mapped_natives->Initialize(base::File(*natives_path, flags)) |
| 52 : !g_mapped_natives->Initialize(base::File(natives_fd))) { | 53 : !g_mapped_natives->Initialize(base::File(natives_fd))) { |
| 54 #else |
| 55 if (!g_mapped_natives->Initialize(base::File(*natives_path, flags))) { |
| 56 #endif // OS_WIN |
| 53 delete g_mapped_natives; | 57 delete g_mapped_natives; |
| 54 g_mapped_natives = NULL; | 58 g_mapped_natives = NULL; |
| 55 LOG(FATAL) << "Couldn't mmap v8 natives data file"; | 59 LOG(FATAL) << "Couldn't mmap v8 natives data file"; |
| 56 return false; | 60 return false; |
| 57 } | 61 } |
| 58 } | 62 } |
| 59 | 63 |
| 60 g_mapped_snapshot = new base::MemoryMappedFile; | 64 g_mapped_snapshot = new base::MemoryMappedFile; |
| 61 if (!g_mapped_snapshot->IsValid()) { | 65 if (!g_mapped_snapshot->IsValid()) { |
| 66 #ifndef OS_WIN |
| 62 if (snapshot_fd == -1 | 67 if (snapshot_fd == -1 |
| 63 ? !g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags)) | 68 ? !g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags)) |
| 64 : !g_mapped_snapshot->Initialize(base::File(snapshot_fd))) { | 69 : !g_mapped_snapshot->Initialize(base::File(snapshot_fd))) { |
| 70 #else |
| 71 if (!g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags))) { |
| 72 #endif // OS_WIN |
| 65 delete g_mapped_snapshot; | 73 delete g_mapped_snapshot; |
| 66 g_mapped_snapshot = NULL; | 74 g_mapped_snapshot = NULL; |
| 67 LOG(ERROR) << "Couldn't mmap v8 snapshot data file"; | 75 LOG(ERROR) << "Couldn't mmap v8 snapshot data file"; |
| 68 return false; | 76 return false; |
| 69 } | 77 } |
| 70 } | 78 } |
| 71 | 79 |
| 72 return true; | 80 return true; |
| 73 } | 81 } |
| 74 | 82 |
| 75 #if !defined(OS_MACOSX) | 83 #if !defined(OS_MACOSX) |
| 76 const int v8_snapshot_dir = | 84 const int v8_snapshot_dir = |
| 77 #if defined(OS_ANDROID) | 85 #if defined(OS_ANDROID) |
| 78 base::DIR_ANDROID_APP_DATA; | 86 base::DIR_ANDROID_APP_DATA; |
| 79 #elif defined(OS_POSIX) | 87 #elif defined(OS_POSIX) |
| 80 base::DIR_EXE; | 88 base::DIR_EXE; |
| 89 #elif defined(OS_WIN) |
| 90 base::DIR_MODULE; |
| 81 #endif // defined(OS_ANDROID) | 91 #endif // defined(OS_ANDROID) |
| 82 #endif // !defined(OS_MACOSX) | 92 #endif // !defined(OS_MACOSX) |
| 83 | 93 |
| 84 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 94 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 85 | 95 |
| 86 } // namespace | 96 } // namespace |
| 87 | 97 |
| 88 | 98 |
| 89 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 99 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 90 // static | 100 // static |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); | 224 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); |
| 215 } | 225 } |
| 216 | 226 |
| 217 void IsolateHolder::RemoveRunMicrotasksObserver() { | 227 void IsolateHolder::RemoveRunMicrotasksObserver() { |
| 218 DCHECK(task_observer_.get()); | 228 DCHECK(task_observer_.get()); |
| 219 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); | 229 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); |
| 220 task_observer_.reset(); | 230 task_observer_.reset(); |
| 221 } | 231 } |
| 222 | 232 |
| 223 } // namespace gin | 233 } // namespace gin |
| OLD | NEW |