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

Side by Side Diff: gin/isolate_holder.cc

Issue 1019483002: Add support to extension_shell and ash_shell to use external V8 snapshot files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years, 9 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 base::MemoryMappedFile::Region snapshot_region = 187 base::MemoryMappedFile::Region snapshot_region =
188 base::MemoryMappedFile::Region::kWholeFile; 188 base::MemoryMappedFile::Region::kWholeFile;
189 if (natives_size != 0 || natives_offset != 0) { 189 if (natives_size != 0 || natives_offset != 0) {
190 snapshot_region = 190 snapshot_region =
191 base::MemoryMappedFile::Region(snapshot_offset, snapshot_size); 191 base::MemoryMappedFile::Region(snapshot_offset, snapshot_size);
192 } 192 }
193 193
194 return MapV8Files( 194 return MapV8Files(
195 NULL, NULL, natives_fd, snapshot_fd, natives_region, snapshot_region); 195 NULL, NULL, natives_fd, snapshot_fd, natives_region, snapshot_region);
196 } 196 }
197
198 // static
199 bool IsolateHolder::OpenV8FilesForChildProcesses(
200 base::PlatformFile* natives_fd_out,
201 base::PlatformFile* snapshot_fd_out) {
202 base::FilePath data_path;
203 PathService::Get(kV8SnapshotBasePathKey, &data_path);
204 DCHECK(!data_path.empty());
205
206 int file_flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
207 base::FilePath natives_data_path = data_path.AppendASCII(kNativesFileName);
208 base::FilePath snapshot_data_path = data_path.AppendASCII(kSnapshotFileName);
209 base::File natives_data_file(natives_data_path, file_flags);
210 base::File snapshot_data_file(snapshot_data_path, file_flags);
211
212 if (!natives_data_file.IsValid() || !snapshot_data_file.IsValid())
213 return false;
214
215 *natives_fd_out = natives_data_file.TakePlatformFile();
216 *snapshot_fd_out = snapshot_data_file.TakePlatformFile();
217 return true;
218 }
197 #endif // V8_USE_EXTERNAL_STARTUP_DATA 219 #endif // V8_USE_EXTERNAL_STARTUP_DATA
198 220
199 //static 221 //static
200 void IsolateHolder::GetV8ExternalSnapshotData(const char** natives_data_out, 222 void IsolateHolder::GetV8ExternalSnapshotData(const char** natives_data_out,
201 int* natives_size_out, 223 int* natives_size_out,
202 const char** snapshot_data_out, 224 const char** snapshot_data_out,
203 int* snapshot_size_out) { 225 int* snapshot_size_out) {
204 if (!g_mapped_natives || !g_mapped_snapshot) { 226 if (!g_mapped_natives || !g_mapped_snapshot) {
205 *natives_data_out = *snapshot_data_out = NULL; 227 *natives_data_out = *snapshot_data_out = NULL;
206 *natives_size_out = *snapshot_size_out = 0; 228 *natives_size_out = *snapshot_size_out = 0;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); 313 base::MessageLoop::current()->AddTaskObserver(task_observer_.get());
292 } 314 }
293 315
294 void IsolateHolder::RemoveRunMicrotasksObserver() { 316 void IsolateHolder::RemoveRunMicrotasksObserver() {
295 DCHECK(task_observer_.get()); 317 DCHECK(task_observer_.get());
296 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); 318 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get());
297 task_observer_.reset(); 319 task_observer_.reset();
298 } 320 }
299 321
300 } // namespace gin 322 } // namespace gin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698