| 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/app/cast_main_delegate.h" | 5 #include "chromecast/app/cast_main_delegate.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/cpu.h" | 10 #include "base/cpu.h" |
| 11 #include "base/lazy_instance.h" |
| 9 #include "base/logging.h" | 12 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 11 #include "base/posix/global_descriptors.h" | 14 #include "base/posix/global_descriptors.h" |
| 12 #include "chromecast/browser/cast_content_browser_client.h" | 15 #include "chromecast/browser/cast_content_browser_client.h" |
| 13 #include "chromecast/common/cast_paths.h" | 16 #include "chromecast/common/cast_paths.h" |
| 14 #include "chromecast/common/cast_resource_delegate.h" | 17 #include "chromecast/common/cast_resource_delegate.h" |
| 15 #include "chromecast/common/global_descriptors.h" | 18 #include "chromecast/common/global_descriptors.h" |
| 19 #include "chromecast/crash/cast_crash_reporter_client.h" |
| 16 #include "chromecast/renderer/cast_content_renderer_client.h" | 20 #include "chromecast/renderer/cast_content_renderer_client.h" |
| 21 #include "components/crash/app/crash_reporter_client.h" |
| 17 #include "content/public/browser/browser_main_runner.h" | 22 #include "content/public/browser/browser_main_runner.h" |
| 18 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 20 | 25 |
| 21 #if defined(OS_ANDROID) | 26 #if defined(OS_ANDROID) |
| 22 #include "chromecast/crash/android/crash_handler.h" | 27 #include "chromecast/crash/android/crash_handler.h" |
| 23 #endif // defined(OS_ANDROID) | 28 #endif // defined(OS_ANDROID) |
| 24 | 29 |
| 30 namespace { |
| 31 |
| 32 #if !defined(OS_ANDROID) |
| 33 base::LazyInstance<chromecast::CastCrashReporterClient>::Leaky |
| 34 g_crash_reporter_client = LAZY_INSTANCE_INITIALIZER; |
| 35 #endif // !defined(OS_ANDROID) |
| 36 |
| 37 } // namespace |
| 38 |
| 25 namespace chromecast { | 39 namespace chromecast { |
| 26 namespace shell { | 40 namespace shell { |
| 27 | 41 |
| 28 CastMainDelegate::CastMainDelegate() { | 42 CastMainDelegate::CastMainDelegate() { |
| 29 } | 43 } |
| 30 | 44 |
| 31 CastMainDelegate::~CastMainDelegate() { | 45 CastMainDelegate::~CastMainDelegate() { |
| 32 } | 46 } |
| 33 | 47 |
| 34 bool CastMainDelegate::BasicStartupComplete(int* exit_code) { | 48 bool CastMainDelegate::BasicStartupComplete(int* exit_code) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 62 #endif | 76 #endif |
| 63 | 77 |
| 64 const base::CommandLine* command_line(base::CommandLine::ForCurrentProcess()); | 78 const base::CommandLine* command_line(base::CommandLine::ForCurrentProcess()); |
| 65 std::string process_type = | 79 std::string process_type = |
| 66 command_line->GetSwitchValueASCII(switches::kProcessType); | 80 command_line->GetSwitchValueASCII(switches::kProcessType); |
| 67 | 81 |
| 68 #if defined(OS_ANDROID) | 82 #if defined(OS_ANDROID) |
| 69 base::FilePath log_file; | 83 base::FilePath log_file; |
| 70 PathService::Get(FILE_CAST_ANDROID_LOG, &log_file); | 84 PathService::Get(FILE_CAST_ANDROID_LOG, &log_file); |
| 71 chromecast::CrashHandler::Initialize(process_type, log_file); | 85 chromecast::CrashHandler::Initialize(process_type, log_file); |
| 86 #else |
| 87 crash_reporter::SetCrashReporterClient(g_crash_reporter_client.Pointer()); |
| 88 |
| 89 if (process_type != switches::kZygoteProcess) { |
| 90 CastCrashReporterClient::InitCrashReporter(process_type); |
| 91 } |
| 72 #endif // defined(OS_ANDROID) | 92 #endif // defined(OS_ANDROID) |
| 73 | 93 |
| 74 InitializeResourceBundle(); | 94 InitializeResourceBundle(); |
| 75 } | 95 } |
| 76 | 96 |
| 77 int CastMainDelegate::RunProcess( | 97 int CastMainDelegate::RunProcess( |
| 78 const std::string& process_type, | 98 const std::string& process_type, |
| 79 const content::MainFunctionParams& main_function_params) { | 99 const content::MainFunctionParams& main_function_params) { |
| 80 #if defined(OS_ANDROID) | 100 #if defined(OS_ANDROID) |
| 81 if (!process_type.empty()) | 101 if (!process_type.empty()) |
| 82 return -1; | 102 return -1; |
| 83 | 103 |
| 84 // Note: Android must handle running its own browser process. | 104 // Note: Android must handle running its own browser process. |
| 85 // See ChromeMainDelegateAndroid::RunProcess. | 105 // See ChromeMainDelegateAndroid::RunProcess. |
| 86 browser_runner_.reset(content::BrowserMainRunner::Create()); | 106 browser_runner_.reset(content::BrowserMainRunner::Create()); |
| 87 return browser_runner_->Initialize(main_function_params); | 107 return browser_runner_->Initialize(main_function_params); |
| 88 #else | 108 #else |
| 89 return -1; | 109 return -1; |
| 90 #endif // defined(OS_ANDROID) | 110 #endif // defined(OS_ANDROID) |
| 91 } | 111 } |
| 92 | 112 |
| 93 #if !defined(OS_ANDROID) | 113 #if !defined(OS_ANDROID) |
| 94 void CastMainDelegate::ZygoteForked() { | 114 void CastMainDelegate::ZygoteForked() { |
| 115 const base::CommandLine* command_line(base::CommandLine::ForCurrentProcess()); |
| 116 std::string process_type = |
| 117 command_line->GetSwitchValueASCII(switches::kProcessType); |
| 118 CastCrashReporterClient::InitCrashReporter(process_type); |
| 95 } | 119 } |
| 96 #endif // !defined(OS_ANDROID) | 120 #endif // !defined(OS_ANDROID) |
| 97 | 121 |
| 98 void CastMainDelegate::InitializeResourceBundle() { | 122 void CastMainDelegate::InitializeResourceBundle() { |
| 99 #if defined(OS_ANDROID) | 123 #if defined(OS_ANDROID) |
| 100 // On Android, the renderer runs with a different UID and can never access | 124 // On Android, the renderer runs with a different UID and can never access |
| 101 // the file system. Use the file descriptor passed in at launch time. | 125 // the file system. Use the file descriptor passed in at launch time. |
| 102 int pak_fd = | 126 int pak_fd = |
| 103 base::GlobalDescriptors::GetInstance()->MaybeGet(kAndroidPakDescriptor); | 127 base::GlobalDescriptors::GetInstance()->MaybeGet(kAndroidPakDescriptor); |
| 104 if (pak_fd >= 0) { | 128 if (pak_fd >= 0) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 131 } | 155 } |
| 132 | 156 |
| 133 content::ContentRendererClient* | 157 content::ContentRendererClient* |
| 134 CastMainDelegate::CreateContentRendererClient() { | 158 CastMainDelegate::CreateContentRendererClient() { |
| 135 renderer_client_.reset(new CastContentRendererClient); | 159 renderer_client_.reset(new CastContentRendererClient); |
| 136 return renderer_client_.get(); | 160 return renderer_client_.get(); |
| 137 } | 161 } |
| 138 | 162 |
| 139 } // namespace shell | 163 } // namespace shell |
| 140 } // namespace chromecast | 164 } // namespace chromecast |
| OLD | NEW |