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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 #include "content/browser/loader_delegate_impl.h" | 68 #include "content/browser/loader_delegate_impl.h" |
69 #include "content/browser/media/media_internals.h" | 69 #include "content/browser/media/media_internals.h" |
70 #include "content/browser/memory/memory_coordinator_impl.h" | 70 #include "content/browser/memory/memory_coordinator_impl.h" |
71 #include "content/browser/memory/swap_metrics_observer.h" | 71 #include "content/browser/memory/swap_metrics_observer.h" |
72 #include "content/browser/net/browser_online_state_observer.h" | 72 #include "content/browser/net/browser_online_state_observer.h" |
73 #include "content/browser/renderer_host/media/media_stream_manager.h" | 73 #include "content/browser/renderer_host/media/media_stream_manager.h" |
74 #include "content/browser/renderer_host/render_process_host_impl.h" | 74 #include "content/browser/renderer_host/render_process_host_impl.h" |
75 #include "content/browser/service_manager/service_manager_context.h" | 75 #include "content/browser/service_manager/service_manager_context.h" |
76 #include "content/browser/speech/speech_recognition_manager_impl.h" | 76 #include "content/browser/speech/speech_recognition_manager_impl.h" |
77 #include "content/browser/startup_task_runner.h" | 77 #include "content/browser/startup_task_runner.h" |
| 78 #include "content/browser/tracing/tracing_controller_impl.h" |
78 #include "content/browser/utility_process_host_impl.h" | 79 #include "content/browser/utility_process_host_impl.h" |
79 #include "content/browser/webui/content_web_ui_controller_factory.h" | 80 #include "content/browser/webui/content_web_ui_controller_factory.h" |
80 #include "content/browser/webui/url_data_manager.h" | 81 #include "content/browser/webui/url_data_manager.h" |
81 #include "content/common/content_switches_internal.h" | 82 #include "content/common/content_switches_internal.h" |
82 #include "content/common/service_manager/service_manager_connection_impl.h" | 83 #include "content/common/service_manager/service_manager_connection_impl.h" |
83 #include "content/public/browser/browser_main_parts.h" | 84 #include "content/public/browser/browser_main_parts.h" |
84 #include "content/public/browser/content_browser_client.h" | 85 #include "content/public/browser/content_browser_client.h" |
85 #include "content/public/browser/gpu_data_manager_observer.h" | 86 #include "content/public/browser/gpu_data_manager_observer.h" |
86 #include "content/public/browser/render_process_host.h" | 87 #include "content/public/browser/render_process_host.h" |
87 #include "content/public/browser/tracing_controller.h" | 88 #include "content/public/browser/tracing_controller.h" |
88 #include "content/public/common/content_client.h" | 89 #include "content/public/common/content_client.h" |
89 #include "content/public/common/content_features.h" | 90 #include "content/public/common/content_features.h" |
90 #include "content/public/common/content_switches.h" | 91 #include "content/public/common/content_switches.h" |
91 #include "content/public/common/main_function_params.h" | 92 #include "content/public/common/main_function_params.h" |
92 #include "content/public/common/result_codes.h" | 93 #include "content/public/common/result_codes.h" |
93 #include "device/gamepad/gamepad_service.h" | 94 #include "device/gamepad/gamepad_service.h" |
94 #include "gpu/vulkan/features.h" | 95 #include "gpu/vulkan/features.h" |
95 #include "media/audio/audio_system_impl.h" | 96 #include "media/audio/audio_system_impl.h" |
96 #include "media/base/media.h" | 97 #include "media/base/media.h" |
97 #include "media/base/user_input_monitor.h" | 98 #include "media/base/user_input_monitor.h" |
98 #include "media/midi/midi_service.h" | 99 #include "media/midi/midi_service.h" |
99 #include "mojo/edk/embedder/embedder.h" | 100 #include "mojo/edk/embedder/embedder.h" |
100 #include "mojo/edk/embedder/scoped_ipc_support.h" | 101 #include "mojo/edk/embedder/scoped_ipc_support.h" |
101 #include "net/base/network_change_notifier.h" | 102 #include "net/base/network_change_notifier.h" |
102 #include "net/socket/client_socket_factory.h" | 103 #include "net/socket/client_socket_factory.h" |
103 #include "net/ssl/ssl_config_service.h" | 104 #include "net/ssl/ssl_config_service.h" |
104 #include "ppapi/features/features.h" | 105 #include "ppapi/features/features.h" |
105 #include "services/resource_coordinator/memory/coordinator/coordinator_impl.h" | 106 #include "services/resource_coordinator/memory/coordinator/coordinator_impl.h" |
| 107 #include "services/resource_coordinator/public/cpp/tracing/chrome_agent.h" |
| 108 #include "services/resource_coordinator/public/interfaces/tracing/tracing.mojom.
h" |
| 109 #include "services/resource_coordinator/tracing/coordinator_impl.h" |
106 #include "services/service_manager/runner/common/client_util.h" | 110 #include "services/service_manager/runner/common/client_util.h" |
107 #include "skia/ext/event_tracer_impl.h" | 111 #include "skia/ext/event_tracer_impl.h" |
108 #include "skia/ext/skia_memory_dump_provider.h" | 112 #include "skia/ext/skia_memory_dump_provider.h" |
109 #include "sql/sql_memory_dump_provider.h" | 113 #include "sql/sql_memory_dump_provider.h" |
110 #include "ui/base/clipboard/clipboard.h" | 114 #include "ui/base/clipboard/clipboard.h" |
111 #include "ui/gfx/switches.h" | 115 #include "ui/gfx/switches.h" |
112 | 116 |
113 #if defined(USE_AURA) || defined(OS_MACOSX) | 117 #if defined(USE_AURA) || defined(OS_MACOSX) |
114 #include "content/browser/compositor/image_transport_factory.h" | 118 #include "content/browser/compositor/image_transport_factory.h" |
115 #endif | 119 #endif |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 // in-process Android WebView. crbug.com/503724 tracks proper fix. | 722 // in-process Android WebView. crbug.com/503724 tracks proper fix. |
719 if (!parsed_command_line_.HasSwitch(switches::kSingleProcess)) { | 723 if (!parsed_command_line_.HasSwitch(switches::kSingleProcess)) { |
720 base::DiscardableMemoryAllocator::SetInstance( | 724 base::DiscardableMemoryAllocator::SetInstance( |
721 discardable_shared_memory_manager_.get()); | 725 discardable_shared_memory_manager_.get()); |
722 } | 726 } |
723 } | 727 } |
724 | 728 |
725 if (parts_) | 729 if (parts_) |
726 parts_->PostMainMessageLoopStart(); | 730 parts_->PostMainMessageLoopStart(); |
727 | 731 |
728 // Start startup tracing through TracingController's interface. TraceLog has | |
729 // been enabled in content_main_runner where threads are not available. Now We | |
730 // need to start tracing for all other tracing agents, which require threads. | |
731 if (parsed_command_line_.HasSwitch(switches::kTraceStartup)) { | |
732 base::trace_event::TraceConfig trace_config( | |
733 parsed_command_line_.GetSwitchValueASCII(switches::kTraceStartup), | |
734 base::trace_event::RECORD_UNTIL_FULL); | |
735 TracingController::GetInstance()->StartTracing( | |
736 trace_config, | |
737 TracingController::StartTracingDoneCallback()); | |
738 } else if (parsed_command_line_.HasSwitch(switches::kTraceToConsole)) { | |
739 TracingController::GetInstance()->StartTracing( | |
740 tracing::GetConfigForTraceToConsole(), | |
741 TracingController::StartTracingDoneCallback()); | |
742 } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) { | |
743 // This checks kTraceConfigFile switch. | |
744 TracingController::GetInstance()->StartTracing( | |
745 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), | |
746 TracingController::StartTracingDoneCallback()); | |
747 } | |
748 // Start tracing to a file for certain duration if needed. Only do this after | |
749 // starting the main message loop to avoid calling | |
750 // MessagePumpForUI::ScheduleWork() before MessagePumpForUI::Start() as it | |
751 // will crash the browser. | |
752 if (is_tracing_startup_for_duration_) { | |
753 TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracingForDuration"); | |
754 InitStartupTracingForDuration(parsed_command_line_); | |
755 } | |
756 | |
757 #if defined(OS_ANDROID) | 732 #if defined(OS_ANDROID) |
758 { | 733 { |
759 TRACE_EVENT0("startup", | 734 TRACE_EVENT0("startup", |
760 "BrowserMainLoop::Subsystem:BrowserMediaPlayerManager"); | 735 "BrowserMainLoop::Subsystem:BrowserMediaPlayerManager"); |
761 if (UsingInProcessGpu()) { | 736 if (UsingInProcessGpu()) { |
762 gpu::ScopedSurfaceRequestConduit::SetInstance( | 737 gpu::ScopedSurfaceRequestConduit::SetInstance( |
763 ScopedSurfaceRequestManager::GetInstance()); | 738 ScopedSurfaceRequestManager::GetInstance()); |
764 } | 739 } |
765 } | 740 } |
766 | 741 |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 } | 1361 } |
1387 | 1362 |
1388 int BrowserMainLoop::BrowserThreadsStarted() { | 1363 int BrowserMainLoop::BrowserThreadsStarted() { |
1389 TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted"); | 1364 TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted"); |
1390 | 1365 |
1391 // Bring up Mojo IPC and the embedded Service Manager as early as possible. | 1366 // Bring up Mojo IPC and the embedded Service Manager as early as possible. |
1392 // Initializaing mojo requires the IO thread to have been initialized first, | 1367 // Initializaing mojo requires the IO thread to have been initialized first, |
1393 // so this cannot happen any earlier than now. | 1368 // so this cannot happen any earlier than now. |
1394 InitializeMojo(); | 1369 InitializeMojo(); |
1395 | 1370 |
| 1371 if (service_manager::ServiceManagerIsRemote()) { |
| 1372 service_manager::Connector* connector = |
| 1373 content::ServiceManagerConnection::GetForProcess()->GetConnector(); |
| 1374 TracingControllerImpl::GetInstance()->Initialize(connector); |
| 1375 |
| 1376 resource_coordinator::tracing::mojom::AgentSetPtr agent_set; |
| 1377 connector->BindInterface("tracing", mojo::MakeRequest(&agent_set)); |
| 1378 resource_coordinator::tracing::ChromeAgent::InitializeIfNeeded( |
| 1379 std::move(agent_set)); |
| 1380 } else { |
| 1381 tracing_coordinator_ = |
| 1382 base::MakeUnique<resource_coordinator::tracing::CoordinatorImpl>(); |
| 1383 TracingControllerImpl::GetInstance()->Initialize(nullptr); |
| 1384 } |
| 1385 // Start startup tracing through TracingController's interface. TraceLog has |
| 1386 // been enabled in content_main_runner where threads are not available. Now We |
| 1387 // need to start tracing for all other tracing agents, which require threads. |
| 1388 if (parsed_command_line_.HasSwitch(switches::kTraceStartup)) { |
| 1389 base::trace_event::TraceConfig trace_config( |
| 1390 parsed_command_line_.GetSwitchValueASCII(switches::kTraceStartup), |
| 1391 base::trace_event::RECORD_UNTIL_FULL); |
| 1392 TracingControllerImpl::GetInstance()->StartTracing( |
| 1393 trace_config, TracingControllerImpl::StartTracingDoneCallback()); |
| 1394 } else if (parsed_command_line_.HasSwitch(switches::kTraceToConsole)) { |
| 1395 TracingControllerImpl::GetInstance()->StartTracing( |
| 1396 tracing::GetConfigForTraceToConsole(), |
| 1397 TracingControllerImpl::StartTracingDoneCallback()); |
| 1398 } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) { |
| 1399 // This checks kTraceConfigFile switch. |
| 1400 TracingControllerImpl::GetInstance()->StartTracing( |
| 1401 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), |
| 1402 TracingControllerImpl::StartTracingDoneCallback()); |
| 1403 } |
| 1404 // Start tracing to a file for certain duration if needed. Only do this after |
| 1405 // starting the main message loop to avoid calling |
| 1406 // MessagePumpForUI::ScheduleWork() before MessagePumpForUI::Start() as it |
| 1407 // will crash the browser. |
| 1408 if (is_tracing_startup_for_duration_) { |
| 1409 TRACE_EVENT0("startup", "BrowserMainLoop::InitStartupTracingForDuration"); |
| 1410 InitStartupTracingForDuration(parsed_command_line_); |
| 1411 } |
| 1412 |
1396 #if defined(USE_AURA) | 1413 #if defined(USE_AURA) |
1397 if (service_manager::ServiceManagerIsRemote()) { | 1414 if (service_manager::ServiceManagerIsRemote()) { |
1398 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1415 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
1399 switches::kIsRunningInMash); | 1416 switches::kIsRunningInMash); |
1400 } | 1417 } |
1401 #endif | 1418 #endif |
1402 | 1419 |
1403 indexed_db_thread_.reset(new base::Thread("IndexedDB")); | 1420 indexed_db_thread_.reset(new base::Thread("IndexedDB")); |
1404 indexed_db_thread_->Start(); | 1421 indexed_db_thread_->Start(); |
1405 | 1422 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 startup_trace_timer_.Start(FROM_HERE, | 1762 startup_trace_timer_.Start(FROM_HERE, |
1746 base::TimeDelta::FromSeconds(delay_secs), | 1763 base::TimeDelta::FromSeconds(delay_secs), |
1747 this, | 1764 this, |
1748 &BrowserMainLoop::EndStartupTracing); | 1765 &BrowserMainLoop::EndStartupTracing); |
1749 } | 1766 } |
1750 | 1767 |
1751 void BrowserMainLoop::EndStartupTracing() { | 1768 void BrowserMainLoop::EndStartupTracing() { |
1752 DCHECK(is_tracing_startup_for_duration_); | 1769 DCHECK(is_tracing_startup_for_duration_); |
1753 | 1770 |
1754 is_tracing_startup_for_duration_ = false; | 1771 is_tracing_startup_for_duration_ = false; |
1755 TracingController::GetInstance()->StopTracing( | 1772 TracingControllerImpl::GetInstance()->StopTracing( |
1756 TracingController::CreateFileSink( | 1773 TracingControllerImpl::CreateFileSink( |
1757 startup_trace_file_, | 1774 startup_trace_file_, |
1758 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); | 1775 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); |
1759 } | 1776 } |
1760 | 1777 |
1761 void BrowserMainLoop::CreateAudioManager() { | 1778 void BrowserMainLoop::CreateAudioManager() { |
1762 DCHECK(!audio_thread_); | 1779 DCHECK(!audio_thread_); |
1763 DCHECK(!audio_manager_); | 1780 DCHECK(!audio_manager_); |
1764 | 1781 |
1765 audio_manager_ = GetContentClient()->browser()->CreateAudioManager( | 1782 audio_manager_ = GetContentClient()->browser()->CreateAudioManager( |
1766 MediaInternals::GetInstance()); | 1783 MediaInternals::GetInstance()); |
1767 if (!audio_manager_) { | 1784 if (!audio_manager_) { |
1768 audio_thread_ = base::MakeUnique<AudioManagerThread>(); | 1785 audio_thread_ = base::MakeUnique<AudioManagerThread>(); |
1769 audio_manager_ = media::AudioManager::Create( | 1786 audio_manager_ = media::AudioManager::Create( |
1770 audio_thread_->task_runner(), audio_thread_->worker_task_runner(), | 1787 audio_thread_->task_runner(), audio_thread_->worker_task_runner(), |
1771 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 1788 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
1772 MediaInternals::GetInstance()); | 1789 MediaInternals::GetInstance()); |
1773 } | 1790 } |
1774 CHECK(audio_manager_); | 1791 CHECK(audio_manager_); |
1775 | 1792 |
1776 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); | 1793 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); |
1777 CHECK(audio_system_); | 1794 CHECK(audio_system_); |
1778 } | 1795 } |
1779 | 1796 |
1780 } // namespace content | 1797 } // namespace content |
OLD | NEW |