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