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 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 | |
63 #if defined(OS_MACOSX) | |
64 #include "content/browser/mac/media_device_notifications.h" | |
65 #endif | |
66 | |
57 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 67 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
58 #include <glib-object.h> | 68 #include <glib-object.h> |
59 #endif | 69 #endif |
60 | 70 |
61 #if defined(OS_CHROMEOS) | 71 #if defined(OS_CHROMEOS) |
62 #include <dbus/dbus-glib.h> | 72 #include <dbus/dbus-glib.h> |
63 #endif | 73 #endif |
64 | 74 |
65 #if defined(TOOLKIT_USES_GTK) | 75 #if defined(TOOLKIT_USES_GTK) |
66 #include "ui/gfx/gtk_util.h" | 76 #include "ui/gfx/gtk_util.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 | 207 |
198 void ImmediateShutdownAndExitProcess() { | 208 void ImmediateShutdownAndExitProcess() { |
199 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); | 209 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); |
200 } | 210 } |
201 | 211 |
202 // static | 212 // static |
203 AudioManager* BrowserMainLoop::GetAudioManager() { | 213 AudioManager* BrowserMainLoop::GetAudioManager() { |
204 return g_current_browser_main_loop->audio_manager_.get(); | 214 return g_current_browser_main_loop->audio_manager_.get(); |
205 } | 215 } |
206 | 216 |
207 // BrowserMainLoop construction / destructione ============================= | 217 // BrowserMainLoop construction / destruction ============================= |
208 | 218 |
209 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) | 219 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) |
210 : parameters_(parameters), | 220 : parameters_(parameters), |
211 parsed_command_line_(parameters.command_line), | 221 parsed_command_line_(parameters.command_line), |
212 result_code_(content::RESULT_CODE_NORMAL_EXIT) { | 222 result_code_(content::RESULT_CODE_NORMAL_EXIT) { |
213 DCHECK(!g_current_browser_main_loop); | 223 DCHECK(!g_current_browser_main_loop); |
214 g_current_browser_main_loop = this; | 224 g_current_browser_main_loop = this; |
215 #if defined(OS_WIN) | 225 #if defined(OS_WIN) |
216 OleInitialize(NULL); | 226 OleInitialize(NULL); |
217 #endif | 227 #endif |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 TraceController::GetInstance()->InitStartupTracing(parsed_command_line_); | 332 TraceController::GetInstance()->InitStartupTracing(parsed_command_line_); |
323 | 333 |
324 system_monitor_.reset(new base::SystemMonitor); | 334 system_monitor_.reset(new base::SystemMonitor); |
325 hi_res_timer_manager_.reset(new HighResolutionTimerManager); | 335 hi_res_timer_manager_.reset(new HighResolutionTimerManager); |
326 | 336 |
327 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 337 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
328 audio_manager_.reset(AudioManager::Create()); | 338 audio_manager_.reset(AudioManager::Create()); |
329 | 339 |
330 #if defined(OS_WIN) | 340 #if defined(OS_WIN) |
331 system_message_window_.reset(new SystemMessageWindowWin); | 341 system_message_window_.reset(new SystemMessageWindowWin); |
342 #elif defined(OS_MACOSX) | |
343 StartMediaDeviceNotifications(); | |
332 #endif | 344 #endif |
333 | 345 |
334 // Prior to any processing happening on the io thread, we create the | 346 // Prior to any processing happening on the io thread, we create the |
335 // plugin service as it is predominantly used from the io thread, | 347 // plugin service as it is predominantly used from the io thread, |
336 // but must be created on the main thread. The service ctor is | 348 // but must be created on the main thread. The service ctor is |
337 // inexpensive and does not invoke the io_thread() accessor. | 349 // inexpensive and does not invoke the io_thread() accessor. |
338 PluginService::GetInstance()->Init(); | 350 PluginService::GetInstance()->Init(); |
339 | 351 |
340 if (parts_.get()) | 352 if (parts_.get()) |
341 parts_->PostMainMessageLoopStart(); | 353 parts_->PostMainMessageLoopStart(); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 | 592 |
581 // Register the main thread by instantiating it, but don't call any methods. | 593 // Register the main thread by instantiating it, but don't call any methods. |
582 main_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, | 594 main_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, |
583 MessageLoop::current())); | 595 MessageLoop::current())); |
584 } | 596 } |
585 | 597 |
586 | 598 |
587 void BrowserMainLoop::BrowserThreadsStarted() { | 599 void BrowserMainLoop::BrowserThreadsStarted() { |
588 // RDH needs the IO thread to be created. | 600 // RDH needs the IO thread to be created. |
589 resource_dispatcher_host_.reset(new ResourceDispatcherHost()); | 601 resource_dispatcher_host_.reset(new ResourceDispatcherHost()); |
602 | |
603 #if defined(OS_LINUX) | |
604 // MediaDeviceNotificationsLinux needs the File Thread. | |
605 const FilePath kDefaultMtabPath("/etc/mtab"); | |
vandebo (ex-Chrome)
2012/03/06 00:41:40
Random thought - does this work on CrOS? It shoul
Lei Zhang
2012/03/06 19:00:25
It should based on our observations on a Chromeboo
| |
606 media_device_notifications_linux_ = | |
607 new MediaDeviceNotificationsLinux(kDefaultMtabPath); | |
608 BrowserThread::PostTask( | |
609 BrowserThread::FILE, FROM_HERE, | |
610 base::Bind(&MediaDeviceNotificationsLinux::InitOnFileThread, | |
611 media_device_notifications_linux_.get())); | |
612 #endif | |
590 } | 613 } |
591 | 614 |
592 void BrowserMainLoop::InitializeToolkit() { | 615 void BrowserMainLoop::InitializeToolkit() { |
593 // TODO(evan): this function is rather subtle, due to the variety | 616 // TODO(evan): this function is rather subtle, due to the variety |
594 // of intersecting ifdefs we have. To keep it easy to follow, there | 617 // of intersecting ifdefs we have. To keep it easy to follow, there |
595 // are no #else branches on any #ifs. | 618 // are no #else branches on any #ifs. |
596 // TODO(stevenjb): Move platform specific code into platform specific Parts | 619 // TODO(stevenjb): Move platform specific code into platform specific Parts |
597 // (Need to add InitializeToolkit stage to BrowserParts). | 620 // (Need to add InitializeToolkit stage to BrowserParts). |
598 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 621 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
599 // Glib type system initialization. Needed at least for gconf, | 622 // 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); | 661 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
639 | 662 |
640 #if defined(OS_MACOSX) | 663 #if defined(OS_MACOSX) |
641 MessageLoopForUI::current()->Run(); | 664 MessageLoopForUI::current()->Run(); |
642 #else | 665 #else |
643 MessageLoopForUI::current()->RunWithDispatcher(NULL); | 666 MessageLoopForUI::current()->RunWithDispatcher(NULL); |
644 #endif | 667 #endif |
645 } | 668 } |
646 | 669 |
647 } // namespace content | 670 } // namespace content |
OLD | NEW |