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

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

Issue 1170623003: Revert "content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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/location.h"
10 #include "base/logging.h" 9 #include "base/logging.h"
11 #include "base/memory/memory_pressure_monitor.h" 10 #include "base/memory/memory_pressure_monitor.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/pending_task.h" 14 #include "base/pending_task.h"
15 #include "base/power_monitor/power_monitor.h" 15 #include "base/power_monitor/power_monitor.h"
16 #include "base/power_monitor/power_monitor_device_source.h" 16 #include "base/power_monitor/power_monitor_device_source.h"
17 #include "base/process/process_metrics.h" 17 #include "base/process/process_metrics.h"
18 #include "base/profiler/scoped_profile.h" 18 #include "base/profiler/scoped_profile.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/single_thread_task_runner.h"
21 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_split.h" 21 #include "base/strings/string_split.h"
23 #include "base/system_monitor/system_monitor.h" 22 #include "base/system_monitor/system_monitor.h"
24 #include "base/thread_task_runner_handle.h" 23 #include "base/thread_task_runner_handle.h"
25 #include "base/threading/thread_restrictions.h" 24 #include "base/threading/thread_restrictions.h"
26 #include "base/timer/hi_res_timer_manager.h" 25 #include "base/timer/hi_res_timer_manager.h"
27 #include "base/trace_event/memory_dump_manager.h" 26 #include "base/trace_event/memory_dump_manager.h"
28 #include "base/trace_event/trace_event.h" 27 #include "base/trace_event/trace_event.h"
29 #include "content/browser/browser_thread_impl.h" 28 #include "content/browser/browser_thread_impl.h"
30 #include "content/browser/device_sensors/device_inertial_sensor_service.h" 29 #include "content/browser/device_sensors/device_inertial_sensor_service.h"
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 622 }
624 623
625 base::trace_event::MemoryDumpManager::GetInstance()->Initialize(); 624 base::trace_event::MemoryDumpManager::GetInstance()->Initialize();
626 625
627 // Enable the dump providers. 626 // Enable the dump providers.
628 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 627 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
629 HostSharedBitmapManager::current()); 628 HostSharedBitmapManager::current());
630 629
631 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) 630 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED)
632 trace_memory_controller_.reset(new base::trace_event::TraceMemoryController( 631 trace_memory_controller_.reset(new base::trace_event::TraceMemoryController(
633 base::MessageLoop::current()->task_runner(), 632 base::MessageLoop::current()->message_loop_proxy(),
634 ::HeapProfilerWithPseudoStackStart, ::HeapProfilerStop, 633 ::HeapProfilerWithPseudoStackStart, ::HeapProfilerStop,
635 ::GetHeapProfile)); 634 ::GetHeapProfile));
636 #endif 635 #endif
637 } 636 }
638 637
639 int BrowserMainLoop::PreCreateThreads() { 638 int BrowserMainLoop::PreCreateThreads() {
640 if (parts_) { 639 if (parts_) {
641 TRACE_EVENT0("startup", 640 TRACE_EVENT0("startup",
642 "BrowserMainLoop::CreateThreads:PreCreateThreads"); 641 "BrowserMainLoop::CreateThreads:PreCreateThreads");
643 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::PreCreateThreads"); 642 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::PreCreateThreads");
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 return result_code_; 707 return result_code_;
709 } 708 }
710 709
711 void BrowserMainLoop::CreateStartupTasks() { 710 void BrowserMainLoop::CreateStartupTasks() {
712 TRACE_EVENT0("startup", "BrowserMainLoop::CreateStartupTasks"); 711 TRACE_EVENT0("startup", "BrowserMainLoop::CreateStartupTasks");
713 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::CreateStartupTasks"); 712 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::CreateStartupTasks");
714 713
715 // First time through, we really want to create all the tasks 714 // First time through, we really want to create all the tasks
716 if (!startup_task_runner_.get()) { 715 if (!startup_task_runner_.get()) {
717 #if defined(OS_ANDROID) 716 #if defined(OS_ANDROID)
718 startup_task_runner_ = make_scoped_ptr( 717 startup_task_runner_ = make_scoped_ptr(new StartupTaskRunner(
719 new StartupTaskRunner(base::Bind(&BrowserStartupComplete), 718 base::Bind(&BrowserStartupComplete),
720 base::ThreadTaskRunnerHandle::Get())); 719 base::MessageLoop::current()->message_loop_proxy()));
721 #else 720 #else
722 startup_task_runner_ = make_scoped_ptr( 721 startup_task_runner_ = make_scoped_ptr(new StartupTaskRunner(
723 new StartupTaskRunner(base::Callback<void(int)>(), 722 base::Callback<void(int)>(),
724 base::ThreadTaskRunnerHandle::Get())); 723 base::MessageLoop::current()->message_loop_proxy()));
725 #endif 724 #endif
726 StartupTask pre_create_threads = 725 StartupTask pre_create_threads =
727 base::Bind(&BrowserMainLoop::PreCreateThreads, base::Unretained(this)); 726 base::Bind(&BrowserMainLoop::PreCreateThreads, base::Unretained(this));
728 startup_task_runner_->AddTask(pre_create_threads); 727 startup_task_runner_->AddTask(pre_create_threads);
729 728
730 StartupTask create_threads = 729 StartupTask create_threads =
731 base::Bind(&BrowserMainLoop::CreateThreads, base::Unretained(this)); 730 base::Bind(&BrowserMainLoop::CreateThreads, base::Unretained(this));
732 startup_task_runner_->AddTask(create_threads); 731 startup_task_runner_->AddTask(create_threads);
733 732
734 StartupTask browser_thread_started = base::Bind( 733 StartupTask browser_thread_started = base::Bind(
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 "BrowserMainLoop::BrowserThreadsStarted:InitSpeechRecognition"); 1200 "BrowserMainLoop::BrowserThreadsStarted:InitSpeechRecognition");
1202 speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl( 1201 speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl(
1203 audio_manager_.get(), media_stream_manager_.get())); 1202 audio_manager_.get(), media_stream_manager_.get()));
1204 } 1203 }
1205 1204
1206 { 1205 {
1207 TRACE_EVENT0( 1206 TRACE_EVENT0(
1208 "startup", 1207 "startup",
1209 "BrowserMainLoop::BrowserThreadsStarted::InitUserInputMonitor"); 1208 "BrowserMainLoop::BrowserThreadsStarted::InitUserInputMonitor");
1210 user_input_monitor_ = media::UserInputMonitor::Create( 1209 user_input_monitor_ = media::UserInputMonitor::Create(
1211 io_thread_->task_runner(), main_thread_->task_runner()); 1210 io_thread_->message_loop_proxy(), main_thread_->message_loop_proxy());
1212 } 1211 }
1213 1212
1214 { 1213 {
1215 TRACE_EVENT0("startup", 1214 TRACE_EVENT0("startup",
1216 "BrowserMainLoop::BrowserThreadsStarted::TimeZoneMonitor"); 1215 "BrowserMainLoop::BrowserThreadsStarted::TimeZoneMonitor");
1217 time_zone_monitor_ = TimeZoneMonitor::Create(); 1216 time_zone_monitor_ = TimeZoneMonitor::Create();
1218 } 1217 }
1219 1218
1220 // Alert the clipboard class to which threads are allowed to access the 1219 // Alert the clipboard class to which threads are allowed to access the
1221 // clipboard: 1220 // clipboard:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 return true; 1304 return true;
1306 } 1305 }
1307 1306
1308 void BrowserMainLoop::MainMessageLoopRun() { 1307 void BrowserMainLoop::MainMessageLoopRun() {
1309 #if defined(OS_ANDROID) 1308 #if defined(OS_ANDROID)
1310 // Android's main message loop is the Java message loop. 1309 // Android's main message loop is the Java message loop.
1311 NOTREACHED(); 1310 NOTREACHED();
1312 #else 1311 #else
1313 DCHECK(base::MessageLoopForUI::IsCurrent()); 1312 DCHECK(base::MessageLoopForUI::IsCurrent());
1314 if (parameters_.ui_task) { 1313 if (parameters_.ui_task) {
1315 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 1314 base::MessageLoopForUI::current()->PostTask(FROM_HERE,
1316 *parameters_.ui_task); 1315 *parameters_.ui_task);
1317 } 1316 }
1318 1317
1319 base::RunLoop run_loop; 1318 base::RunLoop run_loop;
1320 run_loop.Run(); 1319 run_loop.Run();
1321 #endif 1320 #endif
1322 } 1321 }
1323 1322
1324 base::FilePath BrowserMainLoop::GetStartupTraceFileName( 1323 base::FilePath BrowserMainLoop::GetStartupTraceFileName(
1325 const base::CommandLine& command_line) const { 1324 const base::CommandLine& command_line) const {
1326 base::FilePath trace_file = command_line.GetSwitchValuePath( 1325 base::FilePath trace_file = command_line.GetSwitchValuePath(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 DCHECK(is_tracing_startup_); 1367 DCHECK(is_tracing_startup_);
1369 1368
1370 is_tracing_startup_ = false; 1369 is_tracing_startup_ = false;
1371 TracingController::GetInstance()->DisableRecording( 1370 TracingController::GetInstance()->DisableRecording(
1372 TracingController::CreateFileSink( 1371 TracingController::CreateFileSink(
1373 startup_trace_file_, 1372 startup_trace_file_,
1374 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); 1373 base::Bind(OnStoppedStartupTracing, startup_trace_file_)));
1375 } 1374 }
1376 1375
1377 } // namespace content 1376 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698