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 <string> | |
|
jam
2012/03/06 21:21:38
nit: no need. i understand you're adding it for IW
Lei Zhang
2012/03/06 21:36:50
Done.
| |
| 8 | |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 12 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 13 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 14 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 15 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 16 #include "content/browser/browser_thread_impl.h" | 18 #include "content/browser/browser_thread_impl.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 47 #include <windows.h> | 49 #include <windows.h> |
| 48 #include <commctrl.h> | 50 #include <commctrl.h> |
| 49 #include <ole2.h> | 51 #include <ole2.h> |
| 50 #include <shellapi.h> | 52 #include <shellapi.h> |
| 51 | 53 |
| 52 #include "content/browser/system_message_window_win.h" | 54 #include "content/browser/system_message_window_win.h" |
| 53 #include "ui/base/l10n/l10n_util_win.h" | 55 #include "ui/base/l10n/l10n_util_win.h" |
| 54 #include "net/base/winsock_init.h" | 56 #include "net/base/winsock_init.h" |
| 55 #endif | 57 #endif |
| 56 | 58 |
| 59 #if defined(OS_LINUX) | |
| 60 #include "content/browser/media_device_notifications_linux.h" | |
| 61 #endif | |
| 62 | |
| 57 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 63 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 58 #include <glib-object.h> | 64 #include <glib-object.h> |
| 59 #endif | 65 #endif |
| 60 | 66 |
| 61 #if defined(OS_CHROMEOS) | 67 #if defined(OS_CHROMEOS) |
| 62 #include <dbus/dbus-glib.h> | 68 #include <dbus/dbus-glib.h> |
| 63 #endif | 69 #endif |
| 64 | 70 |
| 65 #if defined(TOOLKIT_USES_GTK) | 71 #if defined(TOOLKIT_USES_GTK) |
| 66 #include "ui/gfx/gtk_util.h" | 72 #include "ui/gfx/gtk_util.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 203 |
| 198 void ImmediateShutdownAndExitProcess() { | 204 void ImmediateShutdownAndExitProcess() { |
| 199 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); | 205 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); |
| 200 } | 206 } |
| 201 | 207 |
| 202 // static | 208 // static |
| 203 AudioManager* BrowserMainLoop::GetAudioManager() { | 209 AudioManager* BrowserMainLoop::GetAudioManager() { |
| 204 return g_current_browser_main_loop->audio_manager_.get(); | 210 return g_current_browser_main_loop->audio_manager_.get(); |
| 205 } | 211 } |
| 206 | 212 |
| 207 // BrowserMainLoop construction / destructione ============================= | 213 // BrowserMainLoop construction / destruction ============================= |
| 208 | 214 |
| 209 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) | 215 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) |
| 210 : parameters_(parameters), | 216 : parameters_(parameters), |
| 211 parsed_command_line_(parameters.command_line), | 217 parsed_command_line_(parameters.command_line), |
| 212 result_code_(content::RESULT_CODE_NORMAL_EXIT) { | 218 result_code_(content::RESULT_CODE_NORMAL_EXIT) { |
| 213 DCHECK(!g_current_browser_main_loop); | 219 DCHECK(!g_current_browser_main_loop); |
| 214 g_current_browser_main_loop = this; | 220 g_current_browser_main_loop = this; |
| 215 #if defined(OS_WIN) | 221 #if defined(OS_WIN) |
| 216 OleInitialize(NULL); | 222 OleInitialize(NULL); |
| 217 #endif | 223 #endif |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 | 586 |
| 581 // Register the main thread by instantiating it, but don't call any methods. | 587 // Register the main thread by instantiating it, but don't call any methods. |
| 582 main_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, | 588 main_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, |
| 583 MessageLoop::current())); | 589 MessageLoop::current())); |
| 584 } | 590 } |
| 585 | 591 |
| 586 | 592 |
| 587 void BrowserMainLoop::BrowserThreadsStarted() { | 593 void BrowserMainLoop::BrowserThreadsStarted() { |
| 588 // RDH needs the IO thread to be created. | 594 // RDH needs the IO thread to be created. |
| 589 resource_dispatcher_host_.reset(new ResourceDispatcherHost()); | 595 resource_dispatcher_host_.reset(new ResourceDispatcherHost()); |
| 596 | |
| 597 #if defined(OS_LINUX) | |
| 598 // MediaDeviceNotificationsLinux needs the File Thread. | |
| 599 const FilePath kDefaultMtabPath("/etc/mtab"); | |
| 600 media_device_notifications_linux_ = | |
| 601 new MediaDeviceNotificationsLinux(kDefaultMtabPath); | |
| 602 BrowserThread::PostTask( | |
| 603 BrowserThread::FILE, FROM_HERE, | |
|
jam
2012/03/06 21:21:38
nit: it's nicer if this class can do its thread in
Lei Zhang
2012/03/06 21:36:50
Done.
jam
2012/03/06 22:22:11
you have do it in in a separate method, i.e. after
Lei Zhang
2012/03/06 23:23:42
Oh thanks for reminding me about that. Fixed.
| |
| 604 base::Bind(&MediaDeviceNotificationsLinux::InitOnFileThread, | |
| 605 media_device_notifications_linux_.get())); | |
| 606 #endif | |
| 590 } | 607 } |
| 591 | 608 |
| 592 void BrowserMainLoop::InitializeToolkit() { | 609 void BrowserMainLoop::InitializeToolkit() { |
| 593 // TODO(evan): this function is rather subtle, due to the variety | 610 // TODO(evan): this function is rather subtle, due to the variety |
| 594 // of intersecting ifdefs we have. To keep it easy to follow, there | 611 // of intersecting ifdefs we have. To keep it easy to follow, there |
| 595 // are no #else branches on any #ifs. | 612 // are no #else branches on any #ifs. |
| 596 // TODO(stevenjb): Move platform specific code into platform specific Parts | 613 // TODO(stevenjb): Move platform specific code into platform specific Parts |
| 597 // (Need to add InitializeToolkit stage to BrowserParts). | 614 // (Need to add InitializeToolkit stage to BrowserParts). |
| 598 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 615 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 599 // Glib type system initialization. Needed at least for gconf, | 616 // Glib type system initialization. Needed at least for gconf, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 655 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
| 639 | 656 |
| 640 #if defined(OS_MACOSX) | 657 #if defined(OS_MACOSX) |
| 641 MessageLoopForUI::current()->Run(); | 658 MessageLoopForUI::current()->Run(); |
| 642 #else | 659 #else |
| 643 MessageLoopForUI::current()->RunWithDispatcher(NULL); | 660 MessageLoopForUI::current()->RunWithDispatcher(NULL); |
| 644 #endif | 661 #endif |
| 645 } | 662 } |
| 646 | 663 |
| 647 } // namespace content | 664 } // namespace content |
| OLD | NEW |