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_browser_main_parts.h" | 5 #include "chromecast/browser/cast_browser_main_parts.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 void CastBrowserMainParts::PostMainMessageLoopStart() { | 161 void CastBrowserMainParts::PostMainMessageLoopStart() { |
162 cast_browser_process_->SetMetricsHelper(make_scoped_ptr( | 162 cast_browser_process_->SetMetricsHelper(make_scoped_ptr( |
163 new metrics::CastMetricsHelper(base::MessageLoopProxy::current()))); | 163 new metrics::CastMetricsHelper(base::MessageLoopProxy::current()))); |
164 | 164 |
165 #if defined(OS_ANDROID) | 165 #if defined(OS_ANDROID) |
166 base::MessageLoopForUI::current()->Start(); | 166 base::MessageLoopForUI::current()->Start(); |
167 #endif // defined(OS_ANDROID) | 167 #endif // defined(OS_ANDROID) |
168 } | 168 } |
169 | 169 |
170 int CastBrowserMainParts::PreCreateThreads() { | 170 int CastBrowserMainParts::PreCreateThreads() { |
171 #if !defined(OS_ANDROID) | 171 #if defined(OS_ANDROID) |
| 172 // GPU process is started immediately after threads are created, requiring |
| 173 // CrashDumpManager to be initialized beforehand. |
| 174 base::FilePath crash_dumps_dir; |
| 175 if (!chromecast::CrashHandler::GetCrashDumpLocation(&crash_dumps_dir)) { |
| 176 LOG(ERROR) << "Could not find crash dump location."; |
| 177 } |
| 178 cast_browser_process_->SetCrashDumpManager( |
| 179 make_scoped_ptr(new breakpad::CrashDumpManager(crash_dumps_dir))); |
| 180 #else |
172 base::FilePath home_dir; | 181 base::FilePath home_dir; |
173 CHECK(PathService::Get(DIR_CAST_HOME, &home_dir)); | 182 CHECK(PathService::Get(DIR_CAST_HOME, &home_dir)); |
174 if (!base::CreateDirectory(home_dir)) | 183 if (!base::CreateDirectory(home_dir)) |
175 return 1; | 184 return 1; |
176 #endif // !defined(OS_ANDROID) | 185 #endif |
177 return 0; | 186 return 0; |
178 } | 187 } |
179 | 188 |
180 void CastBrowserMainParts::PreMainMessageLoopRun() { | 189 void CastBrowserMainParts::PreMainMessageLoopRun() { |
181 scoped_refptr<PrefRegistrySimple> pref_registry(new PrefRegistrySimple()); | 190 scoped_refptr<PrefRegistrySimple> pref_registry(new PrefRegistrySimple()); |
182 metrics::RegisterPrefs(pref_registry.get()); | 191 metrics::RegisterPrefs(pref_registry.get()); |
183 cast_browser_process_->SetPrefService( | 192 cast_browser_process_->SetPrefService( |
184 PrefServiceHelper::CreatePrefService(pref_registry.get())); | 193 PrefServiceHelper::CreatePrefService(pref_registry.get())); |
185 | 194 |
186 #if !defined(OS_ANDROID) | 195 #if !defined(OS_ANDROID) |
187 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 196 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
188 if (cmd_line->HasSwitch(switches::kEnableCmaMediaPipeline)) | 197 if (cmd_line->HasSwitch(switches::kEnableCmaMediaPipeline)) |
189 ::media::SetBrowserCdmFactory(new media::CastBrowserCdmFactory); | 198 ::media::SetBrowserCdmFactory(new media::CastBrowserCdmFactory); |
190 #endif // !defined(OS_ANDROID) | 199 #endif // !defined(OS_ANDROID) |
191 | 200 |
192 url_request_context_factory_->InitializeOnUIThread(); | 201 url_request_context_factory_->InitializeOnUIThread(); |
193 | 202 |
194 cast_browser_process_->SetBrowserContext( | 203 cast_browser_process_->SetBrowserContext( |
195 make_scoped_ptr(new CastBrowserContext(url_request_context_factory_))); | 204 make_scoped_ptr(new CastBrowserContext(url_request_context_factory_))); |
196 cast_browser_process_->SetMetricsServiceClient( | 205 cast_browser_process_->SetMetricsServiceClient( |
197 metrics::CastMetricsServiceClient::Create( | 206 metrics::CastMetricsServiceClient::Create( |
198 content::BrowserThread::GetBlockingPool(), | 207 content::BrowserThread::GetBlockingPool(), |
199 cast_browser_process_->pref_service(), | 208 cast_browser_process_->pref_service(), |
200 cast_browser_process_->browser_context()->GetRequestContext())); | 209 cast_browser_process_->browser_context()->GetRequestContext())); |
201 | 210 |
202 #if defined(OS_ANDROID) | |
203 base::FilePath crash_dumps_dir; | |
204 if (!chromecast::CrashHandler::GetCrashDumpLocation(&crash_dumps_dir)) { | |
205 LOG(ERROR) << "Could not find crash dump location."; | |
206 } | |
207 cast_browser_process_->SetCrashDumpManager( | |
208 make_scoped_ptr(new breakpad::CrashDumpManager(crash_dumps_dir))); | |
209 #endif | |
210 | |
211 if (!PlatformClientAuth::Initialize()) | 211 if (!PlatformClientAuth::Initialize()) |
212 LOG(ERROR) << "PlatformClientAuth::Initialize failed."; | 212 LOG(ERROR) << "PlatformClientAuth::Initialize failed."; |
213 | 213 |
214 cast_browser_process_->SetRemoteDebuggingServer( | 214 cast_browser_process_->SetRemoteDebuggingServer( |
215 make_scoped_ptr(new RemoteDebuggingServer())); | 215 make_scoped_ptr(new RemoteDebuggingServer())); |
216 | 216 |
217 cast_browser_process_->SetCastService(CastService::Create( | 217 cast_browser_process_->SetCastService(CastService::Create( |
218 cast_browser_process_->browser_context(), | 218 cast_browser_process_->browser_context(), |
219 cast_browser_process_->pref_service(), | 219 cast_browser_process_->pref_service(), |
220 cast_browser_process_->metrics_service_client(), | 220 cast_browser_process_->metrics_service_client(), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 252 } |
253 | 253 |
254 void CastBrowserMainParts::PostMainMessageLoopRun() { | 254 void CastBrowserMainParts::PostMainMessageLoopRun() { |
255 cast_browser_process_->cast_service()->Finalize(); | 255 cast_browser_process_->cast_service()->Finalize(); |
256 cast_browser_process_->metrics_service_client()->Finalize(); | 256 cast_browser_process_->metrics_service_client()->Finalize(); |
257 cast_browser_process_.reset(); | 257 cast_browser_process_.reset(); |
258 } | 258 } |
259 | 259 |
260 } // namespace shell | 260 } // namespace shell |
261 } // namespace chromecast | 261 } // namespace chromecast |
OLD | NEW |