Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1053)

Side by Side Diff: gin/isolate_holder.cc

Issue 944913002: Transfer v8 snapshot files as file descriptors to child processes on Posix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tidy up Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 bool VerifyV8SnapshotFile(base::MemoryMappedFile* snapshot_file, 99 bool VerifyV8SnapshotFile(base::MemoryMappedFile* snapshot_file,
100 const unsigned char* fingerprint) { 100 const unsigned char* fingerprint) {
101 unsigned char output[crypto::kSHA256Length]; 101 unsigned char output[crypto::kSHA256Length];
102 crypto::SHA256HashString( 102 crypto::SHA256HashString(
103 base::StringPiece(reinterpret_cast<const char*>(snapshot_file->data()), 103 base::StringPiece(reinterpret_cast<const char*>(snapshot_file->data()),
104 snapshot_file->length()), 104 snapshot_file->length()),
105 output, sizeof(output)); 105 output, sizeof(output));
106 return !memcmp(fingerprint, output, sizeof(output)); 106 return !memcmp(fingerprint, output, sizeof(output));
107 } 107 }
108 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA 108 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA
109
110 #if !defined(OS_MACOSX)
111 const int v8_snapshot_dir =
112 #if defined(OS_ANDROID)
113 base::DIR_ANDROID_APP_DATA;
114 #elif defined(OS_POSIX)
115 base::DIR_EXE;
116 #elif defined(OS_WIN)
117 base::DIR_MODULE;
118 #endif // OS_ANDROID
119 #endif // !OS_MACOSX
120
121 #endif // V8_USE_EXTERNAL_STARTUP_DATA 109 #endif // V8_USE_EXTERNAL_STARTUP_DATA
122 110
123 } // namespace 111 } // namespace
124 112
125 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 113 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
126 114
127 #if defined(V8_VERIFY_EXTERNAL_STARTUP_DATA) 115 #if defined(V8_VERIFY_EXTERNAL_STARTUP_DATA)
128 // Defined in gen/gin/v8_snapshot_fingerprint.cc 116 // Defined in gen/gin/v8_snapshot_fingerprint.cc
129 extern const unsigned char g_natives_fingerprint[]; 117 extern const unsigned char g_natives_fingerprint[];
130 extern const unsigned char g_snapshot_fingerprint[]; 118 extern const unsigned char g_snapshot_fingerprint[];
131 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA 119 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA
132 120
121 #if !defined(OS_MACOSX)
122 const int IsolateHolder::kV8SnapshotBasePathKey =
123 #if defined(OS_ANDROID)
124 base::DIR_ANDROID_APP_DATA;
125 #elif defined(OS_POSIX)
126 base::DIR_EXE;
127 #elif defined(OS_WIN)
128 base::DIR_MODULE;
129 #endif // OS_ANDROID
130 #endif // !OS_MACOSX
131
133 const char IsolateHolder::kNativesFileName[] = "natives_blob.bin"; 132 const char IsolateHolder::kNativesFileName[] = "natives_blob.bin";
134 const char IsolateHolder::kSnapshotFileName[] = "snapshot_blob.bin"; 133 const char IsolateHolder::kSnapshotFileName[] = "snapshot_blob.bin";
135 134
136 // static 135 // static
137 bool IsolateHolder::LoadV8Snapshot() { 136 bool IsolateHolder::LoadV8Snapshot() {
138 if (g_mapped_natives && g_mapped_snapshot) 137 if (g_mapped_natives && g_mapped_snapshot)
139 return true; 138 return true;
140 139
141 #if !defined(OS_MACOSX) 140 #if !defined(OS_MACOSX)
142 base::FilePath data_path; 141 base::FilePath data_path;
143 PathService::Get(v8_snapshot_dir, &data_path); 142 PathService::Get(kV8SnapshotBasePathKey, &data_path);
144 DCHECK(!data_path.empty()); 143 DCHECK(!data_path.empty());
145 144
146 base::FilePath natives_path = data_path.AppendASCII(kNativesFileName); 145 base::FilePath natives_path = data_path.AppendASCII(kNativesFileName);
147 base::FilePath snapshot_path = data_path.AppendASCII(kSnapshotFileName); 146 base::FilePath snapshot_path = data_path.AppendASCII(kSnapshotFileName);
148 #else // !defined(OS_MACOSX) 147 #else // !defined(OS_MACOSX)
149 base::ScopedCFTypeRef<CFStringRef> natives_file_name( 148 base::ScopedCFTypeRef<CFStringRef> natives_file_name(
150 base::SysUTF8ToCFStringRef(kNativesFileName)); 149 base::SysUTF8ToCFStringRef(kNativesFileName));
151 base::FilePath natives_path = base::mac::PathForFrameworkBundleResource( 150 base::FilePath natives_path = base::mac::PathForFrameworkBundleResource(
152 natives_file_name); 151 natives_file_name);
153 base::ScopedCFTypeRef<CFStringRef> snapshot_file_name( 152 base::ScopedCFTypeRef<CFStringRef> snapshot_file_name(
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); 296 base::MessageLoop::current()->AddTaskObserver(task_observer_.get());
298 } 297 }
299 298
300 void IsolateHolder::RemoveRunMicrotasksObserver() { 299 void IsolateHolder::RemoveRunMicrotasksObserver() {
301 DCHECK(task_observer_.get()); 300 DCHECK(task_observer_.get());
302 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); 301 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get());
303 task_observer_.reset(); 302 task_observer_.reset();
304 } 303 }
305 304
306 } // namespace gin 305 } // namespace gin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698