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 30 matching lines...) Expand all Loading... | |
41 base::MemoryMappedFile* g_mapped_natives = NULL; | 41 base::MemoryMappedFile* g_mapped_natives = NULL; |
42 base::MemoryMappedFile* g_mapped_snapshot = NULL; | 42 base::MemoryMappedFile* g_mapped_snapshot = NULL; |
43 | 43 |
44 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 44 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
45 bool MapV8Files(base::FilePath* natives_path, base::FilePath* snapshot_path, | 45 bool MapV8Files(base::FilePath* natives_path, base::FilePath* snapshot_path, |
46 int natives_fd = -1, int snapshot_fd = -1) { | 46 int natives_fd = -1, int snapshot_fd = -1) { |
47 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 47 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
48 | 48 |
49 g_mapped_natives = new base::MemoryMappedFile; | 49 g_mapped_natives = new base::MemoryMappedFile; |
50 if (!g_mapped_natives->IsValid()) { | 50 if (!g_mapped_natives->IsValid()) { |
51 #ifndef OS_WIN | |
jochen (gone - plz use gerrit)
2015/01/09 13:40:24
#if !defined(OS_WIN)
rmcilroy
2015/01/09 14:16:33
argh, that was the one thing I planned on changing
| |
51 if (natives_fd == -1 | 52 if (natives_fd == -1 |
52 ? !g_mapped_natives->Initialize(base::File(*natives_path, flags)) | 53 ? !g_mapped_natives->Initialize(base::File(*natives_path, flags)) |
53 : !g_mapped_natives->Initialize(base::File(natives_fd))) { | 54 : !g_mapped_natives->Initialize(base::File(natives_fd))) { |
55 #else | |
56 if (!g_mapped_natives->Initialize(base::File(*natives_path, flags))) { | |
57 #endif // OS_WIN | |
54 delete g_mapped_natives; | 58 delete g_mapped_natives; |
55 g_mapped_natives = NULL; | 59 g_mapped_natives = NULL; |
56 LOG(FATAL) << "Couldn't mmap v8 natives data file"; | 60 LOG(FATAL) << "Couldn't mmap v8 natives data file"; |
57 return false; | 61 return false; |
58 } | 62 } |
59 } | 63 } |
60 | 64 |
61 g_mapped_snapshot = new base::MemoryMappedFile; | 65 g_mapped_snapshot = new base::MemoryMappedFile; |
62 if (!g_mapped_snapshot->IsValid()) { | 66 if (!g_mapped_snapshot->IsValid()) { |
67 #ifndef OS_WIN | |
63 if (snapshot_fd == -1 | 68 if (snapshot_fd == -1 |
64 ? !g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags)) | 69 ? !g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags)) |
65 : !g_mapped_snapshot->Initialize(base::File(snapshot_fd))) { | 70 : !g_mapped_snapshot->Initialize(base::File(snapshot_fd))) { |
71 #else | |
72 if (!g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags))) { | |
73 #endif // OS_WIN | |
66 delete g_mapped_snapshot; | 74 delete g_mapped_snapshot; |
67 g_mapped_snapshot = NULL; | 75 g_mapped_snapshot = NULL; |
68 LOG(ERROR) << "Couldn't mmap v8 snapshot data file"; | 76 LOG(ERROR) << "Couldn't mmap v8 snapshot data file"; |
69 return false; | 77 return false; |
70 } | 78 } |
71 } | 79 } |
72 | 80 |
73 return true; | 81 return true; |
74 } | 82 } |
75 | 83 |
76 #if defined(V8_VERIFY_EXTERNAL_STARTUP_DATA) | 84 #if defined(V8_VERIFY_EXTERNAL_STARTUP_DATA) |
77 bool VerifyV8SnapshotFile(base::MemoryMappedFile* snapshot_file, | 85 bool VerifyV8SnapshotFile(base::MemoryMappedFile* snapshot_file, |
78 const unsigned char* fingerprint) { | 86 const unsigned char* fingerprint) { |
79 unsigned char output[crypto::kSHA256Length]; | 87 unsigned char output[crypto::kSHA256Length]; |
80 crypto::SHA256HashString( | 88 crypto::SHA256HashString( |
81 base::StringPiece(reinterpret_cast<const char*>(snapshot_file->data()), | 89 base::StringPiece(reinterpret_cast<const char*>(snapshot_file->data()), |
82 snapshot_file->length()), | 90 snapshot_file->length()), |
83 output, sizeof(output)); | 91 output, sizeof(output)); |
84 return !memcmp(fingerprint, output, sizeof(output)); | 92 return !memcmp(fingerprint, output, sizeof(output)); |
85 } | 93 } |
86 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA | 94 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA |
87 | 95 |
88 #if !defined(OS_MACOSX) | 96 #if !defined(OS_MACOSX) |
89 const int v8_snapshot_dir = | 97 const int v8_snapshot_dir = |
90 #if defined(OS_ANDROID) | 98 #if defined(OS_ANDROID) |
91 base::DIR_ANDROID_APP_DATA; | 99 base::DIR_ANDROID_APP_DATA; |
92 #elif defined(OS_POSIX) | 100 #elif defined(OS_POSIX) |
93 base::DIR_EXE; | 101 base::DIR_EXE; |
102 #elif defined(OS_WIN) | |
103 base::DIR_MODULE; | |
94 #endif // OS_ANDROID | 104 #endif // OS_ANDROID |
95 #endif // !OS_MACOSX | 105 #endif // !OS_MACOSX |
96 | 106 |
97 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 107 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
98 | 108 |
99 } // namespace | 109 } // namespace |
100 | 110 |
101 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 111 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
102 | 112 |
103 #if defined(V8_VERIFY_EXTERNAL_STARTUP_DATA) | 113 #if defined(V8_VERIFY_EXTERNAL_STARTUP_DATA) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); | 251 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); |
242 } | 252 } |
243 | 253 |
244 void IsolateHolder::RemoveRunMicrotasksObserver() { | 254 void IsolateHolder::RemoveRunMicrotasksObserver() { |
245 DCHECK(task_observer_.get()); | 255 DCHECK(task_observer_.get()); |
246 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); | 256 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); |
247 task_observer_.reset(); | 257 task_observer_.reset(); |
248 } | 258 } |
249 | 259 |
250 } // namespace gin | 260 } // namespace gin |
OLD | NEW |