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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 498 |
499 // Cancel pending requests and prevent new requests. | 499 // Cancel pending requests and prevent new requests. |
500 if (resource_dispatcher_host_.get()) | 500 if (resource_dispatcher_host_.get()) |
501 resource_dispatcher_host_.get()->Shutdown(); | 501 resource_dispatcher_host_.get()->Shutdown(); |
502 | 502 |
503 #if defined(USE_AURA) | 503 #if defined(USE_AURA) |
504 ImageTransportFactory::Terminate(); | 504 ImageTransportFactory::Terminate(); |
505 #endif | 505 #endif |
506 BrowserGpuChannelHostFactory::Terminate(); | 506 BrowserGpuChannelHostFactory::Terminate(); |
507 | 507 |
508 GamepadService::GetInstance()->Terminate(); | |
509 | |
510 // The device monitors are using |system_monitor_| as dependency, so delete | 508 // The device monitors are using |system_monitor_| as dependency, so delete |
511 // them before |system_monitor_| goes away. | 509 // them before |system_monitor_| goes away. |
512 // On Mac and windows, the monitor needs to be destroyed on the same thread | 510 // 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 | 511 // as they were created. On Linux, the monitor will be deleted when IO thread |
514 // goes away. | 512 // goes away. |
515 #if defined(OS_WIN) | 513 #if defined(OS_WIN) |
516 system_message_window_.reset(); | 514 system_message_window_.reset(); |
517 #elif defined(OS_MACOSX) | 515 #elif defined(OS_MACOSX) |
518 device_monitor_mac_.reset(); | 516 device_monitor_mac_.reset(); |
519 #endif | 517 #endif |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 } | 597 } |
600 | 598 |
601 // Close the blocking I/O pool after the other threads. Other threads such | 599 // 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 | 600 // 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 | 601 // data during shutdown, so the blocking pool needs to be available. There |
604 // may also be slow operations pending that will blcok shutdown, so closing | 602 // may also be slow operations pending that will blcok shutdown, so closing |
605 // it here (which will block until required operations are complete) gives | 603 // it here (which will block until required operations are complete) gives |
606 // more head start for those operations to finish. | 604 // more head start for those operations to finish. |
607 BrowserThreadImpl::ShutdownThreadPool(); | 605 BrowserThreadImpl::ShutdownThreadPool(); |
608 | 606 |
| 607 // Must happen after the I/O thread is shutdown since this class lives on the |
| 608 // I/O thread and isn't threadsafe. |
| 609 GamepadService::GetInstance()->Terminate(); |
| 610 |
609 if (parts_.get()) | 611 if (parts_.get()) |
610 parts_->PostDestroyThreads(); | 612 parts_->PostDestroyThreads(); |
611 } | 613 } |
612 | 614 |
613 void BrowserMainLoop::InitializeMainThread() { | 615 void BrowserMainLoop::InitializeMainThread() { |
614 const char* kThreadName = "CrBrowserMain"; | 616 const char* kThreadName = "CrBrowserMain"; |
615 base::PlatformThread::SetName(kThreadName); | 617 base::PlatformThread::SetName(kThreadName); |
616 if (main_message_loop_.get()) | 618 if (main_message_loop_.get()) |
617 main_message_loop_->set_thread_name(kThreadName); | 619 main_message_loop_->set_thread_name(kThreadName); |
618 | 620 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 698 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
697 if (parameters_.ui_task) | 699 if (parameters_.ui_task) |
698 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 700 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
699 | 701 |
700 base::RunLoop run_loop; | 702 base::RunLoop run_loop; |
701 run_loop.Run(); | 703 run_loop.Run(); |
702 #endif | 704 #endif |
703 } | 705 } |
704 | 706 |
705 } // namespace content | 707 } // namespace content |
OLD | NEW |