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

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: compile 2 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 int opener_render_frame_id, 305 int opener_render_frame_id,
322 bool* no_javascript_access) { 306 bool* no_javascript_access) {
323 *no_javascript_access = true; 307 *no_javascript_access = true;
324 return false; 308 return false;
325 } 309 }
326 310
327 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 311 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
328 const base::CommandLine& command_line, 312 const base::CommandLine& command_line,
329 int child_process_id, 313 int child_process_id,
330 content::FileDescriptorInfo* mappings) { 314 content::FileDescriptorInfo* mappings) {
331 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
332 if (!natives_fd_exists()) {
333 int v8_natives_fd = -1;
334 int v8_snapshot_fd = -1;
335 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
336 &v8_snapshot_fd)) {
337 v8_natives_fd_.reset(v8_natives_fd);
338 v8_snapshot_fd_.reset(v8_snapshot_fd);
339 }
340 }
341 // V8 can't start up without the source of the natives, but it can
342 // start up (slower) without the snapshot.
343 DCHECK(natives_fd_exists());
344 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
345 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
346 #endif // V8_USE_EXTERNAL_STARTUP_DATA
347 #if defined(OS_ANDROID) 315 #if defined(OS_ANDROID)
348 const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ; 316 const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ;
349 base::FilePath pak_file_path; 317 base::FilePath pak_file_path;
350 CHECK(PathService::Get(FILE_CAST_PAK, &pak_file_path)); 318 CHECK(PathService::Get(FILE_CAST_PAK, &pak_file_path));
351 base::File pak_file(pak_file_path, flags_open_read); 319 base::File pak_file(pak_file_path, flags_open_read);
352 if (!pak_file.IsValid()) { 320 if (!pak_file.IsValid()) {
353 NOTREACHED() << "Failed to open file when creating renderer process: " 321 NOTREACHED() << "Failed to open file when creating renderer process: "
354 << "cast_shell.pak"; 322 << "cast_shell.pak";
355 } 323 }
356 mappings->Transfer(kAndroidPakDescriptor, 324 mappings->Transfer(kAndroidPakDescriptor,
357 base::ScopedFD(pak_file.TakePlatformFile())); 325 base::ScopedFD(pak_file.TakePlatformFile()));
358 326
359 if (breakpad::IsCrashReporterEnabled()) { 327 if (breakpad::IsCrashReporterEnabled()) {
360 base::File minidump_file( 328 base::File minidump_file(
361 breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( 329 breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile(
362 child_process_id)); 330 child_process_id));
363 if (!minidump_file.IsValid()) { 331 if (!minidump_file.IsValid()) {
364 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " 332 LOG(ERROR) << "Failed to create file for minidump, crash reporting will "
365 << "be disabled for this process."; 333 << "be disabled for this process.";
366 } else { 334 } else {
367 mappings->Transfer(kAndroidMinidumpDescriptor, 335 mappings->Transfer(kAndroidMinidumpDescriptor,
368 base::ScopedFD(minidump_file.TakePlatformFile())); 336 base::ScopedFD(minidump_file.TakePlatformFile()));
369 } 337 }
370 } 338 }
371
372 base::FilePath app_data_path;
373 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &app_data_path));
374 base::FilePath icudata_path =
375 app_data_path.AppendASCII(base::i18n::kIcuDataFileName);
376 base::File icudata_file(icudata_path, flags_open_read);
377 if (!icudata_file.IsValid())
378 NOTREACHED() << "Failed to open ICU file when creating renderer process";
379 mappings->Transfer(kAndroidICUDataDescriptor,
380 base::ScopedFD(icudata_file.TakePlatformFile()));
381 #else 339 #else
382 int crash_signal_fd = GetCrashSignalFD(command_line); 340 int crash_signal_fd = GetCrashSignalFD(command_line);
383 if (crash_signal_fd >= 0) { 341 if (crash_signal_fd >= 0) {
384 mappings->Share(kCrashDumpSignal, crash_signal_fd); 342 mappings->Share(kCrashDumpSignal, crash_signal_fd);
385 } 343 }
386 #endif // defined(OS_ANDROID) 344 #endif // defined(OS_ANDROID)
387 } 345 }
388 346
389 #if defined(OS_ANDROID) && defined(VIDEO_HOLE) 347 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
390 content::ExternalVideoSurfaceContainer* 348 content::ExternalVideoSurfaceContainer*
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 process_type, dumps_path, false /* upload */); 387 process_type, dumps_path, false /* upload */);
430 // StartUploaderThread() even though upload is diferred. 388 // StartUploaderThread() even though upload is diferred.
431 // Breakpad-related memory is freed in the uploader thread. 389 // Breakpad-related memory is freed in the uploader thread.
432 crash_handler->StartUploaderThread(); 390 crash_handler->StartUploaderThread();
433 return crash_handler; 391 return crash_handler;
434 } 392 }
435 #endif // !defined(OS_ANDROID) 393 #endif // !defined(OS_ANDROID)
436 394
437 } // namespace shell 395 } // namespace shell
438 } // namespace chromecast 396 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698