Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: content/browser/browser_main_loop.cc

Issue 10662049: Move the device enumerate/open/close work to device thread from IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moved MediaStream to BrowserMainloop and addressed all the comments from Tommi and Magnus. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/string_number_conversions.h" 16 #include "base/string_number_conversions.h"
17 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
18 #include "content/browser/browser_thread_impl.h" 18 #include "content/browser/browser_thread_impl.h"
19 #include "content/browser/download/download_file_manager.h" 19 #include "content/browser/download/download_file_manager.h"
20 #include "content/browser/download/save_file_manager.h" 20 #include "content/browser/download/save_file_manager.h"
21 #include "content/browser/gamepad/gamepad_service.h" 21 #include "content/browser/gamepad/gamepad_service.h"
22 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 22 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
23 #include "content/browser/gpu/gpu_process_host.h" 23 #include "content/browser/gpu/gpu_process_host.h"
24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 24 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
25 #include "content/browser/in_process_webkit/webkit_thread.h" 25 #include "content/browser/in_process_webkit/webkit_thread.h"
26 #include "content/browser/net/browser_online_state_observer.h" 26 #include "content/browser/net/browser_online_state_observer.h"
27 #include "content/browser/plugin_service_impl.h" 27 #include "content/browser/plugin_service_impl.h"
28 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
29 #include "content/browser/renderer_host/media/media_stream_manager.h"
30 #include "content/browser/renderer_host/media/video_capture_manager.h"
28 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" 31 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
29 #include "content/browser/speech/speech_recognition_manager_impl.h" 32 #include "content/browser/speech/speech_recognition_manager_impl.h"
30 #include "content/browser/trace_controller_impl.h" 33 #include "content/browser/trace_controller_impl.h"
31 #include "content/public/browser/browser_main_parts.h" 34 #include "content/public/browser/browser_main_parts.h"
32 #include "content/public/browser/browser_shutdown.h" 35 #include "content/public/browser/browser_shutdown.h"
33 #include "content/public/browser/content_browser_client.h" 36 #include "content/public/browser/content_browser_client.h"
34 #include "content/public/browser/gpu_data_manager.h" 37 #include "content/public/browser/gpu_data_manager.h"
35 #include "content/public/browser/render_process_host.h" 38 #include "content/public/browser/render_process_host.h"
36 #include "content/public/common/content_switches.h" 39 #include "content/public/common/content_switches.h"
37 #include "content/public/common/main_function_params.h" 40 #include "content/public/common/main_function_params.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 206
204 void ImmediateShutdownAndExitProcess() { 207 void ImmediateShutdownAndExitProcess() {
205 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); 208 BrowserShutdownImpl::ImmediateShutdownAndExitProcess();
206 } 209 }
207 210
208 // static 211 // static
209 media::AudioManager* BrowserMainLoop::GetAudioManager() { 212 media::AudioManager* BrowserMainLoop::GetAudioManager() {
210 return g_current_browser_main_loop->audio_manager_.get(); 213 return g_current_browser_main_loop->audio_manager_.get();
211 } 214 }
212 215
216 // static
217 media_stream::MediaStreamManager* BrowserMainLoop::GetMediaStreamManager() {
218 return g_current_browser_main_loop->media_stream_manager_.get();
219 }
213 // BrowserMainLoop construction / destruction ============================= 220 // BrowserMainLoop construction / destruction =============================
214 221
215 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) 222 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters)
216 : parameters_(parameters), 223 : parameters_(parameters),
217 parsed_command_line_(parameters.command_line), 224 parsed_command_line_(parameters.command_line),
218 result_code_(content::RESULT_CODE_NORMAL_EXIT) { 225 result_code_(content::RESULT_CODE_NORMAL_EXIT) {
219 DCHECK(!g_current_browser_main_loop); 226 DCHECK(!g_current_browser_main_loop);
220 g_current_browser_main_loop = this; 227 g_current_browser_main_loop = this;
221 } 228 }
222 229
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 if (base::debug::TraceLog::GetInstance()->IsEnabled()) { 325 if (base::debug::TraceLog::GetInstance()->IsEnabled()) {
319 TraceControllerImpl::GetInstance()->InitStartupTracing( 326 TraceControllerImpl::GetInstance()->InitStartupTracing(
320 parsed_command_line_); 327 parsed_command_line_);
321 } 328 }
322 329
323 system_monitor_.reset(new base::SystemMonitor); 330 system_monitor_.reset(new base::SystemMonitor);
324 hi_res_timer_manager_.reset(new HighResolutionTimerManager); 331 hi_res_timer_manager_.reset(new HighResolutionTimerManager);
325 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); 332 network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
326 audio_manager_.reset(media::AudioManager::Create()); 333 audio_manager_.reset(media::AudioManager::Create());
327 online_state_observer_.reset(new BrowserOnlineStateObserver); 334 online_state_observer_.reset(new BrowserOnlineStateObserver);
335 scoped_refptr<media_stream::AudioInputDeviceManager>
336 audio_input_device_manager(
337 new media_stream::AudioInputDeviceManager(audio_manager_.get()));
338 scoped_refptr<media_stream::VideoCaptureManager> video_capture_manager(
339 new media_stream::VideoCaptureManager());
340 media_stream_manager_.reset(new media_stream::MediaStreamManager(
341 audio_input_device_manager, video_capture_manager));
328 342
329 #if defined(OS_WIN) 343 #if defined(OS_WIN)
330 system_message_window_.reset(new SystemMessageWindowWin); 344 system_message_window_.reset(new SystemMessageWindowWin);
331 #endif 345 #endif
332 346
333 // Prior to any processing happening on the io thread, we create the 347 // Prior to any processing happening on the io thread, we create the
334 // plugin service as it is predominantly used from the io thread, 348 // plugin service as it is predominantly used from the io thread,
335 // but must be created on the main thread. The service ctor is 349 // but must be created on the main thread. The service ctor is
336 // inexpensive and does not invoke the io_thread() accessor. 350 // inexpensive and does not invoke the io_thread() accessor.
337 PluginService::GetInstance()->Init(); 351 PluginService::GetInstance()->Init();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 // stopping the GPU thread. The GPU thread will close IPC channels to renderer 477 // stopping the GPU thread. The GPU thread will close IPC channels to renderer
464 // processes so this has to happen before stopping the IO thread. 478 // processes so this has to happen before stopping the IO thread.
465 GpuProcessHostUIShim::DestroyAll(); 479 GpuProcessHostUIShim::DestroyAll();
466 480
467 // Cancel pending requests and prevent new requests. 481 // Cancel pending requests and prevent new requests.
468 if (resource_dispatcher_host_.get()) 482 if (resource_dispatcher_host_.get())
469 resource_dispatcher_host_.get()->Shutdown(); 483 resource_dispatcher_host_.get()->Shutdown();
470 484
471 speech_recognition_manager_.reset(); 485 speech_recognition_manager_.reset();
472 486
487 BrowserThread::DeleteOnIOThread::Destruct(media_stream_manager_.release());
tommi (sloooow) - chröme 2012/07/04 13:46:48 maybe add a little comment here to explain why we
no longer working on chromium 2012/07/04 14:31:39 Done.
488
473 #if defined(USE_AURA) 489 #if defined(USE_AURA)
474 ImageTransportFactory::Terminate(); 490 ImageTransportFactory::Terminate();
475 #endif 491 #endif
476 BrowserGpuChannelHostFactory::Terminate(); 492 BrowserGpuChannelHostFactory::Terminate();
477 493
478 GamepadService::GetInstance()->Terminate(); 494 GamepadService::GetInstance()->Terminate();
479 495
480 // Must be size_t so we can subtract from it. 496 // Must be size_t so we can subtract from it.
481 for (size_t thread_id = BrowserThread::ID_COUNT - 1; 497 for (size_t thread_id = BrowserThread::ID_COUNT - 1;
482 thread_id >= (BrowserThread::UI + 1); 498 thread_id >= (BrowserThread::UI + 1);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); 658 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type());
643 if (parameters_.ui_task) 659 if (parameters_.ui_task)
644 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); 660 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task);
645 661
646 base::RunLoop run_loop; 662 base::RunLoop run_loop;
647 run_loop.Run(); 663 run_loop.Run();
648 #endif 664 #endif
649 } 665 }
650 666
651 } // namespace content 667 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698