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 <string> | 7 #include <string> |
8 #if !defined(OS_ANDROID) | 8 #if !defined(OS_ANDROID) |
9 #include <signal.h> | 9 #include <signal.h> |
10 #include <sys/prctl.h> | 10 #include <sys/prctl.h> |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 std::string(g_default_switches[i].switch_name), | 206 std::string(g_default_switches[i].switch_name), |
207 std::string(g_default_switches[i].switch_value)); | 207 std::string(g_default_switches[i].switch_value)); |
208 ++i; | 208 ++i; |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 } // namespace | 212 } // namespace |
213 | 213 |
214 CastBrowserMainParts::CastBrowserMainParts( | 214 CastBrowserMainParts::CastBrowserMainParts( |
215 const content::MainFunctionParams& parameters, | 215 const content::MainFunctionParams& parameters, |
216 URLRequestContextFactory* url_request_context_factory, | 216 URLRequestContextFactory* url_request_context_factory) |
217 scoped_ptr<::media::AudioManagerFactory> audio_manager_factory) | |
218 : BrowserMainParts(), | 217 : BrowserMainParts(), |
219 cast_browser_process_(new CastBrowserProcess()), | 218 cast_browser_process_(new CastBrowserProcess()), |
220 parameters_(parameters), | 219 parameters_(parameters), |
221 url_request_context_factory_(url_request_context_factory), | 220 url_request_context_factory_(url_request_context_factory), |
222 audio_manager_factory_(audio_manager_factory.Pass()), | |
223 net_log_(new CastNetLog()) { | 221 net_log_(new CastNetLog()) { |
224 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 222 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
225 AddDefaultCommandLineSwitches(command_line); | 223 AddDefaultCommandLineSwitches(command_line); |
226 } | 224 } |
227 | 225 |
228 CastBrowserMainParts::~CastBrowserMainParts() { | 226 CastBrowserMainParts::~CastBrowserMainParts() { |
229 } | 227 } |
230 | 228 |
231 void CastBrowserMainParts::PreMainMessageLoopStart() { | 229 void CastBrowserMainParts::PreMainMessageLoopStart() { |
232 // GroupedHistograms needs to be initialized before any threads are created | 230 // GroupedHistograms needs to be initialized before any threads are created |
233 // to prevent race conditions between calls to Preregister and those threads | 231 // to prevent race conditions between calls to Preregister and those threads |
234 // attempting to collect metrics. | 232 // attempting to collect metrics. |
235 // This call must also be before NetworkChangeNotifier, as it generates | 233 // This call must also be before NetworkChangeNotifier, as it generates |
236 // Net/DNS metrics. | 234 // Net/DNS metrics. |
237 metrics::PreregisterAllGroupedHistograms(); | 235 metrics::PreregisterAllGroupedHistograms(); |
238 | 236 |
239 // Set the platform's implementation of AudioManagerFactory. | |
240 if (audio_manager_factory_) | |
241 ::media::AudioManager::SetFactory(audio_manager_factory_.release()); | |
242 | |
243 #if defined(OS_ANDROID) | 237 #if defined(OS_ANDROID) |
244 net::NetworkChangeNotifier::SetFactory( | 238 net::NetworkChangeNotifier::SetFactory( |
245 new net::NetworkChangeNotifierFactoryAndroid()); | 239 new net::NetworkChangeNotifierFactoryAndroid()); |
246 #else | 240 #else |
247 net::NetworkChangeNotifier::SetFactory( | 241 net::NetworkChangeNotifier::SetFactory( |
248 new NetworkChangeNotifierFactoryCast()); | 242 new NetworkChangeNotifierFactoryCast()); |
249 #endif // defined(OS_ANDROID) | 243 #endif // defined(OS_ANDROID) |
250 } | 244 } |
251 | 245 |
252 void CastBrowserMainParts::PostMainMessageLoopStart() { | 246 void CastBrowserMainParts::PostMainMessageLoopStart() { |
(...skipping 13 matching lines...) Expand all Loading... |
266 if (!chromecast::CrashHandler::GetCrashDumpLocation(&crash_dumps_dir)) { | 260 if (!chromecast::CrashHandler::GetCrashDumpLocation(&crash_dumps_dir)) { |
267 LOG(ERROR) << "Could not find crash dump location."; | 261 LOG(ERROR) << "Could not find crash dump location."; |
268 } | 262 } |
269 cast_browser_process_->SetCrashDumpManager( | 263 cast_browser_process_->SetCrashDumpManager( |
270 make_scoped_ptr(new breakpad::CrashDumpManager(crash_dumps_dir))); | 264 make_scoped_ptr(new breakpad::CrashDumpManager(crash_dumps_dir))); |
271 #else | 265 #else |
272 base::FilePath home_dir; | 266 base::FilePath home_dir; |
273 CHECK(PathService::Get(DIR_CAST_HOME, &home_dir)); | 267 CHECK(PathService::Get(DIR_CAST_HOME, &home_dir)); |
274 if (!base::CreateDirectory(home_dir)) | 268 if (!base::CreateDirectory(home_dir)) |
275 return 1; | 269 return 1; |
| 270 |
| 271 // AudioManager is created immediately after threads are created, requiring |
| 272 // AudioManagerFactory to be set beforehand. |
| 273 scoped_ptr< ::media::AudioManagerFactory> audio_manager_factory = |
| 274 cast_browser_process_->browser_client()->CreateAudioManagerFactory(); |
| 275 ::media::AudioManager::SetFactory(audio_manager_factory.release()); |
276 #endif | 276 #endif |
277 | 277 |
278 #if defined(USE_AURA) | 278 #if defined(USE_AURA) |
279 // Screen can (and should) exist even with no displays connected. Its presence | 279 // Screen can (and should) exist even with no displays connected. Its presence |
280 // is assumed as an interface to access display information, e.g. from metrics | 280 // is assumed as an interface to access display information, e.g. from metrics |
281 // code. See CastContentWindow::CreateWindowTree for update when resolution | 281 // code. See CastContentWindow::CreateWindowTree for update when resolution |
282 // is available. | 282 // is available. |
283 cast_browser_process_->SetCastScreen(make_scoped_ptr(new CastScreen)); | 283 cast_browser_process_->SetCastScreen(make_scoped_ptr(new CastScreen)); |
284 DCHECK(!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)); | 284 DCHECK(!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)); |
285 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, | 285 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 #if defined(USE_AURA) | 401 #if defined(USE_AURA) |
402 aura::Env::DeleteInstance(); | 402 aura::Env::DeleteInstance(); |
403 #endif | 403 #endif |
404 | 404 |
405 DeregisterKillOnAlarm(); | 405 DeregisterKillOnAlarm(); |
406 #endif | 406 #endif |
407 } | 407 } |
408 | 408 |
409 } // namespace shell | 409 } // namespace shell |
410 } // namespace chromecast | 410 } // namespace chromecast |
OLD | NEW |