| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 #include "mojo/edk/embedder/embedder.h" | 80 #include "mojo/edk/embedder/embedder.h" |
| 81 #include "mojo/shell/public/cpp/shell.h" | 81 #include "mojo/shell/public/cpp/shell.h" |
| 82 #include "net/base/network_change_notifier.h" | 82 #include "net/base/network_change_notifier.h" |
| 83 #include "net/socket/client_socket_factory.h" | 83 #include "net/socket/client_socket_factory.h" |
| 84 #include "net/ssl/ssl_config_service.h" | 84 #include "net/ssl/ssl_config_service.h" |
| 85 #include "skia/ext/event_tracer_impl.h" | 85 #include "skia/ext/event_tracer_impl.h" |
| 86 #include "skia/ext/skia_memory_dump_provider.h" | 86 #include "skia/ext/skia_memory_dump_provider.h" |
| 87 #include "sql/sql_memory_dump_provider.h" | 87 #include "sql/sql_memory_dump_provider.h" |
| 88 #include "ui/base/clipboard/clipboard.h" | 88 #include "ui/base/clipboard/clipboard.h" |
| 89 | 89 |
| 90 #if defined(USE_AURA) || (defined(OS_MACOSX) && !defined(OS_IOS)) | 90 #if defined(USE_AURA) || defined(OS_MACOSX) |
| 91 #include "content/browser/compositor/image_transport_factory.h" | 91 #include "content/browser/compositor/image_transport_factory.h" |
| 92 #endif | 92 #endif |
| 93 | 93 |
| 94 #if defined(USE_AURA) | 94 #if defined(USE_AURA) |
| 95 #include "content/public/browser/context_factory.h" | 95 #include "content/public/browser/context_factory.h" |
| 96 #include "ui/aura/env.h" | 96 #include "ui/aura/env.h" |
| 97 #endif | 97 #endif |
| 98 | 98 |
| 99 #if !defined(OS_IOS) | |
| 100 #include "content/browser/renderer_host/render_process_host_impl.h" | |
| 101 #endif | |
| 102 | |
| 103 #if defined(OS_ANDROID) | 99 #if defined(OS_ANDROID) |
| 104 #include "base/android/jni_android.h" | 100 #include "base/android/jni_android.h" |
| 105 #include "components/tracing/graphics_memory_dump_provider_android.h" | 101 #include "components/tracing/graphics_memory_dump_provider_android.h" |
| 106 #include "content/browser/android/browser_startup_controller.h" | 102 #include "content/browser/android/browser_startup_controller.h" |
| 107 #include "content/browser/android/browser_surface_texture_manager.h" | 103 #include "content/browser/android/browser_surface_texture_manager.h" |
| 108 #include "content/browser/android/in_process_surface_texture_manager.h" | 104 #include "content/browser/android/in_process_surface_texture_manager.h" |
| 109 #include "content/browser/android/tracing_controller_android.h" | 105 #include "content/browser/android/tracing_controller_android.h" |
| 110 #include "content/browser/screen_orientation/screen_orientation_delegate_android
.h" | 106 #include "content/browser/screen_orientation/screen_orientation_delegate_android
.h" |
| 111 #include "content/public/browser/screen_orientation_provider.h" | 107 #include "content/public/browser/screen_orientation_provider.h" |
| 112 #include "ui/gl/gl_surface.h" | 108 #include "ui/gl/gl_surface.h" |
| 113 #endif | 109 #endif |
| 114 | 110 |
| 115 #if defined(OS_MACOSX) && !defined(OS_IOS) | 111 #if defined(OS_MACOSX) |
| 116 #include "base/memory/memory_pressure_monitor_mac.h" | 112 #include "base/memory/memory_pressure_monitor_mac.h" |
| 117 #include "content/browser/bootstrap_sandbox_manager_mac.h" | 113 #include "content/browser/bootstrap_sandbox_manager_mac.h" |
| 118 #include "content/browser/cocoa/system_hotkey_helper_mac.h" | 114 #include "content/browser/cocoa/system_hotkey_helper_mac.h" |
| 119 #include "content/browser/compositor/browser_compositor_view_mac.h" | 115 #include "content/browser/compositor/browser_compositor_view_mac.h" |
| 120 #include "content/browser/mach_broker_mac.h" | 116 #include "content/browser/mach_broker_mac.h" |
| 121 #include "content/browser/theme_helper_mac.h" | 117 #include "content/browser/theme_helper_mac.h" |
| 122 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" | 118 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" |
| 123 #endif | 119 #endif |
| 124 | 120 |
| 125 #if defined(USE_OZONE) | 121 #if defined(USE_OZONE) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 146 #endif | 142 #endif |
| 147 | 143 |
| 148 #if defined(USE_GLIB) | 144 #if defined(USE_GLIB) |
| 149 #include <glib-object.h> | 145 #include <glib-object.h> |
| 150 #endif | 146 #endif |
| 151 | 147 |
| 152 #if defined(OS_WIN) | 148 #if defined(OS_WIN) |
| 153 #include "media/capture/system_message_window_win.h" | 149 #include "media/capture/system_message_window_win.h" |
| 154 #elif defined(OS_LINUX) && defined(USE_UDEV) | 150 #elif defined(OS_LINUX) && defined(USE_UDEV) |
| 155 #include "media/capture/device_monitor_udev.h" | 151 #include "media/capture/device_monitor_udev.h" |
| 156 #elif defined(OS_MACOSX) && !defined(OS_IOS) | 152 #elif defined(OS_MACOSX) |
| 157 #include "media/capture/device_monitor_mac.h" | 153 #include "media/capture/device_monitor_mac.h" |
| 158 #endif | 154 #endif |
| 159 | 155 |
| 160 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 156 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 161 #include "content/browser/renderer_host/render_sandbox_host_linux.h" | 157 #include "content/browser/renderer_host/render_sandbox_host_linux.h" |
| 162 #include "content/browser/zygote_host/zygote_host_impl_linux.h" | 158 #include "content/browser/zygote_host/zygote_host_impl_linux.h" |
| 163 #include "sandbox/linux/suid/client/setuid_sandbox_host.h" | 159 #include "sandbox/linux/suid/client/setuid_sandbox_host.h" |
| 164 | 160 |
| 165 #if !defined(OS_ANDROID) | 161 #if !defined(OS_ANDROID) |
| 166 #include "content/public/browser/zygote_handle_linux.h" | 162 #include "content/public/browser/zygote_handle_linux.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 330 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 335 thread.reset(); | 331 thread.reset(); |
| 336 } | 332 } |
| 337 | 333 |
| 338 NOINLINE void ResetThread_IO(scoped_ptr<BrowserProcessSubThread> thread) { | 334 NOINLINE void ResetThread_IO(scoped_ptr<BrowserProcessSubThread> thread) { |
| 339 volatile int inhibit_comdat = __LINE__; | 335 volatile int inhibit_comdat = __LINE__; |
| 340 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 336 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 341 thread.reset(); | 337 thread.reset(); |
| 342 } | 338 } |
| 343 | 339 |
| 344 #if !defined(OS_IOS) | |
| 345 NOINLINE void ResetThread_IndexedDb(scoped_ptr<base::Thread> thread) { | 340 NOINLINE void ResetThread_IndexedDb(scoped_ptr<base::Thread> thread) { |
| 346 volatile int inhibit_comdat = __LINE__; | 341 volatile int inhibit_comdat = __LINE__; |
| 347 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 342 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 348 thread.reset(); | 343 thread.reset(); |
| 349 } | 344 } |
| 350 #endif | |
| 351 | 345 |
| 352 MSVC_POP_WARNING() | 346 MSVC_POP_WARNING() |
| 353 MSVC_ENABLE_OPTIMIZE(); | 347 MSVC_ENABLE_OPTIMIZE(); |
| 354 | 348 |
| 355 #if defined(OS_WIN) | 349 #if defined(OS_WIN) |
| 356 // Creates a memory pressure monitor using automatic thresholds, or those | 350 // Creates a memory pressure monitor using automatic thresholds, or those |
| 357 // specified on the command-line. Ownership is passed to the caller. | 351 // specified on the command-line. Ownership is passed to the caller. |
| 358 base::win::MemoryPressureMonitor* CreateWinMemoryPressureMonitor( | 352 base::win::MemoryPressureMonitor* CreateWinMemoryPressureMonitor( |
| 359 const base::CommandLine& parsed_command_line) { | 353 const base::CommandLine& parsed_command_line) { |
| 360 std::vector<std::string> thresholds = base::SplitString( | 354 std::vector<std::string> thresholds = base::SplitString( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 385 | 379 |
| 386 // For measuring memory usage after each task. Behind a command line flag. | 380 // For measuring memory usage after each task. Behind a command line flag. |
| 387 class BrowserMainLoop::MemoryObserver : public base::MessageLoop::TaskObserver { | 381 class BrowserMainLoop::MemoryObserver : public base::MessageLoop::TaskObserver { |
| 388 public: | 382 public: |
| 389 MemoryObserver() {} | 383 MemoryObserver() {} |
| 390 ~MemoryObserver() override {} | 384 ~MemoryObserver() override {} |
| 391 | 385 |
| 392 void WillProcessTask(const base::PendingTask& pending_task) override {} | 386 void WillProcessTask(const base::PendingTask& pending_task) override {} |
| 393 | 387 |
| 394 void DidProcessTask(const base::PendingTask& pending_task) override { | 388 void DidProcessTask(const base::PendingTask& pending_task) override { |
| 395 #if !defined(OS_IOS) // No ProcessMetrics on IOS. | |
| 396 scoped_ptr<base::ProcessMetrics> process_metrics( | 389 scoped_ptr<base::ProcessMetrics> process_metrics( |
| 397 base::ProcessMetrics::CreateCurrentProcessMetrics()); | 390 base::ProcessMetrics::CreateCurrentProcessMetrics()); |
| 398 size_t private_bytes; | 391 size_t private_bytes; |
| 399 process_metrics->GetMemoryBytes(&private_bytes, NULL); | 392 process_metrics->GetMemoryBytes(&private_bytes, NULL); |
| 400 LOCAL_HISTOGRAM_MEMORY_KB("Memory.BrowserUsed", private_bytes >> 10); | 393 LOCAL_HISTOGRAM_MEMORY_KB("Memory.BrowserUsed", private_bytes >> 10); |
| 401 #endif | |
| 402 } | 394 } |
| 403 private: | 395 private: |
| 404 DISALLOW_COPY_AND_ASSIGN(MemoryObserver); | 396 DISALLOW_COPY_AND_ASSIGN(MemoryObserver); |
| 405 }; | 397 }; |
| 406 | 398 |
| 407 | 399 |
| 408 // BrowserMainLoop construction / destruction ============================= | 400 // BrowserMainLoop construction / destruction ============================= |
| 409 | 401 |
| 410 BrowserMainLoop* BrowserMainLoop::GetInstance() { | 402 BrowserMainLoop* BrowserMainLoop::GetInstance() { |
| 411 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 403 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 422 is_tracing_startup_for_duration_( | 414 is_tracing_startup_for_duration_( |
| 423 parameters.command_line.HasSwitch(switches::kTraceStartup) || | 415 parameters.command_line.HasSwitch(switches::kTraceStartup) || |
| 424 (tracing::TraceConfigFile::GetInstance()->IsEnabled() && | 416 (tracing::TraceConfigFile::GetInstance()->IsEnabled() && |
| 425 tracing::TraceConfigFile::GetInstance()->GetStartupDuration() > 0)) { | 417 tracing::TraceConfigFile::GetInstance()->GetStartupDuration() > 0)) { |
| 426 DCHECK(!g_current_browser_main_loop); | 418 DCHECK(!g_current_browser_main_loop); |
| 427 g_current_browser_main_loop = this; | 419 g_current_browser_main_loop = this; |
| 428 } | 420 } |
| 429 | 421 |
| 430 BrowserMainLoop::~BrowserMainLoop() { | 422 BrowserMainLoop::~BrowserMainLoop() { |
| 431 DCHECK_EQ(this, g_current_browser_main_loop); | 423 DCHECK_EQ(this, g_current_browser_main_loop); |
| 432 #if !defined(OS_IOS) | |
| 433 ui::Clipboard::DestroyClipboardForCurrentThread(); | 424 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 434 #endif // !defined(OS_IOS) | |
| 435 g_current_browser_main_loop = NULL; | 425 g_current_browser_main_loop = NULL; |
| 436 } | 426 } |
| 437 | 427 |
| 438 void BrowserMainLoop::Init() { | 428 void BrowserMainLoop::Init() { |
| 439 TRACE_EVENT0("startup", "BrowserMainLoop::Init"); | 429 TRACE_EVENT0("startup", "BrowserMainLoop::Init"); |
| 440 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::Init"); | 430 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::Init"); |
| 441 | 431 |
| 442 parts_.reset( | 432 parts_.reset( |
| 443 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); | 433 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); |
| 444 } | 434 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 | 489 |
| 500 #if defined(OS_WIN) | 490 #if defined(OS_WIN) |
| 501 net::EnsureWinsockInit(); | 491 net::EnsureWinsockInit(); |
| 502 #endif | 492 #endif |
| 503 | 493 |
| 504 #if defined(USE_NSS_CERTS) || !defined(USE_OPENSSL) | 494 #if defined(USE_NSS_CERTS) || !defined(USE_OPENSSL) |
| 505 // We want to be sure to init NSPR on the main thread. | 495 // We want to be sure to init NSPR on the main thread. |
| 506 crypto::EnsureNSPRInit(); | 496 crypto::EnsureNSPRInit(); |
| 507 #endif | 497 #endif |
| 508 | 498 |
| 509 #if !defined(OS_IOS) | |
| 510 if (parsed_command_line_.HasSwitch(switches::kRendererProcessLimit)) { | 499 if (parsed_command_line_.HasSwitch(switches::kRendererProcessLimit)) { |
| 511 std::string limit_string = parsed_command_line_.GetSwitchValueASCII( | 500 std::string limit_string = parsed_command_line_.GetSwitchValueASCII( |
| 512 switches::kRendererProcessLimit); | 501 switches::kRendererProcessLimit); |
| 513 size_t process_limit; | 502 size_t process_limit; |
| 514 if (base::StringToSizeT(limit_string, &process_limit)) { | 503 if (base::StringToSizeT(limit_string, &process_limit)) { |
| 515 RenderProcessHost::SetMaxRendererProcessCount(process_limit); | 504 RenderProcessHost::SetMaxRendererProcessCount(process_limit); |
| 516 } | 505 } |
| 517 } | 506 } |
| 518 #endif // !defined(OS_IOS) | |
| 519 | 507 |
| 520 if (parts_) | 508 if (parts_) |
| 521 parts_->PostEarlyInitialization(); | 509 parts_->PostEarlyInitialization(); |
| 522 } | 510 } |
| 523 | 511 |
| 524 void BrowserMainLoop::PreMainMessageLoopStart() { | 512 void BrowserMainLoop::PreMainMessageLoopStart() { |
| 525 if (parts_) { | 513 if (parts_) { |
| 526 TRACE_EVENT0("startup", | 514 TRACE_EVENT0("startup", |
| 527 "BrowserMainLoop::MainMessageLoopStart:PreMainMessageLoopStart"); | 515 "BrowserMainLoop::MainMessageLoopStart:PreMainMessageLoopStart"); |
| 528 parts_->PreMainMessageLoopStart(); | 516 parts_->PreMainMessageLoopStart(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 new base::PowerMonitor(std::move(power_monitor_source))); | 553 new base::PowerMonitor(std::move(power_monitor_source))); |
| 566 } | 554 } |
| 567 { | 555 { |
| 568 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:HighResTimerManager"); | 556 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:HighResTimerManager"); |
| 569 hi_res_timer_manager_.reset(new base::HighResolutionTimerManager); | 557 hi_res_timer_manager_.reset(new base::HighResolutionTimerManager); |
| 570 } | 558 } |
| 571 { | 559 { |
| 572 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:NetworkChangeNotifier"); | 560 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:NetworkChangeNotifier"); |
| 573 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 561 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
| 574 } | 562 } |
| 575 | |
| 576 #if !defined(OS_IOS) | |
| 577 { | 563 { |
| 578 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MediaFeatures"); | 564 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MediaFeatures"); |
| 579 media::InitializeMediaLibrary(); | 565 media::InitializeMediaLibrary(); |
| 580 } | 566 } |
| 581 { | 567 { |
| 582 TRACE_EVENT0("startup", | 568 TRACE_EVENT0("startup", |
| 583 "BrowserMainLoop::Subsystem:ContentWebUIController"); | 569 "BrowserMainLoop::Subsystem:ContentWebUIController"); |
| 584 WebUIControllerFactory::RegisterFactory( | 570 WebUIControllerFactory::RegisterFactory( |
| 585 ContentWebUIControllerFactory::GetInstance()); | 571 ContentWebUIControllerFactory::GetInstance()); |
| 586 } | 572 } |
| 587 | 573 |
| 588 { | 574 { |
| 589 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:OnlineStateObserver"); | 575 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:OnlineStateObserver"); |
| 590 online_state_observer_.reset(new BrowserOnlineStateObserver); | 576 online_state_observer_.reset(new BrowserOnlineStateObserver); |
| 591 } | 577 } |
| 592 | 578 |
| 593 { | 579 { |
| 594 system_stats_monitor_.reset( | 580 system_stats_monitor_.reset( |
| 595 new base::trace_event::TraceEventSystemStatsMonitor( | 581 new base::trace_event::TraceEventSystemStatsMonitor( |
| 596 base::ThreadTaskRunnerHandle::Get())); | 582 base::ThreadTaskRunnerHandle::Get())); |
| 597 } | 583 } |
| 598 #endif // !defined(OS_IOS) | |
| 599 | 584 |
| 600 #if defined(OS_WIN) | 585 #if defined(OS_WIN) |
| 601 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | 586 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
| 602 screen_orientation_delegate_.reset(new ScreenOrientationDelegateWin()); | 587 screen_orientation_delegate_.reset(new ScreenOrientationDelegateWin()); |
| 603 #endif | 588 #endif |
| 604 | 589 |
| 605 // TODO(boliu): kSingleProcess check is a temporary workaround for | 590 // TODO(boliu): kSingleProcess check is a temporary workaround for |
| 606 // in-process Android WebView. crbug.com/503724 tracks proper fix. | 591 // in-process Android WebView. crbug.com/503724 tracks proper fix. |
| 607 if (!parsed_command_line_.HasSwitch(switches::kSingleProcess)) { | 592 if (!parsed_command_line_.HasSwitch(switches::kSingleProcess)) { |
| 608 base::DiscardableMemoryAllocator::SetInstance( | 593 base::DiscardableMemoryAllocator::SetInstance( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 625 } else if (parsed_command_line_.HasSwitch(switches::kTraceToConsole)) { | 610 } else if (parsed_command_line_.HasSwitch(switches::kTraceToConsole)) { |
| 626 TracingController::GetInstance()->StartTracing( | 611 TracingController::GetInstance()->StartTracing( |
| 627 tracing::GetConfigForTraceToConsole(), | 612 tracing::GetConfigForTraceToConsole(), |
| 628 TracingController::StartTracingDoneCallback()); | 613 TracingController::StartTracingDoneCallback()); |
| 629 } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) { | 614 } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) { |
| 630 // This checks kTraceConfigFile switch. | 615 // This checks kTraceConfigFile switch. |
| 631 TracingController::GetInstance()->StartTracing( | 616 TracingController::GetInstance()->StartTracing( |
| 632 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), | 617 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), |
| 633 TracingController::StartTracingDoneCallback()); | 618 TracingController::StartTracingDoneCallback()); |
| 634 } | 619 } |
| 635 #if !defined(OS_IOS) | |
| 636 // Start tracing to a file for certain duration if needed. Only do this after | 620 // Start tracing to a file for certain duration if needed. Only do this after |
| 637 // starting the main message loop to avoid calling | 621 // starting the main message loop to avoid calling |
| 638 // MessagePumpForUI::ScheduleWork() before MessagePumpForUI::Start() as it | 622 // MessagePumpForUI::ScheduleWork() before MessagePumpForUI::Start() as it |
| 639 // will crash the browser. | 623 // will crash the browser. |
| 640 if (is_tracing_startup_for_duration_) { | 624 if (is_tracing_startup_for_duration_) { |
| 641 TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracingForDuration"); | 625 TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracingForDuration"); |
| 642 InitStartupTracingForDuration(parsed_command_line_); | 626 InitStartupTracingForDuration(parsed_command_line_); |
| 643 } | 627 } |
| 644 #endif // !defined(OS_IOS) | |
| 645 | 628 |
| 646 #if defined(OS_ANDROID) | 629 #if defined(OS_ANDROID) |
| 647 { | 630 { |
| 648 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SurfaceTextureManager"); | 631 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SurfaceTextureManager"); |
| 649 if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) { | 632 if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) { |
| 650 gpu::SurfaceTextureManager::SetInstance( | 633 gpu::SurfaceTextureManager::SetInstance( |
| 651 InProcessSurfaceTextureManager::GetInstance()); | 634 InProcessSurfaceTextureManager::GetInstance()); |
| 652 } else { | 635 } else { |
| 653 gpu::SurfaceTextureManager::SetInstance( | 636 gpu::SurfaceTextureManager::SetInstance( |
| 654 BrowserSurfaceTextureManager::GetInstance()); | 637 BrowserSurfaceTextureManager::GetInstance()); |
| 655 } | 638 } |
| 656 } | 639 } |
| 657 | 640 |
| 658 if (!parsed_command_line_.HasSwitch( | 641 if (!parsed_command_line_.HasSwitch( |
| 659 switches::kDisableScreenOrientationLock)) { | 642 switches::kDisableScreenOrientationLock)) { |
| 660 TRACE_EVENT0("startup", | 643 TRACE_EVENT0("startup", |
| 661 "BrowserMainLoop::Subsystem:ScreenOrientationProvider"); | 644 "BrowserMainLoop::Subsystem:ScreenOrientationProvider"); |
| 662 screen_orientation_delegate_.reset( | 645 screen_orientation_delegate_.reset( |
| 663 new ScreenOrientationDelegateAndroid()); | 646 new ScreenOrientationDelegateAndroid()); |
| 664 ScreenOrientationProvider::SetDelegate(screen_orientation_delegate_.get()); | 647 ScreenOrientationProvider::SetDelegate(screen_orientation_delegate_.get()); |
| 665 } | 648 } |
| 666 #endif | 649 #endif |
| 667 | 650 |
| 668 #if defined(OS_MACOSX) && !defined(OS_IOS) | 651 #if defined(OS_MACOSX) |
| 669 if (BootstrapSandboxManager::ShouldEnable()) { | 652 if (BootstrapSandboxManager::ShouldEnable()) { |
| 670 TRACE_EVENT0("startup", | 653 TRACE_EVENT0("startup", |
| 671 "BrowserMainLoop::Subsystem:BootstrapSandbox"); | 654 "BrowserMainLoop::Subsystem:BootstrapSandbox"); |
| 672 CHECK(BootstrapSandboxManager::GetInstance()); | 655 CHECK(BootstrapSandboxManager::GetInstance()); |
| 673 } | 656 } |
| 674 #endif | 657 #endif |
| 675 | 658 |
| 676 #if defined(USE_OZONE) | 659 #if defined(USE_OZONE) |
| 677 client_native_pixmap_factory_ = ui::ClientNativePixmapFactory::Create(); | 660 client_native_pixmap_factory_ = ui::ClientNativePixmapFactory::Create(); |
| 678 ui::ClientNativePixmapFactory::SetInstance( | 661 ui::ClientNativePixmapFactory::SetInstance( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 // was already set up by the embedder. | 702 // was already set up by the embedder. |
| 720 base::FeatureList::InitializeInstance(); | 703 base::FeatureList::InitializeInstance(); |
| 721 | 704 |
| 722 // TODO(chrisha): Abstract away this construction mess to a helper function, | 705 // TODO(chrisha): Abstract away this construction mess to a helper function, |
| 723 // once MemoryPressureMonitor is made a concrete class. | 706 // once MemoryPressureMonitor is made a concrete class. |
| 724 #if defined(OS_CHROMEOS) | 707 #if defined(OS_CHROMEOS) |
| 725 if (chromeos::switches::MemoryPressureHandlingEnabled()) { | 708 if (chromeos::switches::MemoryPressureHandlingEnabled()) { |
| 726 memory_pressure_monitor_.reset(new base::chromeos::MemoryPressureMonitor( | 709 memory_pressure_monitor_.reset(new base::chromeos::MemoryPressureMonitor( |
| 727 chromeos::switches::GetMemoryPressureThresholds())); | 710 chromeos::switches::GetMemoryPressureThresholds())); |
| 728 } | 711 } |
| 729 #elif defined(OS_MACOSX) && !defined(OS_IOS) | 712 #elif defined(OS_MACOSX) |
| 730 memory_pressure_monitor_.reset(new base::mac::MemoryPressureMonitor()); | 713 memory_pressure_monitor_.reset(new base::mac::MemoryPressureMonitor()); |
| 731 #elif defined(OS_WIN) | 714 #elif defined(OS_WIN) |
| 732 memory_pressure_monitor_.reset(CreateWinMemoryPressureMonitor( | 715 memory_pressure_monitor_.reset(CreateWinMemoryPressureMonitor( |
| 733 parsed_command_line_)); | 716 parsed_command_line_)); |
| 734 #endif | 717 #endif |
| 735 | 718 |
| 736 #if defined(ENABLE_PLUGINS) | 719 #if defined(ENABLE_PLUGINS) |
| 737 // Prior to any processing happening on the IO thread, we create the | 720 // Prior to any processing happening on the IO thread, we create the |
| 738 // plugin service as it is predominantly used from the IO thread, | 721 // plugin service as it is predominantly used from the IO thread, |
| 739 // but must be created on the main thread. The service ctor is | 722 // but must be created on the main thread. The service ctor is |
| 740 // inexpensive and does not invoke the io_thread() accessor. | 723 // inexpensive and does not invoke the io_thread() accessor. |
| 741 { | 724 { |
| 742 TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads:PluginService"); | 725 TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads:PluginService"); |
| 743 PluginService::GetInstance()->Init(); | 726 PluginService::GetInstance()->Init(); |
| 744 } | 727 } |
| 745 #endif | 728 #endif |
| 746 | 729 |
| 747 #if defined(OS_MACOSX) && !defined(OS_IOS) | 730 #if defined(OS_MACOSX) |
| 748 // The WindowResizeHelper allows the UI thread to wait on specific renderer | 731 // The WindowResizeHelper allows the UI thread to wait on specific renderer |
| 749 // and GPU messages from the IO thread. Initializing it before the IO thread | 732 // and GPU messages from the IO thread. Initializing it before the IO thread |
| 750 // starts ensures the affected IO thread messages always have somewhere to go. | 733 // starts ensures the affected IO thread messages always have somewhere to go. |
| 751 ui::WindowResizeHelperMac::Get()->Init(base::ThreadTaskRunnerHandle::Get()); | 734 ui::WindowResizeHelperMac::Get()->Init(base::ThreadTaskRunnerHandle::Get()); |
| 752 #endif | 735 #endif |
| 753 | 736 |
| 754 // 1) Need to initialize in-process GpuDataManager before creating threads. | 737 // 1) Need to initialize in-process GpuDataManager before creating threads. |
| 755 // It's unsafe to append the gpu command line switches to the global | 738 // It's unsafe to append the gpu command line switches to the global |
| 756 // CommandLine::ForCurrentProcess object after threads are created. | 739 // CommandLine::ForCurrentProcess object after threads are created. |
| 757 // 2) Must be after parts_->PreCreateThreads to pick up chrome://flags. | 740 // 2) Must be after parts_->PreCreateThreads to pick up chrome://flags. |
| 758 GpuDataManagerImpl::GetInstance()->Initialize(); | 741 GpuDataManagerImpl::GetInstance()->Initialize(); |
| 759 | 742 |
| 760 #if !defined(OS_IOS) && (!defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID)) | 743 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID) |
| 761 // Single-process is an unsupported and not fully tested mode, so | 744 // Single-process is an unsupported and not fully tested mode, so |
| 762 // don't enable it for official Chrome builds (except on Android). | 745 // don't enable it for official Chrome builds (except on Android). |
| 763 if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) | 746 if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) |
| 764 RenderProcessHost::SetRunRendererInProcess(true); | 747 RenderProcessHost::SetRunRendererInProcess(true); |
| 765 #endif | 748 #endif |
| 766 | 749 |
| 767 return result_code_; | 750 return result_code_; |
| 768 } | 751 } |
| 769 | 752 |
| 770 void BrowserMainLoop::CreateStartupTasks() { | 753 void BrowserMainLoop::CreateStartupTasks() { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 // need to be able to perform IO. | 960 // need to be able to perform IO. |
| 978 base::ThreadRestrictions::SetIOAllowed(true); | 961 base::ThreadRestrictions::SetIOAllowed(true); |
| 979 BrowserThread::PostTask( | 962 BrowserThread::PostTask( |
| 980 BrowserThread::IO, FROM_HERE, | 963 BrowserThread::IO, FROM_HERE, |
| 981 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), | 964 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), |
| 982 true)); | 965 true)); |
| 983 | 966 |
| 984 if (IsRunningInMojoShell()) | 967 if (IsRunningInMojoShell()) |
| 985 MojoShellConnection::Destroy(); | 968 MojoShellConnection::Destroy(); |
| 986 | 969 |
| 987 #if !defined(OS_IOS) | |
| 988 if (RenderProcessHost::run_renderer_in_process()) | 970 if (RenderProcessHost::run_renderer_in_process()) |
| 989 RenderProcessHostImpl::ShutDownInProcessRenderer(); | 971 RenderProcessHostImpl::ShutDownInProcessRenderer(); |
| 990 #endif | |
| 991 | 972 |
| 992 if (parts_) { | 973 if (parts_) { |
| 993 TRACE_EVENT0("shutdown", | 974 TRACE_EVENT0("shutdown", |
| 994 "BrowserMainLoop::Subsystem:PostMainMessageLoopRun"); | 975 "BrowserMainLoop::Subsystem:PostMainMessageLoopRun"); |
| 995 parts_->PostMainMessageLoopRun(); | 976 parts_->PostMainMessageLoopRun(); |
| 996 } | 977 } |
| 997 | 978 |
| 998 #if defined(USE_AURA) | 979 #if defined(USE_AURA) |
| 999 aura::Env::DeleteInstance(); | 980 aura::Env::DeleteInstance(); |
| 1000 #endif | 981 #endif |
| 1001 | 982 |
| 1002 system_stats_monitor_.reset(); | 983 system_stats_monitor_.reset(); |
| 1003 | 984 |
| 1004 #if !defined(OS_IOS) | |
| 1005 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to | 985 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to |
| 1006 // delete related objects on the GPU thread. This must be done before | 986 // delete related objects on the GPU thread. This must be done before |
| 1007 // stopping the GPU thread. The GPU thread will close IPC channels to renderer | 987 // stopping the GPU thread. The GPU thread will close IPC channels to renderer |
| 1008 // processes so this has to happen before stopping the IO thread. | 988 // processes so this has to happen before stopping the IO thread. |
| 1009 { | 989 { |
| 1010 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUProcessHostShim"); | 990 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUProcessHostShim"); |
| 1011 GpuProcessHostUIShim::DestroyAll(); | 991 GpuProcessHostUIShim::DestroyAll(); |
| 1012 } | 992 } |
| 1013 // Cancel pending requests and prevent new requests. | 993 // Cancel pending requests and prevent new requests. |
| 1014 if (resource_dispatcher_host_) { | 994 if (resource_dispatcher_host_) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1039 // The device monitors are using |system_monitor_| as dependency, so delete | 1019 // The device monitors are using |system_monitor_| as dependency, so delete |
| 1040 // them before |system_monitor_| goes away. | 1020 // them before |system_monitor_| goes away. |
| 1041 // On Mac and windows, the monitor needs to be destroyed on the same thread | 1021 // On Mac and windows, the monitor needs to be destroyed on the same thread |
| 1042 // as they were created. On Linux, the monitor will be deleted when IO thread | 1022 // as they were created. On Linux, the monitor will be deleted when IO thread |
| 1043 // goes away. | 1023 // goes away. |
| 1044 #if defined(OS_WIN) | 1024 #if defined(OS_WIN) |
| 1045 system_message_window_.reset(); | 1025 system_message_window_.reset(); |
| 1046 #elif defined(OS_MACOSX) | 1026 #elif defined(OS_MACOSX) |
| 1047 device_monitor_mac_.reset(); | 1027 device_monitor_mac_.reset(); |
| 1048 #endif | 1028 #endif |
| 1049 #endif // !defined(OS_IOS) | |
| 1050 | 1029 |
| 1051 // Shutdown Mojo shell and IPC. | 1030 // Shutdown Mojo shell and IPC. |
| 1052 #if !defined(OS_IOS) | |
| 1053 mojo_shell_context_.reset(); | 1031 mojo_shell_context_.reset(); |
| 1054 mojo_ipc_support_.reset(); | 1032 mojo_ipc_support_.reset(); |
| 1055 #endif | |
| 1056 | 1033 |
| 1057 // Must be size_t so we can subtract from it. | 1034 // Must be size_t so we can subtract from it. |
| 1058 for (size_t thread_id = BrowserThread::ID_COUNT - 1; | 1035 for (size_t thread_id = BrowserThread::ID_COUNT - 1; |
| 1059 thread_id >= (BrowserThread::UI + 1); | 1036 thread_id >= (BrowserThread::UI + 1); |
| 1060 --thread_id) { | 1037 --thread_id) { |
| 1061 // Find the thread object we want to stop. Looping over all valid | 1038 // Find the thread object we want to stop. Looping over all valid |
| 1062 // BrowserThread IDs and DCHECKing on a missing case in the switch | 1039 // BrowserThread IDs and DCHECKing on a missing case in the switch |
| 1063 // statement helps avoid a mismatch between this code and the | 1040 // statement helps avoid a mismatch between this code and the |
| 1064 // BrowserThread::ID enumeration. | 1041 // BrowserThread::ID enumeration. |
| 1065 // | 1042 // |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1076 // | 1053 // |
| 1077 // - (Not sure why DB stops last.) | 1054 // - (Not sure why DB stops last.) |
| 1078 switch (thread_id) { | 1055 switch (thread_id) { |
| 1079 case BrowserThread::DB: { | 1056 case BrowserThread::DB: { |
| 1080 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DBThread"); | 1057 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DBThread"); |
| 1081 ResetThread_DB(std::move(db_thread_)); | 1058 ResetThread_DB(std::move(db_thread_)); |
| 1082 break; | 1059 break; |
| 1083 } | 1060 } |
| 1084 case BrowserThread::FILE: { | 1061 case BrowserThread::FILE: { |
| 1085 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:FileThread"); | 1062 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:FileThread"); |
| 1086 #if !defined(OS_IOS) | |
| 1087 // Clean up state that lives on or uses the file_thread_ before | 1063 // Clean up state that lives on or uses the file_thread_ before |
| 1088 // it goes away. | 1064 // it goes away. |
| 1089 if (resource_dispatcher_host_) | 1065 if (resource_dispatcher_host_) |
| 1090 resource_dispatcher_host_.get()->save_file_manager()->Shutdown(); | 1066 resource_dispatcher_host_.get()->save_file_manager()->Shutdown(); |
| 1091 #endif // !defined(OS_IOS) | |
| 1092 ResetThread_FILE(std::move(file_thread_)); | 1067 ResetThread_FILE(std::move(file_thread_)); |
| 1093 break; | 1068 break; |
| 1094 } | 1069 } |
| 1095 case BrowserThread::FILE_USER_BLOCKING: { | 1070 case BrowserThread::FILE_USER_BLOCKING: { |
| 1096 TRACE_EVENT0("shutdown", | 1071 TRACE_EVENT0("shutdown", |
| 1097 "BrowserMainLoop::Subsystem:FileUserBlockingThread"); | 1072 "BrowserMainLoop::Subsystem:FileUserBlockingThread"); |
| 1098 ResetThread_FILE_USER_BLOCKING(std::move(file_user_blocking_thread_)); | 1073 ResetThread_FILE_USER_BLOCKING(std::move(file_user_blocking_thread_)); |
| 1099 break; | 1074 break; |
| 1100 } | 1075 } |
| 1101 case BrowserThread::PROCESS_LAUNCHER: { | 1076 case BrowserThread::PROCESS_LAUNCHER: { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1113 ResetThread_IO(std::move(io_thread_)); | 1088 ResetThread_IO(std::move(io_thread_)); |
| 1114 break; | 1089 break; |
| 1115 } | 1090 } |
| 1116 case BrowserThread::UI: | 1091 case BrowserThread::UI: |
| 1117 case BrowserThread::ID_COUNT: | 1092 case BrowserThread::ID_COUNT: |
| 1118 default: | 1093 default: |
| 1119 NOTREACHED(); | 1094 NOTREACHED(); |
| 1120 break; | 1095 break; |
| 1121 } | 1096 } |
| 1122 } | 1097 } |
| 1123 | |
| 1124 #if !defined(OS_IOS) | |
| 1125 { | 1098 { |
| 1126 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IndexedDBThread"); | 1099 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IndexedDBThread"); |
| 1127 ResetThread_IndexedDb(std::move(indexed_db_thread_)); | 1100 ResetThread_IndexedDb(std::move(indexed_db_thread_)); |
| 1128 } | 1101 } |
| 1129 #endif | |
| 1130 | 1102 |
| 1131 // Close the blocking I/O pool after the other threads. Other threads such | 1103 // Close the blocking I/O pool after the other threads. Other threads such |
| 1132 // as the I/O thread may need to schedule work like closing files or flushing | 1104 // as the I/O thread may need to schedule work like closing files or flushing |
| 1133 // data during shutdown, so the blocking pool needs to be available. There | 1105 // data during shutdown, so the blocking pool needs to be available. There |
| 1134 // may also be slow operations pending that will blcok shutdown, so closing | 1106 // may also be slow operations pending that will blcok shutdown, so closing |
| 1135 // it here (which will block until required operations are complete) gives | 1107 // it here (which will block until required operations are complete) gives |
| 1136 // more head start for those operations to finish. | 1108 // more head start for those operations to finish. |
| 1137 { | 1109 { |
| 1138 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:ThreadPool"); | 1110 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:ThreadPool"); |
| 1139 BrowserThreadImpl::ShutdownThreadPool(); | 1111 BrowserThreadImpl::ShutdownThreadPool(); |
| 1140 } | 1112 } |
| 1141 | |
| 1142 #if !defined(OS_IOS) | |
| 1143 // Must happen after the IO thread is shutdown since this may be accessed from | 1113 // Must happen after the IO thread is shutdown since this may be accessed from |
| 1144 // it. | 1114 // it. |
| 1145 { | 1115 { |
| 1146 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUChannelFactory"); | 1116 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUChannelFactory"); |
| 1147 if (BrowserGpuChannelHostFactory::instance()) | 1117 if (BrowserGpuChannelHostFactory::instance()) |
| 1148 BrowserGpuChannelHostFactory::Terminate(); | 1118 BrowserGpuChannelHostFactory::Terminate(); |
| 1149 } | 1119 } |
| 1150 | 1120 |
| 1151 // Must happen after the I/O thread is shutdown since this class lives on the | 1121 // Must happen after the I/O thread is shutdown since this class lives on the |
| 1152 // I/O thread and isn't threadsafe. | 1122 // I/O thread and isn't threadsafe. |
| 1153 { | 1123 { |
| 1154 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GamepadService"); | 1124 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GamepadService"); |
| 1155 GamepadService::GetInstance()->Terminate(); | 1125 GamepadService::GetInstance()->Terminate(); |
| 1156 } | 1126 } |
| 1157 { | 1127 { |
| 1158 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:SensorService"); | 1128 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:SensorService"); |
| 1159 DeviceInertialSensorService::GetInstance()->Shutdown(); | 1129 DeviceInertialSensorService::GetInstance()->Shutdown(); |
| 1160 } | 1130 } |
| 1161 #if !defined(OS_ANDROID) | 1131 #if !defined(OS_ANDROID) |
| 1162 { | 1132 { |
| 1163 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:BatteryStatusService"); | 1133 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:BatteryStatusService"); |
| 1164 device::BatteryStatusService::GetInstance()->Shutdown(); | 1134 device::BatteryStatusService::GetInstance()->Shutdown(); |
| 1165 } | 1135 } |
| 1166 #endif | 1136 #endif |
| 1167 { | 1137 { |
| 1168 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DeleteDataSources"); | 1138 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DeleteDataSources"); |
| 1169 URLDataManager::DeleteDataSources(); | 1139 URLDataManager::DeleteDataSources(); |
| 1170 } | 1140 } |
| 1171 #endif // !defined(OS_IOS) | |
| 1172 | 1141 |
| 1173 if (parts_) { | 1142 if (parts_) { |
| 1174 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); | 1143 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); |
| 1175 parts_->PostDestroyThreads(); | 1144 parts_->PostDestroyThreads(); |
| 1176 } | 1145 } |
| 1177 } | 1146 } |
| 1178 | 1147 |
| 1179 void BrowserMainLoop::StopStartupTracingTimer() { | 1148 void BrowserMainLoop::StopStartupTracingTimer() { |
| 1180 startup_trace_timer_.Stop(); | 1149 startup_trace_timer_.Stop(); |
| 1181 } | 1150 } |
| 1182 | 1151 |
| 1183 void BrowserMainLoop::InitializeMainThread() { | 1152 void BrowserMainLoop::InitializeMainThread() { |
| 1184 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeMainThread"); | 1153 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeMainThread"); |
| 1185 static const char kThreadName[] = "CrBrowserMain"; | 1154 static const char kThreadName[] = "CrBrowserMain"; |
| 1186 base::PlatformThread::SetName(kThreadName); | 1155 base::PlatformThread::SetName(kThreadName); |
| 1187 if (main_message_loop_) | 1156 if (main_message_loop_) |
| 1188 main_message_loop_->set_thread_name(kThreadName); | 1157 main_message_loop_->set_thread_name(kThreadName); |
| 1189 | 1158 |
| 1190 // Register the main thread by instantiating it, but don't call any methods. | 1159 // Register the main thread by instantiating it, but don't call any methods. |
| 1191 main_thread_.reset( | 1160 main_thread_.reset( |
| 1192 new BrowserThreadImpl(BrowserThread::UI, base::MessageLoop::current())); | 1161 new BrowserThreadImpl(BrowserThread::UI, base::MessageLoop::current())); |
| 1193 } | 1162 } |
| 1194 | 1163 |
| 1195 int BrowserMainLoop::BrowserThreadsStarted() { | 1164 int BrowserMainLoop::BrowserThreadsStarted() { |
| 1196 TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted"); | 1165 TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted"); |
| 1197 | 1166 |
| 1198 #if !defined(OS_IOS) | |
| 1199 // Bring up Mojo IPC and shell as early as possible. | 1167 // Bring up Mojo IPC and shell as early as possible. |
| 1200 mojo_ipc_support_.reset(new IPC::ScopedIPCSupport( | 1168 mojo_ipc_support_.reset(new IPC::ScopedIPCSupport( |
| 1201 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) | 1169 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) |
| 1202 ->task_runner())); | 1170 ->task_runner())); |
| 1203 mojo_shell_context_.reset(new MojoShellContext); | 1171 mojo_shell_context_.reset(new MojoShellContext); |
| 1204 #if defined(OS_MACOSX) | 1172 #if defined(OS_MACOSX) |
| 1205 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()); | 1173 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()); |
| 1206 #endif // defined(OS_MACOSX) | 1174 #endif // defined(OS_MACOSX) |
| 1207 #endif // !defined(OS_IOS) | |
| 1208 | 1175 |
| 1209 #if !defined(OS_IOS) | |
| 1210 indexed_db_thread_.reset(new base::Thread("IndexedDB")); | 1176 indexed_db_thread_.reset(new base::Thread("IndexedDB")); |
| 1211 indexed_db_thread_->Start(); | 1177 indexed_db_thread_->Start(); |
| 1212 #endif | |
| 1213 | 1178 |
| 1214 #if !defined(OS_IOS) | |
| 1215 HistogramSynchronizer::GetInstance(); | 1179 HistogramSynchronizer::GetInstance(); |
| 1216 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 1180 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 1217 // Up the priority of the UI thread. | 1181 // Up the priority of the UI thread. |
| 1218 base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY); | 1182 base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY); |
| 1219 #endif | 1183 #endif |
| 1220 | 1184 |
| 1221 bool always_uses_gpu = true; | 1185 bool always_uses_gpu = true; |
| 1222 bool established_gpu_channel = false; | 1186 bool established_gpu_channel = false; |
| 1223 #if defined(OS_ANDROID) | 1187 #if defined(OS_ANDROID) |
| 1224 // TODO(crbug.com/439322): This should be set to |true|. | 1188 // TODO(crbug.com/439322): This should be set to |true|. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 base::Bind(base::IgnoreResult(&GpuProcessHost::Get), | 1305 base::Bind(base::IgnoreResult(&GpuProcessHost::Get), |
| 1342 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 1306 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 1343 CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); | 1307 CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); |
| 1344 } | 1308 } |
| 1345 | 1309 |
| 1346 #if defined(OS_MACOSX) | 1310 #if defined(OS_MACOSX) |
| 1347 ThemeHelperMac::GetInstance(); | 1311 ThemeHelperMac::GetInstance(); |
| 1348 SystemHotkeyHelperMac::GetInstance()->DeferredLoadSystemHotkeys(); | 1312 SystemHotkeyHelperMac::GetInstance()->DeferredLoadSystemHotkeys(); |
| 1349 #endif // defined(OS_MACOSX) | 1313 #endif // defined(OS_MACOSX) |
| 1350 | 1314 |
| 1351 #endif // !defined(OS_IOS) | |
| 1352 | |
| 1353 return result_code_; | 1315 return result_code_; |
| 1354 } | 1316 } |
| 1355 | 1317 |
| 1356 bool BrowserMainLoop::UsingInProcessGpu() const { | 1318 bool BrowserMainLoop::UsingInProcessGpu() const { |
| 1357 return parsed_command_line_.HasSwitch(switches::kSingleProcess) || | 1319 return parsed_command_line_.HasSwitch(switches::kSingleProcess) || |
| 1358 parsed_command_line_.HasSwitch(switches::kInProcessGPU); | 1320 parsed_command_line_.HasSwitch(switches::kInProcessGPU); |
| 1359 } | 1321 } |
| 1360 | 1322 |
| 1361 bool BrowserMainLoop::InitializeToolkit() { | 1323 bool BrowserMainLoop::InitializeToolkit() { |
| 1362 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit"); | 1324 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit"); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 DCHECK(is_tracing_startup_for_duration_); | 1445 DCHECK(is_tracing_startup_for_duration_); |
| 1484 | 1446 |
| 1485 is_tracing_startup_for_duration_ = false; | 1447 is_tracing_startup_for_duration_ = false; |
| 1486 TracingController::GetInstance()->StopTracing( | 1448 TracingController::GetInstance()->StopTracing( |
| 1487 TracingController::CreateFileSink( | 1449 TracingController::CreateFileSink( |
| 1488 startup_trace_file_, | 1450 startup_trace_file_, |
| 1489 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); | 1451 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); |
| 1490 } | 1452 } |
| 1491 | 1453 |
| 1492 } // namespace content | 1454 } // namespace content |
| OLD | NEW |