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

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

Issue 17508005: Minor cleanup to remove the static thread-safe methods on BrowserMainLoop. Initially I thought this… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: nits Created 7 years, 6 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"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 size_t private_bytes; 269 size_t private_bytes;
270 process_metrics->GetMemoryBytes(&private_bytes, NULL); 270 process_metrics->GetMemoryBytes(&private_bytes, NULL);
271 HISTOGRAM_MEMORY_KB("Memory.BrowserUsed", private_bytes >> 10); 271 HISTOGRAM_MEMORY_KB("Memory.BrowserUsed", private_bytes >> 10);
272 #endif 272 #endif
273 } 273 }
274 private: 274 private:
275 DISALLOW_COPY_AND_ASSIGN(MemoryObserver); 275 DISALLOW_COPY_AND_ASSIGN(MemoryObserver);
276 }; 276 };
277 277
278 278
279 // static 279 // BrowserMainLoop construction / destruction =============================
280 media::AudioManager* BrowserMainLoop::GetAudioManager() { 280
281 return g_current_browser_main_loop->audio_manager_.get(); 281 BrowserMainLoop* BrowserMainLoop::GetInstance() {
282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
283 return g_current_browser_main_loop;
282 } 284 }
283 285
284 // static
285 AudioMirroringManager* BrowserMainLoop::GetAudioMirroringManager() {
286 return g_current_browser_main_loop->audio_mirroring_manager_.get();
287 }
288
289 // static
290 MediaStreamManager* BrowserMainLoop::GetMediaStreamManager() {
291 return g_current_browser_main_loop->media_stream_manager_.get();
292 }
293 // BrowserMainLoop construction / destruction =============================
294
295 BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters) 286 BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters)
296 : parameters_(parameters), 287 : parameters_(parameters),
297 parsed_command_line_(parameters.command_line), 288 parsed_command_line_(parameters.command_line),
298 result_code_(RESULT_CODE_NORMAL_EXIT) { 289 result_code_(RESULT_CODE_NORMAL_EXIT) {
299 DCHECK(!g_current_browser_main_loop); 290 DCHECK(!g_current_browser_main_loop);
300 g_current_browser_main_loop = this; 291 g_current_browser_main_loop = this;
301 } 292 }
302 293
303 BrowserMainLoop::~BrowserMainLoop() { 294 BrowserMainLoop::~BrowserMainLoop() {
304 DCHECK_EQ(this, g_current_browser_main_loop); 295 DCHECK_EQ(this, g_current_browser_main_loop);
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); 812 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
822 } 813 }
823 814
824 // Initialize the GpuDataManager before we set up the MessageLoops because 815 // Initialize the GpuDataManager before we set up the MessageLoops because
825 // otherwise we'll trigger the assertion about doing IO on the UI thread. 816 // otherwise we'll trigger the assertion about doing IO on the UI thread.
826 GpuDataManagerImpl::GetInstance()->Initialize(); 817 GpuDataManagerImpl::GetInstance()->Initialize();
827 818
828 { 819 {
829 TRACE_EVENT0("startup", 820 TRACE_EVENT0("startup",
830 "BrowserMainLoop::BrowserThreadsStarted:InitSpeechRecognition"); 821 "BrowserMainLoop::BrowserThreadsStarted:InitSpeechRecognition");
831 speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl()); 822 speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl(
823 audio_manager_.get(), media_stream_manager_.get()));
832 } 824 }
833 825
834 // Alert the clipboard class to which threads are allowed to access the 826 // Alert the clipboard class to which threads are allowed to access the
835 // clipboard: 827 // clipboard:
836 std::vector<base::PlatformThreadId> allowed_clipboard_threads; 828 std::vector<base::PlatformThreadId> allowed_clipboard_threads;
837 // The current thread is the UI thread. 829 // The current thread is the UI thread.
838 allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId()); 830 allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId());
839 #if defined(OS_WIN) 831 #if defined(OS_WIN)
840 // On Windows, clipboards are also used on the File or IO threads. 832 // On Windows, clipboards are also used on the File or IO threads.
841 allowed_clipboard_threads.push_back(file_thread_->thread_id()); 833 allowed_clipboard_threads.push_back(file_thread_->thread_id());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 if (parameters_.ui_task) 909 if (parameters_.ui_task)
918 base::MessageLoopForUI::current()->PostTask(FROM_HERE, 910 base::MessageLoopForUI::current()->PostTask(FROM_HERE,
919 *parameters_.ui_task); 911 *parameters_.ui_task);
920 912
921 base::RunLoop run_loop; 913 base::RunLoop run_loop;
922 run_loop.Run(); 914 run_loop.Run();
923 #endif 915 #endif
924 } 916 }
925 917
926 } // namespace content 918 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698