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> |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 52 |
51 #include "content/browser/system_message_window_win.h" | 53 #include "content/browser/system_message_window_win.h" |
52 #include "ui/base/l10n/l10n_util_win.h" | 54 #include "ui/base/l10n/l10n_util_win.h" |
53 #include "net/base/winsock_init.h" | 55 #include "net/base/winsock_init.h" |
54 #endif | 56 #endif |
55 | 57 |
56 #if defined(OS_MACOSX) | 58 #if defined(OS_MACOSX) |
57 #include "content/browser/mac/media_device_notifications.h" | 59 #include "content/browser/mac/media_device_notifications.h" |
58 #endif | 60 #endif |
59 | 61 |
| 62 #if defined(OS_LINUX) |
| 63 #include "content/browser/media_device_notifications_linux.h" |
| 64 #endif |
| 65 |
60 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 66 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
61 #include <glib-object.h> | 67 #include <glib-object.h> |
62 #endif | 68 #endif |
63 | 69 |
64 #if defined(OS_CHROMEOS) | 70 #if defined(OS_CHROMEOS) |
65 #include <dbus/dbus-glib.h> | 71 #include <dbus/dbus-glib.h> |
66 #endif | 72 #endif |
67 | 73 |
68 #if defined(TOOLKIT_USES_GTK) | 74 #if defined(TOOLKIT_USES_GTK) |
69 #include "ui/gfx/gtk_util.h" | 75 #include "ui/gfx/gtk_util.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 206 |
201 void ImmediateShutdownAndExitProcess() { | 207 void ImmediateShutdownAndExitProcess() { |
202 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); | 208 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); |
203 } | 209 } |
204 | 210 |
205 // static | 211 // static |
206 AudioManager* BrowserMainLoop::GetAudioManager() { | 212 AudioManager* BrowserMainLoop::GetAudioManager() { |
207 return g_current_browser_main_loop->audio_manager_.get(); | 213 return g_current_browser_main_loop->audio_manager_.get(); |
208 } | 214 } |
209 | 215 |
210 // BrowserMainLoop construction / destructione ============================= | 216 // BrowserMainLoop construction / destruction ============================= |
211 | 217 |
212 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) | 218 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) |
213 : parameters_(parameters), | 219 : parameters_(parameters), |
214 parsed_command_line_(parameters.command_line), | 220 parsed_command_line_(parameters.command_line), |
215 result_code_(content::RESULT_CODE_NORMAL_EXIT) { | 221 result_code_(content::RESULT_CODE_NORMAL_EXIT) { |
216 DCHECK(!g_current_browser_main_loop); | 222 DCHECK(!g_current_browser_main_loop); |
217 g_current_browser_main_loop = this; | 223 g_current_browser_main_loop = this; |
218 #if defined(OS_WIN) | 224 #if defined(OS_WIN) |
219 OleInitialize(NULL); | 225 OleInitialize(NULL); |
220 #endif | 226 #endif |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 582 |
577 // Register the main thread by instantiating it, but don't call any methods. | 583 // Register the main thread by instantiating it, but don't call any methods. |
578 main_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, | 584 main_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, |
579 MessageLoop::current())); | 585 MessageLoop::current())); |
580 } | 586 } |
581 | 587 |
582 | 588 |
583 void BrowserMainLoop::BrowserThreadsStarted() { | 589 void BrowserMainLoop::BrowserThreadsStarted() { |
584 // RDH needs the IO thread to be created. | 590 // RDH needs the IO thread to be created. |
585 resource_dispatcher_host_.reset(new ResourceDispatcherHost()); | 591 resource_dispatcher_host_.reset(new ResourceDispatcherHost()); |
| 592 |
| 593 #if defined(OS_LINUX) |
| 594 // MediaDeviceNotificationsLinux needs the File Thread. |
| 595 const FilePath kDefaultMtabPath("/etc/mtab"); |
| 596 media_device_notifications_linux_ = |
| 597 new MediaDeviceNotificationsLinux(kDefaultMtabPath); |
| 598 BrowserThread::PostTask( |
| 599 BrowserThread::FILE, FROM_HERE, |
| 600 base::Bind(&MediaDeviceNotificationsLinux::InitOnFileThread, |
| 601 media_device_notifications_linux_.get())); |
| 602 #endif |
586 } | 603 } |
587 | 604 |
588 void BrowserMainLoop::InitializeToolkit() { | 605 void BrowserMainLoop::InitializeToolkit() { |
589 // TODO(evan): this function is rather subtle, due to the variety | 606 // TODO(evan): this function is rather subtle, due to the variety |
590 // of intersecting ifdefs we have. To keep it easy to follow, there | 607 // of intersecting ifdefs we have. To keep it easy to follow, there |
591 // are no #else branches on any #ifs. | 608 // are no #else branches on any #ifs. |
592 // TODO(stevenjb): Move platform specific code into platform specific Parts | 609 // TODO(stevenjb): Move platform specific code into platform specific Parts |
593 // (Need to add InitializeToolkit stage to BrowserParts). | 610 // (Need to add InitializeToolkit stage to BrowserParts). |
594 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 611 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
595 // Glib type system initialization. Needed at least for gconf, | 612 // Glib type system initialization. Needed at least for gconf, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 651 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
635 | 652 |
636 #if defined(OS_MACOSX) | 653 #if defined(OS_MACOSX) |
637 MessageLoopForUI::current()->Run(); | 654 MessageLoopForUI::current()->Run(); |
638 #else | 655 #else |
639 MessageLoopForUI::current()->RunWithDispatcher(NULL); | 656 MessageLoopForUI::current()->RunWithDispatcher(NULL); |
640 #endif | 657 #endif |
641 } | 658 } |
642 | 659 |
643 } // namespace content | 660 } // namespace content |
OLD | NEW |