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/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 #if !defined(OS_IOS) | 576 #if !defined(OS_IOS) |
577 // Start tracing to a file if needed. Only do this after starting the main | 577 // Start tracing to a file if needed. Only do this after starting the main |
578 // message loop to avoid calling MessagePumpForUI::ScheduleWork() before | 578 // message loop to avoid calling MessagePumpForUI::ScheduleWork() before |
579 // MessagePumpForUI::Start() as it will crash the browser. | 579 // MessagePumpForUI::Start() as it will crash the browser. |
580 if (is_tracing_startup_) { | 580 if (is_tracing_startup_) { |
581 TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracing"); | 581 TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracing"); |
582 InitStartupTracing(parsed_command_line_); | 582 InitStartupTracing(parsed_command_line_); |
583 } | 583 } |
584 #endif // !defined(OS_IOS) | 584 #endif // !defined(OS_IOS) |
585 | 585 |
586 #if defined(OS_ANDROID) | 586 #if defined(OS_ANDROID) && !defined(USE_AURA) |
587 { | 587 { |
588 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SurfaceTextureManager"); | 588 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SurfaceTextureManager"); |
no sievers
2015/10/20 19:24:22
keep this
| |
589 if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) { | 589 if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) { |
590 SurfaceTextureManager::SetInstance( | 590 SurfaceTextureManager::SetInstance( |
591 InProcessSurfaceTextureManager::GetInstance()); | 591 InProcessSurfaceTextureManager::GetInstance()); |
592 } else { | 592 } else { |
593 SurfaceTextureManager::SetInstance( | 593 SurfaceTextureManager::SetInstance( |
594 BrowserSurfaceTextureManager::GetInstance()); | 594 BrowserSurfaceTextureManager::GetInstance()); |
595 } | 595 } |
596 } | 596 } |
597 | 597 |
598 if (!parsed_command_line_.HasSwitch( | 598 if (!parsed_command_line_.HasSwitch( |
599 switches::kDisableScreenOrientationLock)) { | 599 switches::kDisableScreenOrientationLock)) { |
no sievers
2015/10/20 19:24:22
and this w/TODO at least
| |
600 TRACE_EVENT0("startup", | 600 TRACE_EVENT0("startup", |
601 "BrowserMainLoop::Subsystem:ScreenOrientationProvider"); | 601 "BrowserMainLoop::Subsystem:ScreenOrientationProvider"); |
602 screen_orientation_delegate_.reset( | 602 screen_orientation_delegate_.reset( |
603 new ScreenOrientationDelegateAndroid()); | 603 new ScreenOrientationDelegateAndroid()); |
604 ScreenOrientationProvider::SetDelegate(screen_orientation_delegate_.get()); | 604 ScreenOrientationProvider::SetDelegate(screen_orientation_delegate_.get()); |
605 } | 605 } |
606 #endif | 606 #endif |
607 | 607 |
608 #if defined(OS_MACOSX) && !defined(OS_IOS) | 608 #if defined(OS_MACOSX) && !defined(OS_IOS) |
609 { | 609 { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 startup_task_runner_->AddTask(create_threads); | 736 startup_task_runner_->AddTask(create_threads); |
737 | 737 |
738 StartupTask browser_thread_started = base::Bind( | 738 StartupTask browser_thread_started = base::Bind( |
739 &BrowserMainLoop::BrowserThreadsStarted, base::Unretained(this)); | 739 &BrowserMainLoop::BrowserThreadsStarted, base::Unretained(this)); |
740 startup_task_runner_->AddTask(browser_thread_started); | 740 startup_task_runner_->AddTask(browser_thread_started); |
741 | 741 |
742 StartupTask pre_main_message_loop_run = base::Bind( | 742 StartupTask pre_main_message_loop_run = base::Bind( |
743 &BrowserMainLoop::PreMainMessageLoopRun, base::Unretained(this)); | 743 &BrowserMainLoop::PreMainMessageLoopRun, base::Unretained(this)); |
744 startup_task_runner_->AddTask(pre_main_message_loop_run); | 744 startup_task_runner_->AddTask(pre_main_message_loop_run); |
745 | 745 |
746 #if defined(OS_ANDROID) | 746 #if defined(OS_ANDROID)// && !defined(USE_AURA) |
747 if (BrowserMayStartAsynchronously()) { | 747 if (BrowserMayStartAsynchronously()) { |
748 startup_task_runner_->StartRunningTasksAsync(); | 748 startup_task_runner_->StartRunningTasksAsync(); |
749 } | 749 } |
750 #endif | 750 #endif |
751 } | 751 } |
752 #if defined(OS_ANDROID) | 752 #if defined(OS_ANDROID)// && !defined(USE_AURA) |
753 if (!BrowserMayStartAsynchronously()) { | 753 if (!BrowserMayStartAsynchronously()) { |
754 // A second request for asynchronous startup can be ignored, so | 754 // A second request for asynchronous startup can be ignored, so |
755 // StartupRunningTasksAsync is only called first time through. If, however, | 755 // StartupRunningTasksAsync is only called first time through. If, however, |
756 // this is a request for synchronous startup then it must override any | 756 // this is a request for synchronous startup then it must override any |
757 // previous call for async startup, so we call RunAllTasksNow() | 757 // previous call for async startup, so we call RunAllTasksNow() |
758 // unconditionally. | 758 // unconditionally. |
759 startup_task_runner_->RunAllTasksNow(); | 759 startup_task_runner_->RunAllTasksNow(); |
760 } | 760 } |
761 #else | 761 #else |
762 startup_task_runner_->RunAllTasksNow(); | 762 startup_task_runner_->RunAllTasksNow(); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1121 #if !defined(OS_IOS) | 1121 #if !defined(OS_IOS) |
1122 HistogramSynchronizer::GetInstance(); | 1122 HistogramSynchronizer::GetInstance(); |
1123 | 1123 |
1124 #if defined(OS_ANDROID) | 1124 #if defined(OS_ANDROID) |
1125 // Up the priority of the UI thread. | 1125 // Up the priority of the UI thread. |
1126 base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY); | 1126 base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY); |
1127 #endif | 1127 #endif |
1128 | 1128 |
1129 bool always_uses_gpu = true; | 1129 bool always_uses_gpu = true; |
1130 bool established_gpu_channel = false; | 1130 bool established_gpu_channel = false; |
1131 #if defined(OS_ANDROID) | 1131 // TODO(mfomitchev): Need ImageTransportFactory::Initialize on Android Aura, |
1132 // but figure out what to do with BrowserGpuChannelHostFactory. | |
no sievers
2015/10/20 19:24:22
We can try to do BrowserGpuChannelHostFactory::Ini
| |
1133 #if defined(OS_ANDROID) && !defined(USE_AURA) | |
1132 // TODO(crbug.com/439322): This should be set to |true|. | 1134 // TODO(crbug.com/439322): This should be set to |true|. |
1133 established_gpu_channel = false; | 1135 established_gpu_channel = false; |
1134 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); | 1136 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); |
1135 #elif defined(USE_AURA) || defined(OS_MACOSX) | 1137 #elif defined(USE_AURA) || defined(OS_MACOSX) |
1136 established_gpu_channel = true; | 1138 established_gpu_channel = true; |
1137 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor() || | 1139 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor() || |
1138 parsed_command_line_.HasSwitch(switches::kDisableGpuEarlyInit)) { | 1140 parsed_command_line_.HasSwitch(switches::kDisableGpuEarlyInit)) { |
1139 established_gpu_channel = always_uses_gpu = false; | 1141 established_gpu_channel = always_uses_gpu = false; |
1140 } | 1142 } |
1141 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); | 1143 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1317 const base::CommandLine& command_line) const { | 1319 const base::CommandLine& command_line) const { |
1318 base::FilePath trace_file = command_line.GetSwitchValuePath( | 1320 base::FilePath trace_file = command_line.GetSwitchValuePath( |
1319 switches::kTraceStartupFile); | 1321 switches::kTraceStartupFile); |
1320 // trace_file = "none" means that startup events will show up for the next | 1322 // trace_file = "none" means that startup events will show up for the next |
1321 // begin/end tracing (via about:tracing or AutomationProxy::BeginTracing/ | 1323 // begin/end tracing (via about:tracing or AutomationProxy::BeginTracing/ |
1322 // EndTracing, for example). | 1324 // EndTracing, for example). |
1323 if (trace_file == base::FilePath().AppendASCII("none")) | 1325 if (trace_file == base::FilePath().AppendASCII("none")) |
1324 return trace_file; | 1326 return trace_file; |
1325 | 1327 |
1326 if (trace_file.empty()) { | 1328 if (trace_file.empty()) { |
1327 #if defined(OS_ANDROID) | 1329 #if defined(OS_ANDROID) && !defined(USE_AURA) |
no sievers
2015/10/20 19:24:22
TODO: tracing
| |
1328 TracingControllerAndroid::GenerateTracingFilePath(&trace_file); | 1330 TracingControllerAndroid::GenerateTracingFilePath(&trace_file); |
1329 #else | 1331 #else |
1330 // Default to saving the startup trace into the current dir. | 1332 // Default to saving the startup trace into the current dir. |
1331 trace_file = base::FilePath().AppendASCII("chrometrace.log"); | 1333 trace_file = base::FilePath().AppendASCII("chrometrace.log"); |
1332 #endif | 1334 #endif |
1333 } | 1335 } |
1334 | 1336 |
1335 return trace_file; | 1337 return trace_file; |
1336 } | 1338 } |
1337 | 1339 |
(...skipping 22 matching lines...) Expand all Loading... | |
1360 DCHECK(is_tracing_startup_); | 1362 DCHECK(is_tracing_startup_); |
1361 | 1363 |
1362 is_tracing_startup_ = false; | 1364 is_tracing_startup_ = false; |
1363 TracingController::GetInstance()->DisableRecording( | 1365 TracingController::GetInstance()->DisableRecording( |
1364 TracingController::CreateFileSink( | 1366 TracingController::CreateFileSink( |
1365 startup_trace_file_, | 1367 startup_trace_file_, |
1366 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); | 1368 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); |
1367 } | 1369 } |
1368 | 1370 |
1369 } // namespace content | 1371 } // namespace content |
OLD | NEW |