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

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

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

Powered by Google App Engine
This is Rietveld 408576698