OLD | NEW |
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 139 } |
140 | 140 |
141 if (scheme == url::kFileScheme) { | 141 if (scheme == url::kFileScheme) { |
142 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 142 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
143 switches::kEnableLocalFileAccesses); | 143 switches::kEnableLocalFileAccesses); |
144 } | 144 } |
145 | 145 |
146 return false; | 146 return false; |
147 } | 147 } |
148 | 148 |
| 149 void CastContentBrowserClient::AppendMappedFileCommandLineSwitches( |
| 150 base::CommandLine* command_line) { |
| 151 std::string process_type = |
| 152 command_line->GetSwitchValueNative(switches::kProcessType); |
| 153 |
| 154 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 155 if (process_type != switches::kZygoteProcess) { |
| 156 DCHECK(natives_fd_exists()); |
| 157 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); |
| 158 if (snapshot_fd_exists()) |
| 159 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); |
| 160 } |
| 161 } |
| 162 |
| 163 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
149 void CastContentBrowserClient::AppendExtraCommandLineSwitches( | 164 void CastContentBrowserClient::AppendExtraCommandLineSwitches( |
150 base::CommandLine* command_line, | 165 base::CommandLine* command_line, |
151 int child_process_id) { | 166 int child_process_id) { |
152 | |
153 std::string process_type = | 167 std::string process_type = |
154 command_line->GetSwitchValueNative(switches::kProcessType); | 168 command_line->GetSwitchValueNative(switches::kProcessType); |
155 base::CommandLine* browser_command_line = | 169 base::CommandLine* browser_command_line = |
156 base::CommandLine::ForCurrentProcess(); | 170 base::CommandLine::ForCurrentProcess(); |
157 | 171 |
158 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
159 if (process_type != switches::kZygoteProcess) { | |
160 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); | |
161 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); | |
162 } | |
163 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
164 | |
165 // IsCrashReporterEnabled() is set when InitCrashReporter() is called, and | 172 // IsCrashReporterEnabled() is set when InitCrashReporter() is called, and |
166 // controlled by GetBreakpadClient()->EnableBreakpadForProcess(), therefore | 173 // controlled by GetBreakpadClient()->EnableBreakpadForProcess(), therefore |
167 // it's ok to add switch to every process here. | 174 // it's ok to add switch to every process here. |
168 if (breakpad::IsCrashReporterEnabled()) { | 175 if (breakpad::IsCrashReporterEnabled()) { |
169 command_line->AppendSwitch(switches::kEnableCrashReporter); | 176 command_line->AppendSwitch(switches::kEnableCrashReporter); |
170 } | 177 } |
171 | 178 |
172 // Renderer process command-line | 179 // Renderer process command-line |
173 if (process_type == switches::kRendererProcess) { | 180 if (process_type == switches::kRendererProcess) { |
174 // Any browser command-line switches that should be propagated to | 181 // Any browser command-line switches that should be propagated to |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 bool* no_javascript_access) { | 316 bool* no_javascript_access) { |
310 *no_javascript_access = true; | 317 *no_javascript_access = true; |
311 return false; | 318 return false; |
312 } | 319 } |
313 | 320 |
314 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 321 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
315 const base::CommandLine& command_line, | 322 const base::CommandLine& command_line, |
316 int child_process_id, | 323 int child_process_id, |
317 content::FileDescriptorInfo* mappings) { | 324 content::FileDescriptorInfo* mappings) { |
318 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 325 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
319 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { | 326 if (!natives_fd_exists()) { |
320 int v8_natives_fd = -1; | 327 int v8_natives_fd = -1; |
321 int v8_snapshot_fd = -1; | 328 int v8_snapshot_fd = -1; |
322 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | 329 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, |
323 &v8_snapshot_fd)) { | 330 &v8_snapshot_fd)) { |
324 v8_natives_fd_.reset(v8_natives_fd); | 331 v8_natives_fd_.reset(v8_natives_fd); |
325 v8_snapshot_fd_.reset(v8_snapshot_fd); | 332 v8_snapshot_fd_.reset(v8_snapshot_fd); |
326 } | 333 } |
327 } | 334 } |
328 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); | 335 // V8 can't start up without the source of the natives, but it can |
| 336 // start up (slower) without the snapshot. |
| 337 DCHECK(natives_fd_exists()); |
329 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 338 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); |
330 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 339 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); |
331 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 340 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
332 #if defined(OS_ANDROID) | 341 #if defined(OS_ANDROID) |
333 const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ; | 342 const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ; |
334 base::FilePath pak_file_path; | 343 base::FilePath pak_file_path; |
335 CHECK(PathService::Get(FILE_CAST_PAK, &pak_file_path)); | 344 CHECK(PathService::Get(FILE_CAST_PAK, &pak_file_path)); |
336 base::File pak_file(pak_file_path, flags_open_read); | 345 base::File pak_file(pak_file_path, flags_open_read); |
337 if (!pak_file.IsValid()) { | 346 if (!pak_file.IsValid()) { |
338 NOTREACHED() << "Failed to open file when creating renderer process: " | 347 NOTREACHED() << "Failed to open file when creating renderer process: " |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 process_type, dumps_path, false /* upload */); | 423 process_type, dumps_path, false /* upload */); |
415 // StartUploaderThread() even though upload is diferred. | 424 // StartUploaderThread() even though upload is diferred. |
416 // Breakpad-related memory is freed in the uploader thread. | 425 // Breakpad-related memory is freed in the uploader thread. |
417 crash_handler->StartUploaderThread(); | 426 crash_handler->StartUploaderThread(); |
418 return crash_handler; | 427 return crash_handler; |
419 } | 428 } |
420 #endif // !defined(OS_ANDROID) | 429 #endif // !defined(OS_ANDROID) |
421 | 430 |
422 } // namespace shell | 431 } // namespace shell |
423 } // namespace chromecast | 432 } // namespace chromecast |
OLD | NEW |