OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/browser_main_loop.h" | 5 #include "content/browser/browser_main_loop.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 34 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
35 #include "content/browser/histogram_synchronizer.h" | 35 #include "content/browser/histogram_synchronizer.h" |
36 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 36 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
37 #include "content/browser/media/capture/audio_mirroring_manager.h" | 37 #include "content/browser/media/capture/audio_mirroring_manager.h" |
38 #include "content/browser/media/media_internals.h" | 38 #include "content/browser/media/media_internals.h" |
39 #include "content/browser/net/browser_online_state_observer.h" | 39 #include "content/browser/net/browser_online_state_observer.h" |
40 #include "content/browser/plugin_service_impl.h" | 40 #include "content/browser/plugin_service_impl.h" |
41 #include "content/browser/renderer_host/media/media_stream_manager.h" | 41 #include "content/browser/renderer_host/media/media_stream_manager.h" |
42 #include "content/browser/speech/speech_recognition_manager_impl.h" | 42 #include "content/browser/speech/speech_recognition_manager_impl.h" |
43 #include "content/browser/startup_task_runner.h" | 43 #include "content/browser/startup_task_runner.h" |
| 44 #include "content/browser/time_zone_monitor.h" |
44 #include "content/browser/webui/content_web_ui_controller_factory.h" | 45 #include "content/browser/webui/content_web_ui_controller_factory.h" |
45 #include "content/browser/webui/url_data_manager.h" | 46 #include "content/browser/webui/url_data_manager.h" |
46 #include "content/public/browser/browser_main_parts.h" | 47 #include "content/public/browser/browser_main_parts.h" |
47 #include "content/public/browser/browser_shutdown.h" | 48 #include "content/public/browser/browser_shutdown.h" |
48 #include "content/public/browser/content_browser_client.h" | 49 #include "content/public/browser/content_browser_client.h" |
49 #include "content/public/browser/render_process_host.h" | 50 #include "content/public/browser/render_process_host.h" |
50 #include "content/public/browser/tracing_controller.h" | 51 #include "content/public/browser/tracing_controller.h" |
51 #include "content/public/common/content_switches.h" | 52 #include "content/public/common/content_switches.h" |
52 #include "content/public/common/main_function_params.h" | 53 #include "content/public/common/main_function_params.h" |
53 #include "content/public/common/result_codes.h" | 54 #include "content/public/common/result_codes.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 319 |
319 BrowserMainLoop::~BrowserMainLoop() { | 320 BrowserMainLoop::~BrowserMainLoop() { |
320 DCHECK_EQ(this, g_current_browser_main_loop); | 321 DCHECK_EQ(this, g_current_browser_main_loop); |
321 #if !defined(OS_IOS) | 322 #if !defined(OS_IOS) |
322 ui::Clipboard::DestroyClipboardForCurrentThread(); | 323 ui::Clipboard::DestroyClipboardForCurrentThread(); |
323 #endif // !defined(OS_IOS) | 324 #endif // !defined(OS_IOS) |
324 g_current_browser_main_loop = NULL; | 325 g_current_browser_main_loop = NULL; |
325 } | 326 } |
326 | 327 |
327 void BrowserMainLoop::Init() { | 328 void BrowserMainLoop::Init() { |
328 TRACE_EVENT0("startup", "BrowserMainLoop::Init") | 329 TRACE_EVENT0("startup", "BrowserMainLoop::Init"); |
329 parts_.reset( | 330 parts_.reset( |
330 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); | 331 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); |
331 } | 332 } |
332 | 333 |
333 // BrowserMainLoop stages ================================================== | 334 // BrowserMainLoop stages ================================================== |
334 | 335 |
335 void BrowserMainLoop::EarlyInitialization() { | 336 void BrowserMainLoop::EarlyInitialization() { |
336 TRACE_EVENT0("startup", "BrowserMainLoop::EarlyInitialization"); | 337 TRACE_EVENT0("startup", "BrowserMainLoop::EarlyInitialization"); |
337 | 338 |
338 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 339 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 RenderProcessHost::SetMaxRendererProcessCount(process_limit); | 391 RenderProcessHost::SetMaxRendererProcessCount(process_limit); |
391 } | 392 } |
392 } | 393 } |
393 #endif // !defined(OS_IOS) | 394 #endif // !defined(OS_IOS) |
394 | 395 |
395 if (parts_) | 396 if (parts_) |
396 parts_->PostEarlyInitialization(); | 397 parts_->PostEarlyInitialization(); |
397 } | 398 } |
398 | 399 |
399 void BrowserMainLoop::MainMessageLoopStart() { | 400 void BrowserMainLoop::MainMessageLoopStart() { |
400 TRACE_EVENT0("startup", "BrowserMainLoop::MainMessageLoopStart") | 401 TRACE_EVENT0("startup", "BrowserMainLoop::MainMessageLoopStart"); |
401 if (parts_) { | 402 if (parts_) { |
402 TRACE_EVENT0("startup", | 403 TRACE_EVENT0("startup", |
403 "BrowserMainLoop::MainMessageLoopStart:PreMainMessageLoopStart"); | 404 "BrowserMainLoop::MainMessageLoopStart:PreMainMessageLoopStart"); |
404 parts_->PreMainMessageLoopStart(); | 405 parts_->PreMainMessageLoopStart(); |
405 } | 406 } |
406 | 407 |
407 #if defined(OS_WIN) | 408 #if defined(OS_WIN) |
408 // If we're running tests (ui_task is non-null), then the ResourceBundle | 409 // If we're running tests (ui_task is non-null), then the ResourceBundle |
409 // has already been initialized. | 410 // has already been initialized. |
410 if (!parameters_.ui_task) { | 411 if (!parameters_.ui_task) { |
411 // Override the configured locale with the user's preferred UI language. | 412 // Override the configured locale with the user's preferred UI language. |
412 l10n_util::OverrideLocaleWithUILanguageList(); | 413 l10n_util::OverrideLocaleWithUILanguageList(); |
413 } | 414 } |
414 #endif | 415 #endif |
415 | 416 |
416 // Create a MessageLoop if one does not already exist for the current thread. | 417 // Create a MessageLoop if one does not already exist for the current thread. |
417 if (!base::MessageLoop::current()) | 418 if (!base::MessageLoop::current()) |
418 main_message_loop_.reset(new base::MessageLoopForUI); | 419 main_message_loop_.reset(new base::MessageLoopForUI); |
419 | 420 |
420 InitializeMainThread(); | 421 InitializeMainThread(); |
421 | 422 |
422 { | 423 { |
423 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SystemMonitor") | 424 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SystemMonitor"); |
424 system_monitor_.reset(new base::SystemMonitor); | 425 system_monitor_.reset(new base::SystemMonitor); |
425 } | 426 } |
426 { | 427 { |
427 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:PowerMonitor") | 428 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:PowerMonitor"); |
428 scoped_ptr<base::PowerMonitorSource> power_monitor_source( | 429 scoped_ptr<base::PowerMonitorSource> power_monitor_source( |
429 new base::PowerMonitorDeviceSource()); | 430 new base::PowerMonitorDeviceSource()); |
430 power_monitor_.reset(new base::PowerMonitor(power_monitor_source.Pass())); | 431 power_monitor_.reset(new base::PowerMonitor(power_monitor_source.Pass())); |
431 } | 432 } |
432 { | 433 { |
433 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:HighResTimerManager") | 434 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:HighResTimerManager"); |
434 hi_res_timer_manager_.reset(new base::HighResolutionTimerManager); | 435 hi_res_timer_manager_.reset(new base::HighResolutionTimerManager); |
435 } | 436 } |
436 { | 437 { |
437 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:NetworkChangeNotifier") | 438 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:NetworkChangeNotifier"); |
438 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 439 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
439 } | 440 } |
440 | 441 |
441 #if !defined(OS_IOS) | 442 #if !defined(OS_IOS) |
442 { | 443 { |
443 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MediaFeatures") | 444 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MediaFeatures"); |
444 media::InitializeCPUSpecificMediaFeatures(); | 445 media::InitializeCPUSpecificMediaFeatures(); |
445 } | 446 } |
446 { | 447 { |
447 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:AudioMan") | 448 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:AudioMan"); |
448 audio_manager_.reset(media::AudioManager::Create( | 449 audio_manager_.reset(media::AudioManager::Create( |
449 MediaInternals::GetInstance())); | 450 MediaInternals::GetInstance())); |
450 } | 451 } |
451 { | 452 { |
452 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MidiManager") | 453 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MidiManager"); |
453 midi_manager_.reset(media::MidiManager::Create()); | 454 midi_manager_.reset(media::MidiManager::Create()); |
454 } | 455 } |
455 { | 456 { |
456 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:ContentWebUIController") | 457 TRACE_EVENT0("startup", |
| 458 "BrowserMainLoop::Subsystem:ContentWebUIController"); |
457 WebUIControllerFactory::RegisterFactory( | 459 WebUIControllerFactory::RegisterFactory( |
458 ContentWebUIControllerFactory::GetInstance()); | 460 ContentWebUIControllerFactory::GetInstance()); |
459 } | 461 } |
460 | 462 |
461 { | 463 { |
462 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:AudioMirroringManager") | 464 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:AudioMirroringManager"); |
463 audio_mirroring_manager_.reset(new AudioMirroringManager()); | 465 audio_mirroring_manager_.reset(new AudioMirroringManager()); |
464 } | 466 } |
465 { | 467 { |
466 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:OnlineStateObserver") | 468 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:OnlineStateObserver"); |
467 online_state_observer_.reset(new BrowserOnlineStateObserver); | 469 online_state_observer_.reset(new BrowserOnlineStateObserver); |
468 } | 470 } |
469 | 471 |
470 { | 472 { |
471 system_stats_monitor_.reset(new base::debug::TraceEventSystemStatsMonitor( | 473 system_stats_monitor_.reset(new base::debug::TraceEventSystemStatsMonitor( |
472 base::ThreadTaskRunnerHandle::Get())); | 474 base::ThreadTaskRunnerHandle::Get())); |
473 } | 475 } |
474 #endif // !defined(OS_IOS) | 476 #endif // !defined(OS_IOS) |
475 | 477 |
476 #if defined(OS_WIN) | 478 #if defined(OS_WIN) |
477 system_message_window_.reset(new SystemMessageWindowWin); | 479 system_message_window_.reset(new SystemMessageWindowWin); |
478 #endif | 480 #endif |
479 | 481 |
480 if (parts_) | 482 if (parts_) |
481 parts_->PostMainMessageLoopStart(); | 483 parts_->PostMainMessageLoopStart(); |
482 | 484 |
483 #if !defined(OS_IOS) | 485 #if !defined(OS_IOS) |
484 // Start tracing to a file if needed. Only do this after starting the main | 486 // Start tracing to a file if needed. Only do this after starting the main |
485 // message loop to avoid calling MessagePumpForUI::ScheduleWork() before | 487 // message loop to avoid calling MessagePumpForUI::ScheduleWork() before |
486 // MessagePumpForUI::Start() as it will crash the browser. | 488 // MessagePumpForUI::Start() as it will crash the browser. |
487 if (is_tracing_startup_) { | 489 if (is_tracing_startup_) { |
488 TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracing") | 490 TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracing"); |
489 InitStartupTracing(parsed_command_line_); | 491 InitStartupTracing(parsed_command_line_); |
490 } | 492 } |
491 #endif // !defined(OS_IOS) | 493 #endif // !defined(OS_IOS) |
492 | 494 |
493 #if defined(OS_ANDROID) | 495 #if defined(OS_ANDROID) |
494 { | 496 { |
495 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SurfaceTexturePeer") | 497 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SurfaceTexturePeer"); |
496 SurfaceTexturePeer::InitInstance(new SurfaceTexturePeerBrowserImpl()); | 498 SurfaceTexturePeer::InitInstance(new SurfaceTexturePeerBrowserImpl()); |
497 } | 499 } |
498 #endif | 500 #endif |
499 | 501 |
500 if (parsed_command_line_.HasSwitch(switches::kMemoryMetrics)) { | 502 if (parsed_command_line_.HasSwitch(switches::kMemoryMetrics)) { |
501 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MemoryObserver") | 503 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MemoryObserver"); |
502 memory_observer_.reset(new MemoryObserver()); | 504 memory_observer_.reset(new MemoryObserver()); |
503 base::MessageLoop::current()->AddTaskObserver(memory_observer_.get()); | 505 base::MessageLoop::current()->AddTaskObserver(memory_observer_.get()); |
504 } | 506 } |
505 | 507 |
506 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) | 508 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) |
507 trace_memory_controller_.reset(new base::debug::TraceMemoryController( | 509 trace_memory_controller_.reset(new base::debug::TraceMemoryController( |
508 base::MessageLoop::current()->message_loop_proxy(), | 510 base::MessageLoop::current()->message_loop_proxy(), |
509 ::HeapProfilerWithPseudoStackStart, | 511 ::HeapProfilerWithPseudoStackStart, |
510 ::HeapProfilerStop, | 512 ::HeapProfilerStop, |
511 ::GetHeapProfile)); | 513 ::GetHeapProfile)); |
512 #endif | 514 #endif |
513 } | 515 } |
514 | 516 |
515 int BrowserMainLoop::PreCreateThreads() { | 517 int BrowserMainLoop::PreCreateThreads() { |
516 | 518 |
517 if (parts_) { | 519 if (parts_) { |
518 TRACE_EVENT0("startup", | 520 TRACE_EVENT0("startup", |
519 "BrowserMainLoop::CreateThreads:PreCreateThreads"); | 521 "BrowserMainLoop::CreateThreads:PreCreateThreads"); |
520 result_code_ = parts_->PreCreateThreads(); | 522 result_code_ = parts_->PreCreateThreads(); |
521 } | 523 } |
522 | 524 |
523 #if defined(ENABLE_PLUGINS) | 525 #if defined(ENABLE_PLUGINS) |
524 // Prior to any processing happening on the io thread, we create the | 526 // Prior to any processing happening on the io thread, we create the |
525 // plugin service as it is predominantly used from the io thread, | 527 // plugin service as it is predominantly used from the io thread, |
526 // but must be created on the main thread. The service ctor is | 528 // but must be created on the main thread. The service ctor is |
527 // inexpensive and does not invoke the io_thread() accessor. | 529 // inexpensive and does not invoke the io_thread() accessor. |
528 { | 530 { |
529 TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads:PluginService") | 531 TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads:PluginService"); |
530 PluginService::GetInstance()->Init(); | 532 PluginService::GetInstance()->Init(); |
531 } | 533 } |
532 #endif | 534 #endif |
533 | 535 |
534 #if !defined(OS_IOS) && (!defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID)) | 536 #if !defined(OS_IOS) && (!defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID)) |
535 // Single-process is an unsupported and not fully tested mode, so | 537 // Single-process is an unsupported and not fully tested mode, so |
536 // don't enable it for official Chrome builds (except on Android). | 538 // don't enable it for official Chrome builds (except on Android). |
537 if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) | 539 if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) |
538 RenderProcessHost::SetRunRendererInProcess(true); | 540 RenderProcessHost::SetRunRendererInProcess(true); |
539 #endif | 541 #endif |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 MainMessageLoopRun(); | 707 MainMessageLoopRun(); |
706 | 708 |
707 TRACE_EVENT_END_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); | 709 TRACE_EVENT_END_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); |
708 } | 710 } |
709 | 711 |
710 void BrowserMainLoop::ShutdownThreadsAndCleanUp() { | 712 void BrowserMainLoop::ShutdownThreadsAndCleanUp() { |
711 if (!created_threads_) { | 713 if (!created_threads_) { |
712 // Called early, nothing to do | 714 // Called early, nothing to do |
713 return; | 715 return; |
714 } | 716 } |
715 TRACE_EVENT0("shutdown", "BrowserMainLoop::ShutdownThreadsAndCleanUp") | 717 TRACE_EVENT0("shutdown", "BrowserMainLoop::ShutdownThreadsAndCleanUp"); |
716 | 718 |
717 // Teardown may start in PostMainMessageLoopRun, and during teardown we | 719 // Teardown may start in PostMainMessageLoopRun, and during teardown we |
718 // need to be able to perform IO. | 720 // need to be able to perform IO. |
719 base::ThreadRestrictions::SetIOAllowed(true); | 721 base::ThreadRestrictions::SetIOAllowed(true); |
720 BrowserThread::PostTask( | 722 BrowserThread::PostTask( |
721 BrowserThread::IO, FROM_HERE, | 723 BrowserThread::IO, FROM_HERE, |
722 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), | 724 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), |
723 true)); | 725 true)); |
724 | 726 |
725 #if !defined(OS_IOS) | 727 #if !defined(OS_IOS) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 } | 888 } |
887 #endif // !defined(OS_IOS) | 889 #endif // !defined(OS_IOS) |
888 | 890 |
889 if (parts_) { | 891 if (parts_) { |
890 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); | 892 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); |
891 parts_->PostDestroyThreads(); | 893 parts_->PostDestroyThreads(); |
892 } | 894 } |
893 } | 895 } |
894 | 896 |
895 void BrowserMainLoop::InitializeMainThread() { | 897 void BrowserMainLoop::InitializeMainThread() { |
896 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeMainThread") | 898 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeMainThread"); |
897 const char* kThreadName = "CrBrowserMain"; | 899 const char* kThreadName = "CrBrowserMain"; |
898 base::PlatformThread::SetName(kThreadName); | 900 base::PlatformThread::SetName(kThreadName); |
899 if (main_message_loop_) | 901 if (main_message_loop_) |
900 main_message_loop_->set_thread_name(kThreadName); | 902 main_message_loop_->set_thread_name(kThreadName); |
901 | 903 |
902 // Register the main thread by instantiating it, but don't call any methods. | 904 // Register the main thread by instantiating it, but don't call any methods. |
903 main_thread_.reset( | 905 main_thread_.reset( |
904 new BrowserThreadImpl(BrowserThread::UI, base::MessageLoop::current())); | 906 new BrowserThreadImpl(BrowserThread::UI, base::MessageLoop::current())); |
905 } | 907 } |
906 | 908 |
907 int BrowserMainLoop::BrowserThreadsStarted() { | 909 int BrowserMainLoop::BrowserThreadsStarted() { |
908 TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted") | 910 TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted"); |
909 | 911 |
910 #if !defined(OS_IOS) | 912 #if !defined(OS_IOS) |
911 indexed_db_thread_.reset(new base::Thread("IndexedDB")); | 913 indexed_db_thread_.reset(new base::Thread("IndexedDB")); |
912 indexed_db_thread_->Start(); | 914 indexed_db_thread_->Start(); |
913 #endif | 915 #endif |
914 | 916 |
915 #if defined(OS_ANDROID) | 917 #if defined(OS_ANDROID) |
916 // Up the priority of anything that touches with display tasks | 918 // Up the priority of anything that touches with display tasks |
917 // (this thread is UI thread, and io_thread_ is for IPCs). | 919 // (this thread is UI thread, and io_thread_ is for IPCs). |
918 io_thread_->SetPriority(base::kThreadPriority_Display); | 920 io_thread_->SetPriority(base::kThreadPriority_Display); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 } | 987 } |
986 | 988 |
987 { | 989 { |
988 TRACE_EVENT0( | 990 TRACE_EVENT0( |
989 "startup", | 991 "startup", |
990 "BrowserMainLoop::BrowserThreadsStarted::InitUserInputMonitor"); | 992 "BrowserMainLoop::BrowserThreadsStarted::InitUserInputMonitor"); |
991 user_input_monitor_ = media::UserInputMonitor::Create( | 993 user_input_monitor_ = media::UserInputMonitor::Create( |
992 io_thread_->message_loop_proxy(), main_thread_->message_loop_proxy()); | 994 io_thread_->message_loop_proxy(), main_thread_->message_loop_proxy()); |
993 } | 995 } |
994 | 996 |
| 997 { |
| 998 TRACE_EVENT0("startup", |
| 999 "BrowserMainLoop::BrowserThreadsStarted::TimeZoneMonitor"); |
| 1000 time_zone_monitor_ = TimeZoneMonitor::Create(); |
| 1001 } |
| 1002 |
995 // Alert the clipboard class to which threads are allowed to access the | 1003 // Alert the clipboard class to which threads are allowed to access the |
996 // clipboard: | 1004 // clipboard: |
997 std::vector<base::PlatformThreadId> allowed_clipboard_threads; | 1005 std::vector<base::PlatformThreadId> allowed_clipboard_threads; |
998 // The current thread is the UI thread. | 1006 // The current thread is the UI thread. |
999 allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId()); | 1007 allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId()); |
1000 #if defined(OS_WIN) | 1008 #if defined(OS_WIN) |
1001 // On Windows, clipboards are also used on the File or IO threads. | 1009 // On Windows, clipboards are also used on the File or IO threads. |
1002 allowed_clipboard_threads.push_back(file_thread_->thread_id()); | 1010 allowed_clipboard_threads.push_back(file_thread_->thread_id()); |
1003 allowed_clipboard_threads.push_back(io_thread_->thread_id()); | 1011 allowed_clipboard_threads.push_back(io_thread_->thread_id()); |
1004 #endif | 1012 #endif |
(...skipping 18 matching lines...) Expand all Loading... |
1023 | 1031 |
1024 #if defined(OS_MACOSX) | 1032 #if defined(OS_MACOSX) |
1025 ThemeHelperMac::GetInstance(); | 1033 ThemeHelperMac::GetInstance(); |
1026 #endif | 1034 #endif |
1027 #endif // !defined(OS_IOS) | 1035 #endif // !defined(OS_IOS) |
1028 | 1036 |
1029 return result_code_; | 1037 return result_code_; |
1030 } | 1038 } |
1031 | 1039 |
1032 bool BrowserMainLoop::InitializeToolkit() { | 1040 bool BrowserMainLoop::InitializeToolkit() { |
1033 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit") | 1041 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit"); |
1034 // TODO(evan): this function is rather subtle, due to the variety | 1042 // TODO(evan): this function is rather subtle, due to the variety |
1035 // of intersecting ifdefs we have. To keep it easy to follow, there | 1043 // of intersecting ifdefs we have. To keep it easy to follow, there |
1036 // are no #else branches on any #ifs. | 1044 // are no #else branches on any #ifs. |
1037 // TODO(stevenjb): Move platform specific code into platform specific Parts | 1045 // TODO(stevenjb): Move platform specific code into platform specific Parts |
1038 // (Need to add InitializeToolkit stage to BrowserParts). | 1046 // (Need to add InitializeToolkit stage to BrowserParts). |
1039 // See also GTK setup in EarlyInitialization, above, and associated comments. | 1047 // See also GTK setup in EarlyInitialization, above, and associated comments. |
1040 | 1048 |
1041 #if defined(TOOLKIT_GTK) | 1049 #if defined(TOOLKIT_GTK) |
1042 // It is important for this to happen before the first run dialog, as it | 1050 // It is important for this to happen before the first run dialog, as it |
1043 // styles the dialog as well. | 1051 // styles the dialog as well. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 base::TimeDelta::FromSeconds(delay_secs)); | 1130 base::TimeDelta::FromSeconds(delay_secs)); |
1123 } | 1131 } |
1124 | 1132 |
1125 void BrowserMainLoop::EndStartupTracing(const base::FilePath& trace_file) { | 1133 void BrowserMainLoop::EndStartupTracing(const base::FilePath& trace_file) { |
1126 is_tracing_startup_ = false; | 1134 is_tracing_startup_ = false; |
1127 TracingController::GetInstance()->DisableRecording( | 1135 TracingController::GetInstance()->DisableRecording( |
1128 trace_file, base::Bind(&OnStoppedStartupTracing)); | 1136 trace_file, base::Bind(&OnStoppedStartupTracing)); |
1129 } | 1137 } |
1130 | 1138 |
1131 } // namespace content | 1139 } // namespace content |
OLD | NEW |