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 "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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 | 217 |
| 218 // static | 218 // static |
| 219 media::AudioManager* BrowserMainLoop::GetAudioManager() { | 219 media::AudioManager* BrowserMainLoop::GetAudioManager() { |
| 220 return g_current_browser_main_loop->audio_manager_.get(); | 220 return g_current_browser_main_loop->audio_manager_.get(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 // static | 223 // static |
| 224 media_stream::MediaStreamManager* BrowserMainLoop::GetMediaStreamManager() { | 224 media_stream::MediaStreamManager* BrowserMainLoop::GetMediaStreamManager() { |
| 225 return g_current_browser_main_loop->media_stream_manager_.get(); | 225 return g_current_browser_main_loop->media_stream_manager_.get(); |
| 226 } | 226 } |
| 227 | |
| 228 // static | |
| 229 void BrowserMainLoop::UseFakeMediaStreamDevice() { | |
| 230 // Configure the manager once it gets created. | |
| 231 BrowserMainLoop::use_fake_media_stream_device_ = true; | |
|
jam
2012/09/04 15:18:14
nit: BrowserMainLoop:: is unnecessary
phoglund_chromium
2012/09/05 11:43:54
Done.
| |
| 232 } | |
| 233 | |
| 234 bool BrowserMainLoop::use_fake_media_stream_device_ = false; | |
| 235 | |
| 227 // BrowserMainLoop construction / destruction ============================= | 236 // BrowserMainLoop construction / destruction ============================= |
| 228 | 237 |
| 229 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) | 238 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) |
| 230 : parameters_(parameters), | 239 : parameters_(parameters), |
| 231 parsed_command_line_(parameters.command_line), | 240 parsed_command_line_(parameters.command_line), |
| 232 result_code_(content::RESULT_CODE_NORMAL_EXIT) { | 241 result_code_(content::RESULT_CODE_NORMAL_EXIT){ |
| 233 DCHECK(!g_current_browser_main_loop); | 242 DCHECK(!g_current_browser_main_loop); |
| 234 g_current_browser_main_loop = this; | 243 g_current_browser_main_loop = this; |
| 235 } | 244 } |
| 236 | 245 |
| 237 BrowserMainLoop::~BrowserMainLoop() { | 246 BrowserMainLoop::~BrowserMainLoop() { |
| 238 DCHECK_EQ(this, g_current_browser_main_loop); | 247 DCHECK_EQ(this, g_current_browser_main_loop); |
| 239 g_current_browser_main_loop = NULL; | 248 g_current_browser_main_loop = NULL; |
| 240 } | 249 } |
| 241 | 250 |
| 242 void BrowserMainLoop::Init() { | 251 void BrowserMainLoop::Init() { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 | 470 |
| 462 // If the UI thread blocks, the whole UI is unresponsive. | 471 // If the UI thread blocks, the whole UI is unresponsive. |
| 463 // Do not allow disk IO from the UI thread. | 472 // Do not allow disk IO from the UI thread. |
| 464 base::ThreadRestrictions::SetIOAllowed(false); | 473 base::ThreadRestrictions::SetIOAllowed(false); |
| 465 base::ThreadRestrictions::DisallowWaiting(); | 474 base::ThreadRestrictions::DisallowWaiting(); |
| 466 } | 475 } |
| 467 | 476 |
| 468 void BrowserMainLoop::RunMainMessageLoopParts() { | 477 void BrowserMainLoop::RunMainMessageLoopParts() { |
| 469 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); | 478 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); |
| 470 | 479 |
| 480 if (use_fake_media_stream_device_) | |
|
jam
2012/09/04 15:18:14
actually, it seems that this static better belongs
phoglund_chromium
2012/09/05 11:43:54
Good point, I'll move it.
| |
| 481 media_stream_manager_->UseFakeDevice(); | |
| 482 | |
| 471 bool ran_main_loop = false; | 483 bool ran_main_loop = false; |
| 472 if (parts_.get()) | 484 if (parts_.get()) |
| 473 ran_main_loop = parts_->MainMessageLoopRun(&result_code_); | 485 ran_main_loop = parts_->MainMessageLoopRun(&result_code_); |
| 474 | 486 |
| 475 if (!ran_main_loop) | 487 if (!ran_main_loop) |
| 476 MainMessageLoopRun(); | 488 MainMessageLoopRun(); |
| 477 | 489 |
| 478 TRACE_EVENT_END_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); | 490 TRACE_EVENT_END_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); |
| 479 } | 491 } |
| 480 | 492 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 708 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
| 697 if (parameters_.ui_task) | 709 if (parameters_.ui_task) |
| 698 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 710 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
| 699 | 711 |
| 700 base::RunLoop run_loop; | 712 base::RunLoop run_loop; |
| 701 run_loop.Run(); | 713 run_loop.Run(); |
| 702 #endif | 714 #endif |
| 703 } | 715 } |
| 704 | 716 |
| 705 } // namespace content | 717 } // namespace content |
| OLD | NEW |