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

Side by Side Diff: chromecast/browser/cast_content_browser_client.cc

Issue 1164483003: Allow startup with missing V8 snapshot file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromecast/browser/cast_content_browser_client.h" 5 #include "chromecast/browser/cast_content_browser_client.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 base::CommandLine* command_line, 150 base::CommandLine* command_line,
151 int child_process_id) { 151 int child_process_id) {
152 152
153 std::string process_type = 153 std::string process_type =
154 command_line->GetSwitchValueNative(switches::kProcessType); 154 command_line->GetSwitchValueNative(switches::kProcessType);
155 base::CommandLine* browser_command_line = 155 base::CommandLine* browser_command_line =
156 base::CommandLine::ForCurrentProcess(); 156 base::CommandLine::ForCurrentProcess();
157 157
158 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 158 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
159 if (process_type != switches::kZygoteProcess) { 159 if (process_type != switches::kZygoteProcess) {
160 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); 160 if (v8_natives_fd_.get() != -1) {
161 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); 161 command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
162 }
163 if (v8_snapshot_fd_.get() != -1) {
164 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
165 }
162 } 166 }
163 #endif // V8_USE_EXTERNAL_STARTUP_DATA 167 #endif // V8_USE_EXTERNAL_STARTUP_DATA
164 168
165 // IsCrashReporterEnabled() is set when InitCrashReporter() is called, and 169 // IsCrashReporterEnabled() is set when InitCrashReporter() is called, and
166 // controlled by GetBreakpadClient()->EnableBreakpadForProcess(), therefore 170 // controlled by GetBreakpadClient()->EnableBreakpadForProcess(), therefore
167 // it's ok to add switch to every process here. 171 // it's ok to add switch to every process here.
168 if (breakpad::IsCrashReporterEnabled()) { 172 if (breakpad::IsCrashReporterEnabled()) {
169 command_line->AppendSwitch(switches::kEnableCrashReporter); 173 command_line->AppendSwitch(switches::kEnableCrashReporter);
170 } 174 }
171 175
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 bool* no_javascript_access) { 313 bool* no_javascript_access) {
310 *no_javascript_access = true; 314 *no_javascript_access = true;
311 return false; 315 return false;
312 } 316 }
313 317
314 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 318 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
315 const base::CommandLine& command_line, 319 const base::CommandLine& command_line,
316 int child_process_id, 320 int child_process_id,
317 content::FileDescriptorInfo* mappings) { 321 content::FileDescriptorInfo* mappings) {
318 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 322 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
319 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { 323 if (v8_natives_fd_.get() == -1) {
320 int v8_natives_fd = -1; 324 int v8_natives_fd = -1;
321 int v8_snapshot_fd = -1; 325 int v8_snapshot_fd = -1;
322 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, 326 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
323 &v8_snapshot_fd)) { 327 &v8_snapshot_fd)) {
324 v8_natives_fd_.reset(v8_natives_fd); 328 v8_natives_fd_.reset(v8_natives_fd);
325 v8_snapshot_fd_.reset(v8_snapshot_fd); 329 v8_snapshot_fd_.reset(v8_snapshot_fd);
326 } 330 }
327 } 331 }
328 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); 332 DCHECK(v8_natives_fd_.get() != -1);
329 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); 333 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
330 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); 334 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
331 #endif // V8_USE_EXTERNAL_STARTUP_DATA 335 #endif // V8_USE_EXTERNAL_STARTUP_DATA
332 #if defined(OS_ANDROID) 336 #if defined(OS_ANDROID)
333 const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ; 337 const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ;
334 base::FilePath pak_file_path; 338 base::FilePath pak_file_path;
335 CHECK(PathService::Get(FILE_CAST_PAK, &pak_file_path)); 339 CHECK(PathService::Get(FILE_CAST_PAK, &pak_file_path));
336 base::File pak_file(pak_file_path, flags_open_read); 340 base::File pak_file(pak_file_path, flags_open_read);
337 if (!pak_file.IsValid()) { 341 if (!pak_file.IsValid()) {
338 NOTREACHED() << "Failed to open file when creating renderer process: " 342 NOTREACHED() << "Failed to open file when creating renderer process: "
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 process_type, dumps_path, false /* upload */); 418 process_type, dumps_path, false /* upload */);
415 // StartUploaderThread() even though upload is diferred. 419 // StartUploaderThread() even though upload is diferred.
416 // Breakpad-related memory is freed in the uploader thread. 420 // Breakpad-related memory is freed in the uploader thread.
417 crash_handler->StartUploaderThread(); 421 crash_handler->StartUploaderThread();
418 return crash_handler; 422 return crash_handler;
419 } 423 }
420 #endif // !defined(OS_ANDROID) 424 #endif // !defined(OS_ANDROID)
421 425
422 } // namespace shell 426 } // namespace shell
423 } // namespace chromecast 427 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698