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

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

Issue 1182443003: Moved logic for mapping child process FDs for ICU and V8 into child_process_launcher.cc (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"
11 #include "base/files/scoped_file.h" 11 #include "base/files/scoped_file.h"
12 #include "base/i18n/icu_util.h"
13 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
14 #include "base/path_service.h" 13 #include "base/path_service.h"
15 #include "chromecast/base/cast_paths.h" 14 #include "chromecast/base/cast_paths.h"
16 #include "chromecast/base/chromecast_switches.h" 15 #include "chromecast/base/chromecast_switches.h"
17 #include "chromecast/browser/cast_browser_context.h" 16 #include "chromecast/browser/cast_browser_context.h"
18 #include "chromecast/browser/cast_browser_main_parts.h" 17 #include "chromecast/browser/cast_browser_main_parts.h"
19 #include "chromecast/browser/cast_browser_process.h" 18 #include "chromecast/browser/cast_browser_process.h"
20 #include "chromecast/browser/cast_network_delegate.h" 19 #include "chromecast/browser/cast_network_delegate.h"
21 #include "chromecast/browser/cast_quota_permission_context.h" 20 #include "chromecast/browser/cast_quota_permission_context.h"
22 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h" 21 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h"
23 #include "chromecast/browser/geolocation/cast_access_token_store.h" 22 #include "chromecast/browser/geolocation/cast_access_token_store.h"
24 #include "chromecast/browser/media/cma_message_filter_host.h" 23 #include "chromecast/browser/media/cma_message_filter_host.h"
25 #include "chromecast/browser/url_request_context_factory.h" 24 #include "chromecast/browser/url_request_context_factory.h"
26 #include "chromecast/common/global_descriptors.h" 25 #include "chromecast/common/global_descriptors.h"
27 #include "chromecast/media/cma/backend/media_pipeline_device.h" 26 #include "chromecast/media/cma/backend/media_pipeline_device.h"
28 #include "components/crash/app/breakpad_linux.h" 27 #include "components/crash/app/breakpad_linux.h"
29 #include "components/crash/browser/crash_handler_host_linux.h" 28 #include "components/crash/browser/crash_handler_host_linux.h"
30 #include "components/network_hints/browser/network_hints_message_filter.h" 29 #include "components/network_hints/browser/network_hints_message_filter.h"
31 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/certificate_request_result_type.h" 31 #include "content/public/browser/certificate_request_result_type.h"
33 #include "content/public/browser/client_certificate_delegate.h" 32 #include "content/public/browser/client_certificate_delegate.h"
34 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
35 #include "content/public/browser/resource_dispatcher_host.h" 34 #include "content/public/browser/resource_dispatcher_host.h"
36 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
37 #include "content/public/common/content_descriptors.h" 36 #include "content/public/common/content_descriptors.h"
38 #include "content/public/common/content_switches.h" 37 #include "content/public/common/content_switches.h"
39 #include "content/public/common/url_constants.h" 38 #include "content/public/common/url_constants.h"
40 #include "content/public/common/web_preferences.h" 39 #include "content/public/common/web_preferences.h"
41 #include "gin/v8_initializer.h"
42 #include "media/audio/audio_manager_factory.h" 40 #include "media/audio/audio_manager_factory.h"
43 #include "net/ssl/ssl_cert_request_info.h" 41 #include "net/ssl/ssl_cert_request_info.h"
44 #include "net/url_request/url_request_context_getter.h" 42 #include "net/url_request/url_request_context_getter.h"
45 #include "ui/gl/gl_switches.h" 43 #include "ui/gl/gl_switches.h"
46 44
47 #if defined(OS_ANDROID) 45 #if defined(OS_ANDROID)
48 #include "components/crash/browser/crash_dump_manager_android.h" 46 #include "components/crash/browser/crash_dump_manager_android.h"
49 #include "components/external_video_surface/browser/android/external_video_surfa ce_container_impl.h" 47 #include "components/external_video_surface/browser/android/external_video_surfa ce_container_impl.h"
50 #endif // defined(OS_ANDROID) 48 #endif // defined(OS_ANDROID)
51 49
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 142 }
145 143
146 if (scheme == url::kFileScheme) { 144 if (scheme == url::kFileScheme) {
147 return base::CommandLine::ForCurrentProcess()->HasSwitch( 145 return base::CommandLine::ForCurrentProcess()->HasSwitch(
148 switches::kEnableLocalFileAccesses); 146 switches::kEnableLocalFileAccesses);
149 } 147 }
150 148
151 return false; 149 return false;
152 } 150 }
153 151
154 void CastContentBrowserClient::AppendMappedFileCommandLineSwitches(
155 base::CommandLine* command_line) {
156 std::string process_type =
157 command_line->GetSwitchValueNative(switches::kProcessType);
158
159 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
160 if (process_type != switches::kZygoteProcess) {
161 DCHECK(natives_fd_exists());
162 command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
163 if (snapshot_fd_exists())
164 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
165 }
166 }
167
168 #endif // V8_USE_EXTERNAL_STARTUP_DATA 152 #endif // V8_USE_EXTERNAL_STARTUP_DATA
169 void CastContentBrowserClient::AppendExtraCommandLineSwitches( 153 void CastContentBrowserClient::AppendExtraCommandLineSwitches(
170 base::CommandLine* command_line, 154 base::CommandLine* command_line,
171 int child_process_id) { 155 int child_process_id) {
172 std::string process_type = 156 std::string process_type =
173 command_line->GetSwitchValueNative(switches::kProcessType); 157 command_line->GetSwitchValueNative(switches::kProcessType);
174 base::CommandLine* browser_command_line = 158 base::CommandLine* browser_command_line =
175 base::CommandLine::ForCurrentProcess(); 159 base::CommandLine::ForCurrentProcess();
176 160
177 // IsCrashReporterEnabled() is set when InitCrashReporter() is called, and 161 // IsCrashReporterEnabled() is set when InitCrashReporter() is called, and
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 int opener_id, 304 int opener_id,
321 bool* no_javascript_access) { 305 bool* no_javascript_access) {
322 *no_javascript_access = true; 306 *no_javascript_access = true;
323 return false; 307 return false;
324 } 308 }
325 309
326 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 310 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
327 const base::CommandLine& command_line, 311 const base::CommandLine& command_line,
328 int child_process_id, 312 int child_process_id,
329 content::FileDescriptorInfo* mappings) { 313 content::FileDescriptorInfo* mappings) {
330 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
331 if (!natives_fd_exists()) {
332 int v8_natives_fd = -1;
333 int v8_snapshot_fd = -1;
334 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
335 &v8_snapshot_fd)) {
336 v8_natives_fd_.reset(v8_natives_fd);
337 v8_snapshot_fd_.reset(v8_snapshot_fd);
338 }
339 }
340 // V8 can't start up without the source of the natives, but it can
341 // start up (slower) without the snapshot.
342 DCHECK(natives_fd_exists());
343 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
344 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
345 #endif // V8_USE_EXTERNAL_STARTUP_DATA
346 #if defined(OS_ANDROID) 314 #if defined(OS_ANDROID)
347 const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ; 315 const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ;
348 base::FilePath pak_file_path; 316 base::FilePath pak_file_path;
349 CHECK(PathService::Get(FILE_CAST_PAK, &pak_file_path)); 317 CHECK(PathService::Get(FILE_CAST_PAK, &pak_file_path));
350 base::File pak_file(pak_file_path, flags_open_read); 318 base::File pak_file(pak_file_path, flags_open_read);
351 if (!pak_file.IsValid()) { 319 if (!pak_file.IsValid()) {
352 NOTREACHED() << "Failed to open file when creating renderer process: " 320 NOTREACHED() << "Failed to open file when creating renderer process: "
353 << "cast_shell.pak"; 321 << "cast_shell.pak";
354 } 322 }
355 mappings->Transfer(kAndroidPakDescriptor, 323 mappings->Transfer(kAndroidPakDescriptor,
356 base::ScopedFD(pak_file.TakePlatformFile())); 324 base::ScopedFD(pak_file.TakePlatformFile()));
357 325
358 if (breakpad::IsCrashReporterEnabled()) { 326 if (breakpad::IsCrashReporterEnabled()) {
359 base::File minidump_file( 327 base::File minidump_file(
360 breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( 328 breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile(
361 child_process_id)); 329 child_process_id));
362 if (!minidump_file.IsValid()) { 330 if (!minidump_file.IsValid()) {
363 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " 331 LOG(ERROR) << "Failed to create file for minidump, crash reporting will "
364 << "be disabled for this process."; 332 << "be disabled for this process.";
365 } else { 333 } else {
366 mappings->Transfer(kAndroidMinidumpDescriptor, 334 mappings->Transfer(kAndroidMinidumpDescriptor,
367 base::ScopedFD(minidump_file.TakePlatformFile())); 335 base::ScopedFD(minidump_file.TakePlatformFile()));
368 } 336 }
369 } 337 }
370
371 base::FilePath app_data_path;
372 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &app_data_path));
373 base::FilePath icudata_path =
374 app_data_path.AppendASCII(base::i18n::kIcuDataFileName);
375 base::File icudata_file(icudata_path, flags_open_read);
376 if (!icudata_file.IsValid())
377 NOTREACHED() << "Failed to open ICU file when creating renderer process";
378 mappings->Transfer(kAndroidICUDataDescriptor,
379 base::ScopedFD(icudata_file.TakePlatformFile()));
380 #else 338 #else
381 int crash_signal_fd = GetCrashSignalFD(command_line); 339 int crash_signal_fd = GetCrashSignalFD(command_line);
382 if (crash_signal_fd >= 0) { 340 if (crash_signal_fd >= 0) {
383 mappings->Share(kCrashDumpSignal, crash_signal_fd); 341 mappings->Share(kCrashDumpSignal, crash_signal_fd);
384 } 342 }
385 #endif // defined(OS_ANDROID) 343 #endif // defined(OS_ANDROID)
386 } 344 }
387 345
388 #if defined(OS_ANDROID) && defined(VIDEO_HOLE) 346 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
389 content::ExternalVideoSurfaceContainer* 347 content::ExternalVideoSurfaceContainer*
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 process_type, dumps_path, false /* upload */); 386 process_type, dumps_path, false /* upload */);
429 // StartUploaderThread() even though upload is diferred. 387 // StartUploaderThread() even though upload is diferred.
430 // Breakpad-related memory is freed in the uploader thread. 388 // Breakpad-related memory is freed in the uploader thread.
431 crash_handler->StartUploaderThread(); 389 crash_handler->StartUploaderThread();
432 return crash_handler; 390 return crash_handler;
433 } 391 }
434 #endif // !defined(OS_ANDROID) 392 #endif // !defined(OS_ANDROID)
435 393
436 } // namespace shell 394 } // namespace shell
437 } // namespace chromecast 395 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698