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

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

Issue 9433006: Remove GetAudioManager and GetMediaStreamManager from ResourceContext. The reason is the content mo… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 8 years, 10 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
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/mock_resource_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/logging.h" 10 #include "base/logging.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/common/hi_res_timer_manager.h" 25 #include "content/common/hi_res_timer_manager.h"
26 #include "content/common/sandbox_policy.h" 26 #include "content/common/sandbox_policy.h"
27 #include "content/public/browser/browser_main_parts.h" 27 #include "content/public/browser/browser_main_parts.h"
28 #include "content/public/browser/browser_shutdown.h" 28 #include "content/public/browser/browser_shutdown.h"
29 #include "content/public/browser/content_browser_client.h" 29 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/browser/render_process_host.h" 30 #include "content/public/browser/render_process_host.h"
31 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
32 #include "content/public/common/main_function_params.h" 32 #include "content/public/common/main_function_params.h"
33 #include "content/public/common/result_codes.h" 33 #include "content/public/common/result_codes.h"
34 #include "crypto/nss_util.h" 34 #include "crypto/nss_util.h"
35 #include "media/audio/audio_manager.h"
35 #include "net/base/network_change_notifier.h" 36 #include "net/base/network_change_notifier.h"
36 #include "net/base/ssl_config_service.h" 37 #include "net/base/ssl_config_service.h"
37 #include "net/socket/client_socket_factory.h" 38 #include "net/socket/client_socket_factory.h"
38 #include "net/socket/tcp_client_socket.h" 39 #include "net/socket/tcp_client_socket.h"
39 40
40 #if defined(OS_WIN) 41 #if defined(OS_WIN)
41 #include <windows.h> 42 #include <windows.h>
42 #include <commctrl.h> 43 #include <commctrl.h>
43 #include <ole2.h> 44 #include <ole2.h>
44 #include <shellapi.h> 45 #include <shellapi.h>
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 NULL); 163 NULL);
163 } 164 }
164 } 165 }
165 #endif 166 #endif
166 167
167 } // namespace 168 } // namespace
168 169
169 namespace content { 170 namespace content {
170 171
171 // The currently-running BrowserMainLoop. There can be one or zero. 172 // The currently-running BrowserMainLoop. There can be one or zero.
172 // This is stored to enable immediate shutdown when needed. 173 BrowserMainLoop* g_current_browser_main_loop = NULL;
173 BrowserMainLoop* current_browser_main_loop = NULL;
174 174
175 // This is just to be able to keep ShutdownThreadsAndCleanUp out of 175 // This is just to be able to keep ShutdownThreadsAndCleanUp out of
176 // the public interface of BrowserMainLoop. 176 // the public interface of BrowserMainLoop.
177 class BrowserShutdownImpl { 177 class BrowserShutdownImpl {
178 public: 178 public:
179 static void ImmediateShutdownAndExitProcess() { 179 static void ImmediateShutdownAndExitProcess() {
180 DCHECK(current_browser_main_loop); 180 DCHECK(g_current_browser_main_loop);
181 current_browser_main_loop->ShutdownThreadsAndCleanUp(); 181 g_current_browser_main_loop->ShutdownThreadsAndCleanUp();
182 182
183 #if defined(OS_WIN) 183 #if defined(OS_WIN)
184 // At this point the message loop is still running yet we've shut everything 184 // At this point the message loop is still running yet we've shut everything
185 // down. If any messages are processed we'll likely crash. Exit now. 185 // down. If any messages are processed we'll likely crash. Exit now.
186 ExitProcess(content::RESULT_CODE_NORMAL_EXIT); 186 ExitProcess(content::RESULT_CODE_NORMAL_EXIT);
187 #elif defined(OS_POSIX) && !defined(OS_MACOSX) 187 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
188 _exit(content::RESULT_CODE_NORMAL_EXIT); 188 _exit(content::RESULT_CODE_NORMAL_EXIT);
189 #else 189 #else
190 NOTIMPLEMENTED(); 190 NOTIMPLEMENTED();
191 #endif 191 #endif
192 } 192 }
193 }; 193 };
194 194
195 void ImmediateShutdownAndExitProcess() { 195 void ImmediateShutdownAndExitProcess() {
196 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); 196 BrowserShutdownImpl::ImmediateShutdownAndExitProcess();
197 } 197 }
198 198
199 // static
200 AudioManager* BrowserMainLoop::GetAudioManager() {
201 return g_current_browser_main_loop->audio_manager_.get();
202 }
203
199 // BrowserMainLoop construction / destructione ============================= 204 // BrowserMainLoop construction / destructione =============================
200 205
201 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) 206 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters)
202 : parameters_(parameters), 207 : parameters_(parameters),
203 parsed_command_line_(parameters.command_line), 208 parsed_command_line_(parameters.command_line),
204 result_code_(content::RESULT_CODE_NORMAL_EXIT) { 209 result_code_(content::RESULT_CODE_NORMAL_EXIT) {
205 DCHECK(!current_browser_main_loop); 210 DCHECK(!g_current_browser_main_loop);
206 current_browser_main_loop = this; 211 g_current_browser_main_loop = this;
207 #if defined(OS_WIN) 212 #if defined(OS_WIN)
208 OleInitialize(NULL); 213 OleInitialize(NULL);
209 #endif 214 #endif
210 } 215 }
211 216
212 BrowserMainLoop::~BrowserMainLoop() { 217 BrowserMainLoop::~BrowserMainLoop() {
213 DCHECK_EQ(this, current_browser_main_loop); 218 DCHECK_EQ(this, g_current_browser_main_loop);
214 current_browser_main_loop = NULL; 219 g_current_browser_main_loop = NULL;
215 #if defined(OS_WIN) 220 #if defined(OS_WIN)
216 OleUninitialize(); 221 OleUninitialize();
217 #endif 222 #endif
218 } 223 }
219 224
220 void BrowserMainLoop::Init() { 225 void BrowserMainLoop::Init() {
221 parts_.reset( 226 parts_.reset(
222 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); 227 GetContentClient()->browser()->CreateBrowserMainParts(parameters_));
223 } 228 }
224 229
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 InitializeMainThread(); 314 InitializeMainThread();
310 315
311 // Start tracing to a file if needed. 316 // Start tracing to a file if needed.
312 if (base::debug::TraceLog::GetInstance()->IsEnabled()) 317 if (base::debug::TraceLog::GetInstance()->IsEnabled())
313 TraceController::GetInstance()->InitStartupTracing(parsed_command_line_); 318 TraceController::GetInstance()->InitStartupTracing(parsed_command_line_);
314 319
315 system_monitor_.reset(new base::SystemMonitor); 320 system_monitor_.reset(new base::SystemMonitor);
316 hi_res_timer_manager_.reset(new HighResolutionTimerManager); 321 hi_res_timer_manager_.reset(new HighResolutionTimerManager);
317 322
318 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); 323 network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
324 audio_manager_.reset(AudioManager::Create());
319 325
320 #if defined(OS_WIN) 326 #if defined(OS_WIN)
321 system_message_window_.reset(new SystemMessageWindowWin); 327 system_message_window_.reset(new SystemMessageWindowWin);
322 #endif 328 #endif
323 329
324 // Prior to any processing happening on the io thread, we create the 330 // Prior to any processing happening on the io thread, we create the
325 // plugin service as it is predominantly used from the io thread, 331 // plugin service as it is predominantly used from the io thread,
326 // but must be created on the main thread. The service ctor is 332 // but must be created on the main thread. The service ctor is
327 // inexpensive and does not invoke the io_thread() accessor. 333 // inexpensive and does not invoke the io_thread() accessor.
328 PluginService::GetInstance()->Init(); 334 PluginService::GetInstance()->Init();
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); 620 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task);
615 621
616 #if defined(OS_MACOSX) 622 #if defined(OS_MACOSX)
617 MessageLoopForUI::current()->Run(); 623 MessageLoopForUI::current()->Run();
618 #else 624 #else
619 MessageLoopForUI::current()->RunWithDispatcher(NULL); 625 MessageLoopForUI::current()->RunWithDispatcher(NULL);
620 #endif 626 #endif
621 } 627 }
622 628
623 } // namespace content 629 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/mock_resource_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698