Chromium Code Reviews| 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/hi_res_timer_manager.h" | 10 #include "base/hi_res_timer_manager.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 #endif | 289 #endif |
| 290 | 290 |
| 291 if (parsed_command_line_.HasSwitch(switches::kEnableSSLCachedInfo)) | 291 if (parsed_command_line_.HasSwitch(switches::kEnableSSLCachedInfo)) |
| 292 net::SSLConfigService::EnableCachedInfo(); | 292 net::SSLConfigService::EnableCachedInfo(); |
| 293 | 293 |
| 294 // TODO(abarth): Should this move to InitializeNetworkOptions? This doesn't | 294 // TODO(abarth): Should this move to InitializeNetworkOptions? This doesn't |
| 295 // seem dependent on SSL initialization(). | 295 // seem dependent on SSL initialization(). |
| 296 if (parsed_command_line_.HasSwitch(switches::kEnableTcpFastOpen)) | 296 if (parsed_command_line_.HasSwitch(switches::kEnableTcpFastOpen)) |
| 297 net::set_tcp_fastopen_enabled(true); | 297 net::set_tcp_fastopen_enabled(true); |
| 298 | 298 |
| 299 #if !defined(OS_IOS) | |
| 299 if (parsed_command_line_.HasSwitch(switches::kRendererProcessLimit)) { | 300 if (parsed_command_line_.HasSwitch(switches::kRendererProcessLimit)) { |
| 300 std::string limit_string = parsed_command_line_.GetSwitchValueASCII( | 301 std::string limit_string = parsed_command_line_.GetSwitchValueASCII( |
| 301 switches::kRendererProcessLimit); | 302 switches::kRendererProcessLimit); |
| 302 size_t process_limit; | 303 size_t process_limit; |
| 303 if (base::StringToSizeT(limit_string, &process_limit)) { | 304 if (base::StringToSizeT(limit_string, &process_limit)) { |
| 304 content::RenderProcessHost::SetMaxRendererProcessCount(process_limit); | 305 content::RenderProcessHost::SetMaxRendererProcessCount(process_limit); |
| 305 } | 306 } |
| 306 } | 307 } |
| 308 #endif // !defined(OS_IOS) | |
| 307 | 309 |
| 308 if (parts_.get()) | 310 if (parts_.get()) |
| 309 parts_->PostEarlyInitialization(); | 311 parts_->PostEarlyInitialization(); |
| 310 } | 312 } |
| 311 | 313 |
| 312 void BrowserMainLoop::MainMessageLoopStart() { | 314 void BrowserMainLoop::MainMessageLoopStart() { |
| 313 if (parts_.get()) | 315 if (parts_.get()) |
| 314 parts_->PreMainMessageLoopStart(); | 316 parts_->PreMainMessageLoopStart(); |
| 315 | 317 |
| 316 #if defined(OS_WIN) | 318 #if defined(OS_WIN) |
| 317 // If we're running tests (ui_task is non-null), then the ResourceBundle | 319 // If we're running tests (ui_task is non-null), then the ResourceBundle |
| 318 // has already been initialized. | 320 // has already been initialized. |
| 319 if (!parameters_.ui_task) { | 321 if (!parameters_.ui_task) { |
| 320 // Override the configured locale with the user's preferred UI language. | 322 // Override the configured locale with the user's preferred UI language. |
| 321 l10n_util::OverrideLocaleWithUILanguageList(); | 323 l10n_util::OverrideLocaleWithUILanguageList(); |
| 322 } | 324 } |
| 323 #endif | 325 #endif |
| 324 | 326 |
| 325 // Create a MessageLoop if one does not already exist for the current thread. | 327 // Create a MessageLoop if one does not already exist for the current thread. |
| 326 if (!MessageLoop::current()) | 328 if (!MessageLoop::current()) |
| 327 main_message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); | 329 main_message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); |
| 328 | 330 |
| 329 InitializeMainThread(); | 331 InitializeMainThread(); |
| 330 | 332 |
| 333 #if !defined(OS_IOS) | |
| 331 // Start tracing to a file if needed. | 334 // Start tracing to a file if needed. |
| 332 if (base::debug::TraceLog::GetInstance()->IsEnabled()) { | 335 if (base::debug::TraceLog::GetInstance()->IsEnabled()) { |
| 333 TraceControllerImpl::GetInstance()->InitStartupTracing( | 336 TraceControllerImpl::GetInstance()->InitStartupTracing( |
| 334 parsed_command_line_); | 337 parsed_command_line_); |
| 335 } | 338 } |
| 339 #endif // !defined(OS_IOS) | |
| 336 | 340 |
| 337 system_monitor_.reset(new base::SystemMonitor); | 341 system_monitor_.reset(new base::SystemMonitor); |
|
jam
2012/09/05 15:49:05
nit: move this code up so that the two ifdefs can
leng
2012/09/06 08:40:02
Done.
| |
| 338 hi_res_timer_manager_.reset(new HighResolutionTimerManager); | 342 hi_res_timer_manager_.reset(new HighResolutionTimerManager); |
| 339 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 343 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
| 340 audio_manager_.reset(media::AudioManager::Create()); | 344 audio_manager_.reset(media::AudioManager::Create()); |
| 345 #if !defined(OS_IOS) | |
| 341 online_state_observer_.reset(new BrowserOnlineStateObserver); | 346 online_state_observer_.reset(new BrowserOnlineStateObserver); |
| 342 scoped_refptr<media_stream::AudioInputDeviceManager> | 347 scoped_refptr<media_stream::AudioInputDeviceManager> |
| 343 audio_input_device_manager( | 348 audio_input_device_manager( |
| 344 new media_stream::AudioInputDeviceManager(audio_manager_.get())); | 349 new media_stream::AudioInputDeviceManager(audio_manager_.get())); |
| 345 scoped_refptr<media_stream::VideoCaptureManager> video_capture_manager( | 350 scoped_refptr<media_stream::VideoCaptureManager> video_capture_manager( |
| 346 new media_stream::VideoCaptureManager()); | 351 new media_stream::VideoCaptureManager()); |
| 347 media_stream_manager_.reset(new media_stream::MediaStreamManager( | 352 media_stream_manager_.reset(new media_stream::MediaStreamManager( |
| 348 audio_input_device_manager, video_capture_manager)); | 353 audio_input_device_manager, video_capture_manager)); |
| 349 | 354 |
| 350 #if defined(OS_WIN) | |
| 351 system_message_window_.reset(new SystemMessageWindowWin); | |
| 352 #endif | |
| 353 | |
| 354 // Prior to any processing happening on the io thread, we create the | 355 // Prior to any processing happening on the io thread, we create the |
| 355 // plugin service as it is predominantly used from the io thread, | 356 // plugin service as it is predominantly used from the io thread, |
| 356 // but must be created on the main thread. The service ctor is | 357 // but must be created on the main thread. The service ctor is |
| 357 // inexpensive and does not invoke the io_thread() accessor. | 358 // inexpensive and does not invoke the io_thread() accessor. |
| 358 PluginService::GetInstance()->Init(); | 359 PluginService::GetInstance()->Init(); |
| 360 #endif // !defined(OS_IOS) | |
| 361 | |
| 362 #if defined(OS_WIN) | |
| 363 system_message_window_.reset(new SystemMessageWindowWin); | |
| 364 #endif | |
| 359 | 365 |
| 360 if (parts_.get()) | 366 if (parts_.get()) |
| 361 parts_->PostMainMessageLoopStart(); | 367 parts_->PostMainMessageLoopStart(); |
| 362 } | 368 } |
| 363 | 369 |
| 364 void BrowserMainLoop::CreateThreads() { | 370 void BrowserMainLoop::CreateThreads() { |
| 365 if (parts_.get()) | 371 if (parts_.get()) |
| 366 result_code_ = parts_->PreCreateThreads(); | 372 result_code_ = parts_->PreCreateThreads(); |
| 367 | 373 |
| 368 if (result_code_ > 0) | 374 if (result_code_ > 0) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 case BrowserThread::UI: | 427 case BrowserThread::UI: |
| 422 case BrowserThread::ID_COUNT: | 428 case BrowserThread::ID_COUNT: |
| 423 default: | 429 default: |
| 424 NOTREACHED(); | 430 NOTREACHED(); |
| 425 break; | 431 break; |
| 426 } | 432 } |
| 427 | 433 |
| 428 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); | 434 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); |
| 429 | 435 |
| 430 if (thread_id == BrowserThread::WEBKIT_DEPRECATED) { | 436 if (thread_id == BrowserThread::WEBKIT_DEPRECATED) { |
| 437 #if !defined(OS_IOS) | |
| 431 webkit_thread_.reset(new WebKitThread); | 438 webkit_thread_.reset(new WebKitThread); |
| 432 webkit_thread_->Initialize(); | 439 webkit_thread_->Initialize(); |
| 440 #endif | |
| 433 } else if (thread_to_start) { | 441 } else if (thread_to_start) { |
| 434 (*thread_to_start).reset(new BrowserProcessSubThread(id)); | 442 (*thread_to_start).reset(new BrowserProcessSubThread(id)); |
| 435 (*thread_to_start)->StartWithOptions(*options); | 443 (*thread_to_start)->StartWithOptions(*options); |
| 436 } else { | 444 } else { |
| 437 NOTREACHED(); | 445 NOTREACHED(); |
| 438 } | 446 } |
| 439 } | 447 } |
| 440 | 448 |
| 441 BrowserThreadsStarted(); | 449 BrowserThreadsStarted(); |
| 442 | 450 |
| 443 if (parts_.get()) | 451 if (parts_.get()) |
| 444 parts_->PreMainMessageLoopRun(); | 452 parts_->PreMainMessageLoopRun(); |
| 445 | 453 |
| 454 #if !defined(OS_IOS) | |
| 446 // When running the GPU thread in-process, avoid optimistically starting it | 455 // When running the GPU thread in-process, avoid optimistically starting it |
| 447 // since creating the GPU thread races against creation of the one-and-only | 456 // since creating the GPU thread races against creation of the one-and-only |
| 448 // ChildProcess instance which is created by the renderer thread. | 457 // ChildProcess instance which is created by the renderer thread. |
| 449 GpuDataManager* gpu_data_manager = content::GpuDataManager::GetInstance(); | 458 GpuDataManager* gpu_data_manager = content::GpuDataManager::GetInstance(); |
| 450 if (gpu_data_manager->GpuAccessAllowed() && | 459 if (gpu_data_manager->GpuAccessAllowed() && |
| 451 !parsed_command_line_.HasSwitch(switches::kDisableGpuProcessPrelaunch) && | 460 !parsed_command_line_.HasSwitch(switches::kDisableGpuProcessPrelaunch) && |
| 452 !parsed_command_line_.HasSwitch(switches::kSingleProcess) && | 461 !parsed_command_line_.HasSwitch(switches::kSingleProcess) && |
| 453 !parsed_command_line_.HasSwitch(switches::kInProcessGPU)) { | 462 !parsed_command_line_.HasSwitch(switches::kInProcessGPU)) { |
| 454 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process"); | 463 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process"); |
| 455 BrowserThread::PostTask( | 464 BrowserThread::PostTask( |
| 456 BrowserThread::IO, FROM_HERE, base::Bind( | 465 BrowserThread::IO, FROM_HERE, base::Bind( |
| 457 base::IgnoreResult(&GpuProcessHost::Get), | 466 base::IgnoreResult(&GpuProcessHost::Get), |
| 458 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 467 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 459 content::CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); | 468 content::CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); |
| 460 } | 469 } |
| 470 #endif // !defined(OS_IOS) | |
| 461 | 471 |
| 462 // If the UI thread blocks, the whole UI is unresponsive. | 472 // If the UI thread blocks, the whole UI is unresponsive. |
| 463 // Do not allow disk IO from the UI thread. | 473 // Do not allow disk IO from the UI thread. |
| 464 base::ThreadRestrictions::SetIOAllowed(false); | 474 base::ThreadRestrictions::SetIOAllowed(false); |
| 465 base::ThreadRestrictions::DisallowWaiting(); | 475 base::ThreadRestrictions::DisallowWaiting(); |
| 466 } | 476 } |
| 467 | 477 |
| 468 void BrowserMainLoop::RunMainMessageLoopParts() { | 478 void BrowserMainLoop::RunMainMessageLoopParts() { |
| 469 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); | 479 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); |
| 470 | 480 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 483 // need to be able to perform IO. | 493 // need to be able to perform IO. |
| 484 base::ThreadRestrictions::SetIOAllowed(true); | 494 base::ThreadRestrictions::SetIOAllowed(true); |
| 485 BrowserThread::PostTask( | 495 BrowserThread::PostTask( |
| 486 BrowserThread::IO, FROM_HERE, | 496 BrowserThread::IO, FROM_HERE, |
| 487 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), | 497 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), |
| 488 true)); | 498 true)); |
| 489 | 499 |
| 490 if (parts_.get()) | 500 if (parts_.get()) |
| 491 parts_->PostMainMessageLoopRun(); | 501 parts_->PostMainMessageLoopRun(); |
| 492 | 502 |
| 503 #if !defined(OS_IOS) | |
| 493 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to | 504 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to |
| 494 // delete related objects on the GPU thread. This must be done before | 505 // delete related objects on the GPU thread. This must be done before |
| 495 // stopping the GPU thread. The GPU thread will close IPC channels to renderer | 506 // stopping the GPU thread. The GPU thread will close IPC channels to renderer |
| 496 // processes so this has to happen before stopping the IO thread. | 507 // processes so this has to happen before stopping the IO thread. |
| 497 GpuProcessHostUIShim::DestroyAll(); | 508 GpuProcessHostUIShim::DestroyAll(); |
| 498 | 509 |
| 499 // Cancel pending requests and prevent new requests. | 510 // Cancel pending requests and prevent new requests. |
| 500 if (resource_dispatcher_host_.get()) | 511 if (resource_dispatcher_host_.get()) |
| 501 resource_dispatcher_host_.get()->Shutdown(); | 512 resource_dispatcher_host_.get()->Shutdown(); |
| 502 | 513 |
| 503 #if defined(USE_AURA) | 514 #if defined(USE_AURA) |
| 504 ImageTransportFactory::Terminate(); | 515 ImageTransportFactory::Terminate(); |
| 505 #endif | 516 #endif |
| 506 BrowserGpuChannelHostFactory::Terminate(); | 517 BrowserGpuChannelHostFactory::Terminate(); |
| 507 | 518 |
| 508 GamepadService::GetInstance()->Terminate(); | 519 GamepadService::GetInstance()->Terminate(); |
| 509 | 520 |
| 510 // The device monitors are using |system_monitor_| as dependency, so delete | 521 // The device monitors are using |system_monitor_| as dependency, so delete |
| 511 // them before |system_monitor_| goes away. | 522 // them before |system_monitor_| goes away. |
| 512 // On Mac and windows, the monitor needs to be destroyed on the same thread | 523 // On Mac and windows, the monitor needs to be destroyed on the same thread |
| 513 // as they were created. On Linux, the monitor will be deleted when IO thread | 524 // as they were created. On Linux, the monitor will be deleted when IO thread |
| 514 // goes away. | 525 // goes away. |
| 515 #if defined(OS_WIN) | 526 #if defined(OS_WIN) |
| 516 system_message_window_.reset(); | 527 system_message_window_.reset(); |
| 517 #elif defined(OS_MACOSX) | 528 #elif defined(OS_MACOSX) |
| 518 device_monitor_mac_.reset(); | 529 device_monitor_mac_.reset(); |
| 519 #endif | 530 #endif |
| 531 #endif // !defined(OS_IOS) | |
| 520 | 532 |
| 521 // Must be size_t so we can subtract from it. | 533 // Must be size_t so we can subtract from it. |
| 522 for (size_t thread_id = BrowserThread::ID_COUNT - 1; | 534 for (size_t thread_id = BrowserThread::ID_COUNT - 1; |
| 523 thread_id >= (BrowserThread::UI + 1); | 535 thread_id >= (BrowserThread::UI + 1); |
| 524 --thread_id) { | 536 --thread_id) { |
| 525 // Find the thread object we want to stop. Looping over all valid | 537 // Find the thread object we want to stop. Looping over all valid |
| 526 // BrowserThread IDs and DCHECKing on a missing case in the switch | 538 // BrowserThread IDs and DCHECKing on a missing case in the switch |
| 527 // statement helps avoid a mismatch between this code and the | 539 // statement helps avoid a mismatch between this code and the |
| 528 // BrowserThread::ID enumeration. | 540 // BrowserThread::ID enumeration. |
| 529 // | 541 // |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 557 // Need to destroy ResourceDispatcherHost before PluginService | 569 // Need to destroy ResourceDispatcherHost before PluginService |
| 558 // and since it caches a pointer to it. | 570 // and since it caches a pointer to it. |
| 559 resource_dispatcher_host_.reset(); | 571 resource_dispatcher_host_.reset(); |
| 560 break; | 572 break; |
| 561 case BrowserThread::FILE_USER_BLOCKING: | 573 case BrowserThread::FILE_USER_BLOCKING: |
| 562 thread_to_stop = &file_user_blocking_thread_; | 574 thread_to_stop = &file_user_blocking_thread_; |
| 563 break; | 575 break; |
| 564 case BrowserThread::FILE: | 576 case BrowserThread::FILE: |
| 565 thread_to_stop = &file_thread_; | 577 thread_to_stop = &file_thread_; |
| 566 | 578 |
| 579 #if !defined(OS_IOS) | |
| 567 // Clean up state that lives on or uses the file_thread_ before | 580 // Clean up state that lives on or uses the file_thread_ before |
| 568 // it goes away. | 581 // it goes away. |
| 569 if (resource_dispatcher_host_.get()) { | 582 if (resource_dispatcher_host_.get()) { |
| 570 resource_dispatcher_host_.get()->download_file_manager()->Shutdown(); | 583 resource_dispatcher_host_.get()->download_file_manager()->Shutdown(); |
| 571 resource_dispatcher_host_.get()->save_file_manager()->Shutdown(); | 584 resource_dispatcher_host_.get()->save_file_manager()->Shutdown(); |
| 572 } | 585 } |
| 586 #endif // !defined(OS_IOS) | |
| 573 break; | 587 break; |
| 574 case BrowserThread::PROCESS_LAUNCHER: | 588 case BrowserThread::PROCESS_LAUNCHER: |
| 575 thread_to_stop = &process_launcher_thread_; | 589 thread_to_stop = &process_launcher_thread_; |
| 576 break; | 590 break; |
| 577 case BrowserThread::CACHE: | 591 case BrowserThread::CACHE: |
| 578 thread_to_stop = &cache_thread_; | 592 thread_to_stop = &cache_thread_; |
| 579 break; | 593 break; |
| 580 case BrowserThread::IO: | 594 case BrowserThread::IO: |
| 581 thread_to_stop = &io_thread_; | 595 thread_to_stop = &io_thread_; |
| 582 break; | 596 break; |
| 583 case BrowserThread::UI: | 597 case BrowserThread::UI: |
| 584 case BrowserThread::ID_COUNT: | 598 case BrowserThread::ID_COUNT: |
| 585 default: | 599 default: |
| 586 NOTREACHED(); | 600 NOTREACHED(); |
| 587 break; | 601 break; |
| 588 } | 602 } |
| 589 | 603 |
| 590 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); | 604 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); |
| 591 | 605 |
| 592 if (id == BrowserThread::WEBKIT_DEPRECATED) { | 606 if (id == BrowserThread::WEBKIT_DEPRECATED) { |
| 607 #if !defined(OS_IOS) | |
| 593 webkit_thread_.reset(); | 608 webkit_thread_.reset(); |
| 609 #endif | |
| 594 } else if (thread_to_stop) { | 610 } else if (thread_to_stop) { |
| 595 thread_to_stop->reset(); | 611 thread_to_stop->reset(); |
| 596 } else { | 612 } else { |
| 597 NOTREACHED(); | 613 NOTREACHED(); |
| 598 } | 614 } |
| 599 } | 615 } |
| 600 | 616 |
| 601 // Close the blocking I/O pool after the other threads. Other threads such | 617 // Close the blocking I/O pool after the other threads. Other threads such |
| 602 // as the I/O thread may need to schedule work like closing files or flushing | 618 // as the I/O thread may need to schedule work like closing files or flushing |
| 603 // data during shutdown, so the blocking pool needs to be available. There | 619 // data during shutdown, so the blocking pool needs to be available. There |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 616 if (main_message_loop_.get()) | 632 if (main_message_loop_.get()) |
| 617 main_message_loop_->set_thread_name(kThreadName); | 633 main_message_loop_->set_thread_name(kThreadName); |
| 618 | 634 |
| 619 // Register the main thread by instantiating it, but don't call any methods. | 635 // Register the main thread by instantiating it, but don't call any methods. |
| 620 main_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, | 636 main_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, |
| 621 MessageLoop::current())); | 637 MessageLoop::current())); |
| 622 } | 638 } |
| 623 | 639 |
| 624 | 640 |
| 625 void BrowserMainLoop::BrowserThreadsStarted() { | 641 void BrowserMainLoop::BrowserThreadsStarted() { |
| 642 #if !defined(OS_IOS) | |
| 626 HistogramSynchronizer::GetInstance(); | 643 HistogramSynchronizer::GetInstance(); |
| 627 | 644 |
| 628 content::BrowserGpuChannelHostFactory::Initialize(); | 645 content::BrowserGpuChannelHostFactory::Initialize(); |
| 629 #if defined(USE_AURA) | 646 #if defined(USE_AURA) |
| 630 ImageTransportFactory::Initialize(); | 647 ImageTransportFactory::Initialize(); |
| 631 #endif | 648 #endif |
| 632 | 649 |
| 633 #if defined(OS_LINUX) | 650 #if defined(OS_LINUX) |
| 634 device_monitor_linux_.reset(new DeviceMonitorLinux()); | 651 device_monitor_linux_.reset(new DeviceMonitorLinux()); |
| 635 #elif defined(OS_MACOSX) | 652 #elif defined(OS_MACOSX) |
| 636 device_monitor_mac_.reset(new DeviceMonitorMac()); | 653 device_monitor_mac_.reset(new DeviceMonitorMac()); |
| 637 #endif | 654 #endif |
| 638 | 655 |
| 639 // RDH needs the IO thread to be created. | 656 // RDH needs the IO thread to be created. |
| 640 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); | 657 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); |
| 641 | 658 |
| 659 // Start the GpuDataManager before we set up the MessageLoops because | |
| 660 // otherwise we'll trigger the assertion about doing IO on the UI thread. | |
| 661 content::GpuDataManager::GetInstance(); | |
| 662 #endif // !OS_IOS | |
| 663 | |
| 642 #if defined(ENABLE_INPUT_SPEECH) | 664 #if defined(ENABLE_INPUT_SPEECH) |
| 643 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); | 665 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); |
| 644 #endif | 666 #endif |
| 645 | |
| 646 // Start the GpuDataManager before we set up the MessageLoops because | |
| 647 // otherwise we'll trigger the assertion about doing IO on the UI thread. | |
| 648 content::GpuDataManager::GetInstance(); | |
| 649 } | 667 } |
| 650 | 668 |
| 651 void BrowserMainLoop::InitializeToolkit() { | 669 void BrowserMainLoop::InitializeToolkit() { |
| 652 // TODO(evan): this function is rather subtle, due to the variety | 670 // TODO(evan): this function is rather subtle, due to the variety |
| 653 // of intersecting ifdefs we have. To keep it easy to follow, there | 671 // of intersecting ifdefs we have. To keep it easy to follow, there |
| 654 // are no #else branches on any #ifs. | 672 // are no #else branches on any #ifs. |
| 655 // TODO(stevenjb): Move platform specific code into platform specific Parts | 673 // TODO(stevenjb): Move platform specific code into platform specific Parts |
| 656 // (Need to add InitializeToolkit stage to BrowserParts). | 674 // (Need to add InitializeToolkit stage to BrowserParts). |
| 657 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 675 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 658 // Glib type system initialization. Needed at least for gconf, | 676 // Glib type system initialization. Needed at least for gconf, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 714 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
| 697 if (parameters_.ui_task) | 715 if (parameters_.ui_task) |
| 698 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 716 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
| 699 | 717 |
| 700 base::RunLoop run_loop; | 718 base::RunLoop run_loop; |
| 701 run_loop.Run(); | 719 run_loop.Run(); |
| 702 #endif | 720 #endif |
| 703 } | 721 } |
| 704 | 722 |
| 705 } // namespace content | 723 } // namespace content |
| OLD | NEW |