[email protected] | d3d6325d | 2012-01-03 21:17:36 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ |
| 6 | #define CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
maxmorin | 017ba8c6 | 2017-06-02 10:23:09 | [diff] [blame] | 11 | #include <map> |
leon.han | 21e0e48 | 2017-02-23 04:13:32 | [diff] [blame] | 12 | #include <memory> |
[email protected] | 6779aa1 | 2011-03-29 17:32:24 | [diff] [blame] | 13 | #include <set> |
[email protected] | b68d5ed | 2009-04-16 02:41:28 | [diff] [blame] | 14 | #include <string> |
maxmorin | 017ba8c6 | 2017-06-02 10:23:09 | [diff] [blame] | 15 | #include <utility> |
[email protected] | 1bc8306 | 2009-02-06 00:16:37 | [diff] [blame] | 16 | #include <vector> |
| 17 | |
jdduke | 691dd57 | 2014-12-02 20:47:52 | [diff] [blame] | 18 | #include "base/cancelable_callback.h" |
Sebastien Marchand | 836d04b3 | 2020-04-28 18:10:03 | [diff] [blame^] | 19 | #include "base/clang_profiling_buildflags.h" |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 20 | #include "base/macros.h" |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 21 | #include "base/memory/discardable_memory_allocator.h" |
[email protected] | 5071cb2 | 2013-07-10 02:19:06 | [diff] [blame] | 22 | #include "base/memory/memory_pressure_listener.h" |
rockot | 775ce0d | 2015-01-27 18:35:01 | [diff] [blame] | 23 | #include "base/memory/ref_counted.h" |
[email protected] | e6e30ac | 2014-01-13 21:24:39 | [diff] [blame] | 24 | #include "base/metrics/user_metrics_action.h" |
[email protected] | 1223d6ef | 2011-03-28 16:47:50 | [diff] [blame] | 25 | #include "base/observer_list.h" |
maxmorin | 017ba8c6 | 2017-06-02 10:23:09 | [diff] [blame] | 26 | #include "base/optional.h" |
[email protected] | 21aa9968 | 2013-06-11 07:17:01 | [diff] [blame] | 27 | #include "base/strings/string16.h" |
tbansal | 99d8aeb | 2017-05-22 19:12:58 | [diff] [blame] | 28 | #include "base/time/time.h" |
[email protected] | 037fce0 | 2009-01-22 01:42:15 | [diff] [blame] | 29 | #include "build/build_config.h" |
jam | 8a021512a | 2015-02-03 18:16:08 | [diff] [blame] | 30 | #include "content/child/child_thread_impl.h" |
[email protected] | 8d128d6 | 2011-09-13 22:11:57 | [diff] [blame] | 31 | #include "content/common/content_export.h" |
ben | 76f52b24 | 2016-06-18 05:42:48 | [diff] [blame] | 32 | #include "content/common/frame.mojom.h" |
alexmos | bc7eafa | 2014-12-06 01:38:09 | [diff] [blame] | 33 | #include "content/common/frame_replication_state.h" |
samans | 2040988b | 2017-04-11 23:58:35 | [diff] [blame] | 34 | #include "content/common/frame_sink_provider.mojom.h" |
jonross | a2ff4f8 | 2018-02-16 17:27:46 | [diff] [blame] | 35 | #include "content/common/render_frame_metadata.mojom.h" |
rockot | e261d211 | 2016-09-21 22:22:23 | [diff] [blame] | 36 | #include "content/common/render_message_filter.mojom.h" |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 37 | #include "content/common/renderer.mojom.h" |
jam | 188f19f | 2017-06-07 03:56:24 | [diff] [blame] | 38 | #include "content/common/renderer_host.mojom.h" |
[email protected] | 52647690 | 2011-10-06 20:34:06 | [diff] [blame] | 39 | #include "content/public/renderer/render_thread.h" |
Yuzhu Shen | fe5f3a5 | 2018-01-11 21:24:13 | [diff] [blame] | 40 | #include "content/public/renderer/url_loader_throttle_provider.h" |
Sadrul Habib Chowdhury | 31c9871 | 2018-12-11 04:15:13 | [diff] [blame] | 41 | #include "content/renderer/compositor/compositor_dependencies.h" |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 42 | #include "content/renderer/discardable_memory_utils.h" |
Amos Lim | bcc710e | 2018-06-08 05:51:17 | [diff] [blame] | 43 | #include "content/renderer/media/audio/audio_input_ipc_factory.h" |
| 44 | #include "content/renderer/media/audio/audio_output_ipc_factory.h" |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 45 | #include "gpu/ipc/client/gpu_channel_host.h" |
Antoine Labour | e55c9ef8 | 2017-11-10 18:51:23 | [diff] [blame] | 46 | #include "ipc/ipc_sync_channel.h" |
Scott Violet | a35f9a4 | 2018-03-22 22:00:44 | [diff] [blame] | 47 | #include "media/media_buildflags.h" |
Julie Jeongeun Kim | 4e77af262 | 2019-09-11 03:36:45 | [diff] [blame] | 48 | #include "mojo/public/cpp/bindings/associated_receiver.h" |
Julie Jeongeun Kim | daa9aa1 | 2019-10-24 02:51:56 | [diff] [blame] | 49 | #include "mojo/public/cpp/bindings/associated_remote.h" |
Julie Jeongeun Kim | 4e77af262 | 2019-09-11 03:36:45 | [diff] [blame] | 50 | #include "mojo/public/cpp/bindings/pending_associated_receiver.h" |
Julie Jeongeun Kim | 4421c2e | 2019-09-11 06:34:39 | [diff] [blame] | 51 | #include "mojo/public/cpp/bindings/pending_receiver.h" |
Julie Jeongeun Kim | 6f4b7e0 | 2019-09-11 05:05:46 | [diff] [blame] | 52 | #include "mojo/public/cpp/bindings/pending_remote.h" |
Gyuyoung Kim | ef648a2e7 | 2019-09-17 09:48:35 | [diff] [blame] | 53 | #include "mojo/public/cpp/bindings/receiver.h" |
Mario Sanchez Prada | 5492c9a | 2019-09-10 20:58:11 | [diff] [blame] | 54 | #include "mojo/public/cpp/bindings/remote.h" |
[email protected] | d7ff5fb | 2014-05-29 19:50:25 | [diff] [blame] | 55 | #include "net/base/network_change_notifier.h" |
tbansal | b612c5d | 2017-05-25 18:53:06 | [diff] [blame] | 56 | #include "net/nqe/effective_connection_type.h" |
Ken Rockot | 54311e6 | 2018-02-10 19:01:52 | [diff] [blame] | 57 | #include "services/network/public/mojom/url_loader_factory.mojom.h" |
Miyoung Shin | 99505dd | 2019-07-27 12:45:35 | [diff] [blame] | 58 | #include "services/viz/public/mojom/compositing/compositing_mode_watcher.mojom.h" |
Ken Rockot | 26e4e80 | 2018-07-31 15:03:33 | [diff] [blame] | 59 | #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 60 | #include "third_party/blink/public/common/user_agent/user_agent_metadata.h" |
Kent Tamura | 38fb434 | 2018-07-25 12:47:53 | [diff] [blame] | 61 | #include "third_party/blink/public/platform/scheduler/web_rail_mode_observer.h" |
Daniel Murphy | 738378c | 2019-05-31 21:59:25 | [diff] [blame] | 62 | #include "third_party/blink/public/platform/scheduler/web_thread_scheduler.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 63 | #include "third_party/blink/public/platform/web_connection_type.h" |
Kouhei Ueno | 23f0759f | 2020-02-17 04:50:42 | [diff] [blame] | 64 | #include "third_party/blink/public/platform/web_isolate.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 65 | #include "third_party/blink/public/web/web_memory_statistics.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 66 | #include "ui/gfx/native_widget_types.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 67 | |
[email protected] | 39008c0 | 2009-02-11 23:59:25 | [diff] [blame] | 68 | class SkBitmap; |
[email protected] | 46f36a49 | 2010-07-28 19:36:41 | [diff] [blame] | 69 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 70 | namespace blink { |
Antonio Gomes | 925f9b9 | 2019-07-30 23:23:23 | [diff] [blame] | 71 | class WebVideoCaptureImplManager; |
[email protected] | b7c7bcf | 2009-10-03 07:07:34 | [diff] [blame] | 72 | } |
| 73 | |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 74 | namespace base { |
skyostil | 457b0a1 | 2014-09-09 10:12:07 | [diff] [blame] | 75 | class SingleThreadTaskRunner; |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 76 | class Thread; |
| 77 | } |
| 78 | |
[email protected] | c29b7ff | 2013-03-06 03:51:04 | [diff] [blame] | 79 | namespace cc { |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 80 | class TaskGraphRunner; |
[email protected] | c29b7ff | 2013-03-06 03:51:04 | [diff] [blame] | 81 | } |
| 82 | |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 83 | namespace gpu { |
| 84 | class GpuChannelHost; |
| 85 | } |
| 86 | |
[email protected] | 563d665f | 2013-02-01 04:42:39 | [diff] [blame] | 87 | namespace media { |
[email protected] | 2329bfc7 | 2014-02-28 02:03:21 | [diff] [blame] | 88 | class GpuVideoAcceleratorFactories; |
[email protected] | 563d665f | 2013-02-01 04:42:39 | [diff] [blame] | 89 | } |
| 90 | |
Ken Rockot | 13051c93 | 2019-11-14 20:11:51 | [diff] [blame] | 91 | namespace mojo { |
| 92 | class BinderMap; |
| 93 | } |
| 94 | |
danakj | 9242985 | 2017-06-29 00:19:03 | [diff] [blame] | 95 | namespace viz { |
Scott Violet | 7e33efc | 2018-08-29 22:30:15 | [diff] [blame] | 96 | class ContextProviderCommandBuffer; |
| 97 | class Gpu; |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 98 | class RasterContextProvider; |
| 99 | class SyntheticBeginFrameSource; |
| 100 | } // namespace viz |
Scott Violet | 7e33efc | 2018-08-29 22:30:15 | [diff] [blame] | 101 | |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 102 | namespace content { |
[email protected] | 3958e97 | 2012-07-17 00:25:41 | [diff] [blame] | 103 | class AudioRendererMixerManager; |
John Abd-El-Malek | e1d4de3 | 2017-10-21 16:14:29 | [diff] [blame] | 104 | class CategorizedWorkerPool; |
John Abd-El-Malek | e1d4de3 | 2017-10-21 16:14:29 | [diff] [blame] | 105 | class GpuVideoAcceleratorFactoriesImpl; |
Robert Sesek | 6e3d725c | 2018-06-06 14:38:02 | [diff] [blame] | 106 | class LowMemoryModeController; |
tyoshino | 832a58a | 2016-04-18 08:14:08 | [diff] [blame] | 107 | class RenderThreadObserver; |
tfarina | 556a723 | 2014-10-05 01:02:09 | [diff] [blame] | 108 | class RendererBlinkPlatformImpl; |
John Abd-El-Malek | 6b56ef71 | 2017-10-21 22:52:46 | [diff] [blame] | 109 | class ResourceDispatcher; |
Alex Clarke | 9fc39b9b | 2020-01-31 17:29:47 | [diff] [blame] | 110 | class VariationsRenderThreadObserver; |
[email protected] | cb25aa1 | 2012-08-07 19:13:43 | [diff] [blame] | 111 | |
boliu | bee541f4 | 2015-11-05 00:52:53 | [diff] [blame] | 112 | #if defined(OS_ANDROID) |
siva.gunturi | 5d4feb05 | 2015-11-15 16:15:31 | [diff] [blame] | 113 | class StreamTextureFactory; |
boliu | bee541f4 | 2015-11-05 00:52:53 | [diff] [blame] | 114 | #endif |
| 115 | |
Matt Falkenhagen | ef13d78 | 2019-05-30 21:02:12 | [diff] [blame] | 116 | // The RenderThreadImpl class represents the main thread, where RenderView |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 117 | // instances live. The RenderThread supports an API that is used by its |
| 118 | // consumer to talk indirectly to the RenderViews and supporting objects. |
| 119 | // Likewise, it provides an API for the RenderViews to talk back to the main |
[email protected] | 770005b | 2012-04-16 15:58:13 | [diff] [blame] | 120 | // process (i.e., their corresponding WebContentsImpl). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 121 | // |
| 122 | // Most of the communication occurs in the form of IPC messages. They are |
| 123 | // routed to the RenderThread according to the routing IDs of the messages. |
| 124 | // The routing IDs correspond to RenderView instances. |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 125 | class CONTENT_EXPORT RenderThreadImpl |
| 126 | : public RenderThread, |
jam | 8a021512a | 2015-02-03 18:16:08 | [diff] [blame] | 127 | public ChildThreadImpl, |
Nico Weber | 43ddd7a3 | 2017-08-15 19:19:27 | [diff] [blame] | 128 | public mojom::Renderer, |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 129 | public viz::mojom::CompositingModeWatcher, |
Nico Weber | 43ddd7a3 | 2017-08-15 19:19:27 | [diff] [blame] | 130 | public CompositorDependencies { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 131 | public: |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 132 | static RenderThreadImpl* current(); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 133 | static mojom::RenderMessageFilter* current_render_message_filter(); |
olegmax | 045f7fb1 | 2017-05-19 07:58:55 | [diff] [blame] | 134 | static RendererBlinkPlatformImpl* current_blink_platform_impl(); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 135 | |
| 136 | static void SetRenderMessageFilterForTesting( |
| 137 | mojom::RenderMessageFilter* render_message_filter); |
olegmax | 045f7fb1 | 2017-05-19 07:58:55 | [diff] [blame] | 138 | static void SetRendererBlinkPlatformImplForTesting( |
| 139 | RendererBlinkPlatformImpl* blink_platform_impl); |
[email protected] | 52647690 | 2011-10-06 20:34:06 | [diff] [blame] | 140 | |
John Abd-El-Malek | d488264 | 2017-12-04 21:45:19 | [diff] [blame] | 141 | // Returns the task runner for the main thread where the RenderThread lives. |
Hajime Hoshi | 20578c6 | 2018-01-12 09:43:26 | [diff] [blame] | 142 | static scoped_refptr<base::SingleThreadTaskRunner> |
| 143 | DeprecatedGetMainTaskRunner(); |
John Abd-El-Malek | d488264 | 2017-12-04 21:45:19 | [diff] [blame] | 144 | |
Wez | 6979109b | 2018-09-07 17:30:56 | [diff] [blame] | 145 | RenderThreadImpl( |
| 146 | base::RepeatingClosure quit_closure, |
Greg Kraynov | f5d6027 | 2018-08-10 12:28:51 | [diff] [blame] | 147 | std::unique_ptr<blink::scheduler::WebThreadScheduler> scheduler); |
| 148 | RenderThreadImpl( |
| 149 | const InProcessChildThreadParams& params, |
Sunny Sachanandani | e3e58250 | 2019-10-22 20:10:38 | [diff] [blame] | 150 | int32_t client_id, |
Greg Kraynov | f5d6027 | 2018-08-10 12:28:51 | [diff] [blame] | 151 | std::unique_ptr<blink::scheduler::WebThreadScheduler> scheduler); |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 152 | ~RenderThreadImpl() override; |
| 153 | void Shutdown() override; |
haraken | bbfdd9f0 | 2017-01-12 07:14:04 | [diff] [blame] | 154 | bool ShouldBeDestroyed() override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 155 | |
[email protected] | 58436a1 | 2012-03-21 17:10:26 | [diff] [blame] | 156 | // When initializing WebKit, ensure that any schemes needed for the content |
| 157 | // module are registered properly. Static to allow sharing with tests. |
| 158 | static void RegisterSchemes(); |
| 159 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 160 | // RenderThread implementation: |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 161 | bool Send(IPC::Message* msg) override; |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 162 | IPC::SyncChannel* GetChannel() override; |
| 163 | std::string GetLocale() override; |
| 164 | IPC::SyncMessageFilter* GetSyncMessageFilter() override; |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 165 | void AddRoute(int32_t routing_id, IPC::Listener* listener) override; |
| 166 | void RemoveRoute(int32_t routing_id) override; |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 167 | int GenerateRoutingID() override; |
| 168 | void AddFilter(IPC::MessageFilter* filter) override; |
| 169 | void RemoveFilter(IPC::MessageFilter* filter) override; |
tyoshino | 832a58a | 2016-04-18 08:14:08 | [diff] [blame] | 170 | void AddObserver(RenderThreadObserver* observer) override; |
| 171 | void RemoveObserver(RenderThreadObserver* observer) override; |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 172 | void SetResourceDispatcherDelegate( |
mohan.reddy | ee0b42a | 2014-10-08 04:53:14 | [diff] [blame] | 173 | ResourceDispatcherDelegate* delegate) override; |
Clemens Hammacher | 38b6a76 | 2019-02-05 13:07:22 | [diff] [blame] | 174 | void RegisterExtension(std::unique_ptr<v8::Extension> extension) override; |
danakj | 710b4c0 | 2019-11-28 16:08:45 | [diff] [blame] | 175 | int PostTaskToAllWebWorkers(base::RepeatingClosure closure) override; |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 176 | bool ResolveProxy(const GURL& url, std::string* proxy_list) override; |
| 177 | base::WaitableEvent* GetShutdownEvent() override; |
staraz | 067f5824 | 2016-11-07 21:06:41 | [diff] [blame] | 178 | int32_t GetClientId() override; |
Nasko Oskov | 3d0d1dc | 2018-09-25 03:57:13 | [diff] [blame] | 179 | bool IsOnline() override; |
Karan Bhatia | c89897f | 2017-08-10 01:06:40 | [diff] [blame] | 180 | void SetRendererProcessType( |
Yuta Kitamura | 6359350 | 2018-11-12 09:27:13 | [diff] [blame] | 181 | blink::scheduler::WebRendererProcessType type) override; |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 182 | blink::WebString GetUserAgent() override; |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 183 | const blink::UserAgentMetadata& GetUserAgentMetadata() override; |
Virender Singh | dfc6c79 | 2019-12-03 05:40:03 | [diff] [blame] | 184 | bool IsUseZoomForDSF() override; |
[email protected] | 1223d6ef | 2011-03-28 16:47:50 | [diff] [blame] | 185 | |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 186 | // IPC::Listener implementation via ChildThreadImpl: |
| 187 | void OnAssociatedInterfaceRequest( |
| 188 | const std::string& name, |
| 189 | mojo::ScopedInterfaceEndpointHandle handle) override; |
| 190 | |
weili | fabbf757 | 2017-05-22 19:05:16 | [diff] [blame] | 191 | // ChildThread implementation via ChildThreadImpl: |
| 192 | scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner() override; |
| 193 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 194 | // CompositorDependencies implementation. |
senorblanco | b60ba95 | 2015-01-27 19:12:36 | [diff] [blame] | 195 | int GetGpuRasterizationMSAASampleCount() override; |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 196 | bool IsLcdTextEnabled() override; |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 197 | bool IsZeroCopyEnabled() override; |
ericrk | 1d17f75 | 2015-10-20 03:03:07 | [diff] [blame] | 198 | bool IsPartialRasterEnabled() override; |
ccameron | c7fcd13 | 2015-11-03 20:14:31 | [diff] [blame] | 199 | bool IsGpuMemoryBufferCompositorResourcesEnabled() override; |
ccameron | a764475 | 2014-12-30 01:16:31 | [diff] [blame] | 200 | bool IsElasticOverscrollEnabled() override; |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 201 | bool IsUseZoomForDSFEnabled() override; |
Dave Tapuska | 14d816f | 2020-04-20 16:21:13 | [diff] [blame] | 202 | bool IsSingleThreaded() override; |
danakj | f24dc81 | 2019-10-04 19:03:16 | [diff] [blame] | 203 | scoped_refptr<base::SingleThreadTaskRunner> GetCleanupTaskRunner() override; |
Yuta Kitamura | deb91bb | 2018-05-29 05:53:20 | [diff] [blame] | 204 | blink::scheduler::WebThreadScheduler* GetWebMainThreadScheduler() override; |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 205 | cc::TaskGraphRunner* GetTaskGraphRunner() override; |
wjmaclean | 1d97062 | 2017-01-21 22:28:24 | [diff] [blame] | 206 | bool IsScrollAnimatorEnabled() override; |
Khushal | 3e96e66 | 2017-10-30 23:16:50 | [diff] [blame] | 207 | std::unique_ptr<cc::UkmRecorderFactory> CreateUkmRecorderFactory() override; |
danakj | 2d2889a | 2019-04-05 21:22:08 | [diff] [blame] | 208 | void RequestNewLayerTreeFrameSink( |
Erik Chen | 450ab56 | 2019-10-10 18:58:13 | [diff] [blame] | 209 | RenderWidget* render_widget, |
danakj | 2d2889a | 2019-04-05 21:22:08 | [diff] [blame] | 210 | scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, |
| 211 | const GURL& url, |
| 212 | LayerTreeFrameSinkCallback callback, |
danakj | 2d2889a | 2019-04-05 21:22:08 | [diff] [blame] | 213 | const char* client_name) override; |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 214 | #ifdef OS_ANDROID |
| 215 | bool UsingSynchronousCompositing() override; |
| 216 | #endif |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 217 | |
danakj | e6da4f1 | 2018-07-04 17:41:30 | [diff] [blame] | 218 | bool IsThreadedAnimationEnabled(); |
Dave Tapuska | 14d816f | 2020-04-20 16:21:13 | [diff] [blame] | 219 | scoped_refptr<base::SingleThreadTaskRunner> |
| 220 | GetCompositorMainThreadTaskRunner(); |
danakj | e6da4f1 | 2018-07-04 17:41:30 | [diff] [blame] | 221 | |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 222 | // viz::mojom::CompositingModeWatcher implementation. |
| 223 | void CompositingModeFallbackToSoftware() override; |
| 224 | |
| 225 | // Whether gpu compositing is being used or is disabled for software |
| 226 | // compositing. Clients of the compositor should give resources that match |
| 227 | // the appropriate mode. |
| 228 | bool IsGpuCompositingDisabled() { return is_gpu_compositing_disabled_; } |
| 229 | |
[email protected] | b3e83de | 2012-02-07 03:33:28 | [diff] [blame] | 230 | // Synchronously establish a channel to the GPU plugin if not previously |
| 231 | // established or if it has been lost (for example if the GPU plugin crashed). |
| 232 | // If there is a pending asynchronous request, it will be completed by the |
Bo Liu | d1ef1c3 | 2017-12-08 06:15:50 | [diff] [blame] | 233 | // time this routine returns. |
| 234 | scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync(); |
[email protected] | b3e83de | 2012-02-07 03:33:28 | [diff] [blame] | 235 | |
piman | c44437a2 | 2016-10-29 00:09:22 | [diff] [blame] | 236 | gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager(); |
| 237 | |
Sam McNally | 52e5028 | 2017-11-29 00:54:02 | [diff] [blame] | 238 | blink::AssociatedInterfaceRegistry* GetAssociatedInterfaceRegistry(); |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 239 | |
Kent Tamura | 2eab5b1 | 2018-12-07 04:31:23 | [diff] [blame] | 240 | // True if we are running web tests. This currently disables forwarding |
[email protected] | 70dee7e | 2013-05-29 18:28:30 | [diff] [blame] | 241 | // various status messages to the console, skips network error pages, and |
| 242 | // short circuits size update and focus events. |
danakj | becba32 | 2019-03-29 17:13:46 | [diff] [blame] | 243 | bool web_test_mode() const { return web_test_mode_; } |
| 244 | void enable_web_test_mode() { web_test_mode_ = true; } |
[email protected] | ac7f5a0 | 2013-03-16 16:14:41 | [diff] [blame] | 245 | |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 246 | base::DiscardableMemoryAllocator* GetDiscardableMemoryAllocatorForTest() |
| 247 | const { |
| 248 | return discardable_memory_allocator_.get(); |
penghuang | 342762b | 2016-12-02 21:04:58 | [diff] [blame] | 249 | } |
| 250 | |
tfarina | 556a723 | 2014-10-05 01:02:09 | [diff] [blame] | 251 | RendererBlinkPlatformImpl* blink_platform_impl() const { |
| 252 | DCHECK(blink_platform_impl_); |
| 253 | return blink_platform_impl_.get(); |
[email protected] | 078780b | 2014-06-20 16:57:06 | [diff] [blame] | 254 | } |
| 255 | |
Yuta Kitamura | 4e256bfc | 2018-09-27 06:32:35 | [diff] [blame] | 256 | // Returns the task runner on the compositor thread. |
| 257 | // |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 258 | // Will be null if threaded compositing has not been enabled. |
skyostil | 2d3b5bd | 2015-05-27 15:40:59 | [diff] [blame] | 259 | scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner() const { |
| 260 | return compositor_task_runner_; |
[email protected] | a9fb30aa | 2011-10-06 06:58:46 | [diff] [blame] | 261 | } |
| 262 | |
John Abd-El-Malek | 6b56ef71 | 2017-10-21 22:52:46 | [diff] [blame] | 263 | ResourceDispatcher* resource_dispatcher() const { |
| 264 | return resource_dispatcher_.get(); |
| 265 | } |
| 266 | |
Yuzhu Shen | fe5f3a5 | 2018-01-11 21:24:13 | [diff] [blame] | 267 | URLLoaderThrottleProvider* url_loader_throttle_provider() const { |
| 268 | return url_loader_throttle_provider_.get(); |
| 269 | } |
| 270 | |
[email protected] | 6ca6a08 | 2013-09-22 20:10:05 | [diff] [blame] | 271 | #if defined(OS_ANDROID) |
siva.gunturi | 5d4feb05 | 2015-11-15 16:15:31 | [diff] [blame] | 272 | scoped_refptr<StreamTextureFactory> GetStreamTexureFactory(); |
boliu | f8753bf6 | 2016-02-11 20:09:42 | [diff] [blame] | 273 | bool EnableStreamTextureCopy(); |
[email protected] | 6ca6a08 | 2013-09-22 20:10:05 | [diff] [blame] | 274 | #endif |
| 275 | |
Antonio Gomes | 925f9b9 | 2019-07-30 23:23:23 | [diff] [blame] | 276 | blink::WebVideoCaptureImplManager* video_capture_impl_manager() const { |
[email protected] | 80b161a | 2011-06-27 17:42:11 | [diff] [blame] | 277 | return vc_manager_.get(); |
| 278 | } |
| 279 | |
Robert Sesek | 6e3d725c | 2018-06-06 14:38:02 | [diff] [blame] | 280 | LowMemoryModeController* low_memory_mode_controller() const { |
| 281 | return low_memory_mode_controller_.get(); |
| 282 | } |
| 283 | |
rockot | e261d211 | 2016-09-21 22:22:23 | [diff] [blame] | 284 | mojom::RenderMessageFilter* render_message_filter(); |
rockot | 1587e33 | 2016-07-27 17:44:14 | [diff] [blame] | 285 | |
[email protected] | 6217d39 | 2010-03-25 22:08:35 | [diff] [blame] | 286 | // Get the GPU channel. Returns NULL if the channel is not established or |
| 287 | // has been lost. |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 288 | gpu::GpuChannelHost* GetGpuChannel(); |
[email protected] | 6217d39 | 2010-03-25 22:08:35 | [diff] [blame] | 289 | |
skyostil | 2d3b5bd | 2015-05-27 15:40:59 | [diff] [blame] | 290 | // Returns a SingleThreadTaskRunner instance corresponding to the message loop |
[email protected] | c1330c8 | 2013-06-06 02:23:25 | [diff] [blame] | 291 | // of the thread on which media operations should be run. Must be called |
| 292 | // on the renderer's main thread. |
acolwell | b403494 | 2014-08-28 15:42:43 | [diff] [blame] | 293 | scoped_refptr<base::SingleThreadTaskRunner> GetMediaThreadTaskRunner(); |
[email protected] | c1330c8 | 2013-06-06 02:23:25 | [diff] [blame] | 294 | |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 295 | // A TaskRunner instance that runs tasks on the raster worker pool. |
| 296 | base::TaskRunner* GetWorkerTaskRunner(); |
dcastagna | b880e8f | 2015-06-30 20:16:06 | [diff] [blame] | 297 | |
CJ DiMeglio | 79f7c91a2 | 2018-08-30 22:24:43 | [diff] [blame] | 298 | // Creates a ContextProvider if yet created, and returns it to be used for |
| 299 | // video frame compositing. The ContextProvider given as an argument is |
| 300 | // one that has been lost, and is a hint to the RenderThreadImpl to clear |
| 301 | // it's |video_frame_compositor_context_provider_| if it matches. |
Sergey Ulanov | 83f4a15 | 2019-02-14 03:54:25 | [diff] [blame] | 302 | scoped_refptr<viz::RasterContextProvider> |
| 303 | GetVideoFrameCompositorContextProvider( |
| 304 | scoped_refptr<viz::RasterContextProvider>); |
CJ DiMeglio | 79f7c91a2 | 2018-08-30 22:24:43 | [diff] [blame] | 305 | |
danakj | 0b4b94e3 | 2016-05-10 22:33:01 | [diff] [blame] | 306 | // Returns a worker context provider that will be bound on the compositor |
| 307 | // thread. |
Victor Miura | ff648861 | 2017-12-21 04:16:15 | [diff] [blame] | 308 | scoped_refptr<viz::RasterContextProvider> |
Jonathan Backer | 8e4f35d | 2018-10-15 20:56:42 | [diff] [blame] | 309 | SharedCompositorWorkerContextProvider(bool try_gpu_rasterization); |
reveman | d180dfc3 | 2015-09-24 00:19:43 | [diff] [blame] | 310 | |
dcastagna | 7f45dada | 2015-10-19 20:17:35 | [diff] [blame] | 311 | media::GpuVideoAcceleratorFactories* GetGpuFactories(); |
[email protected] | 3bb8bb3 | 2013-07-11 13:13:03 | [diff] [blame] | 312 | |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 313 | scoped_refptr<viz::ContextProviderCommandBuffer> |
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 314 | SharedMainThreadContextProvider(); |
[email protected] | c29b7ff | 2013-03-06 03:51:04 | [diff] [blame] | 315 | |
[email protected] | 3958e97 | 2012-07-17 00:25:41 | [diff] [blame] | 316 | // AudioRendererMixerManager instance which manages renderer side mixer |
| 317 | // instances shared based on configured audio parameters. Lazily created on |
| 318 | // first call. |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 319 | AudioRendererMixerManager* GetAudioRendererMixerManager(); |
[email protected] | 3958e97 | 2012-07-17 00:25:41 | [diff] [blame] | 320 | |
Yuzu Saijo | 9acd7e6 | 2019-06-12 10:05:31 | [diff] [blame] | 321 | class UnfreezableMessageFilter : public IPC::MessageFilter { |
| 322 | public: |
| 323 | explicit UnfreezableMessageFilter(RenderThreadImpl* render_thread_impl); |
| 324 | bool OnMessageReceived(const IPC::Message& message) override; |
| 325 | |
| 326 | // Adds |unfreezable_task_runner| for the task to be executed later. |
| 327 | void AddListenerUnfreezableTaskRunner( |
| 328 | int32_t routing_id, |
| 329 | scoped_refptr<base::SingleThreadTaskRunner> unfreezable_task_runner); |
| 330 | |
Brook Hong | c4ab7a0 | 2020-04-02 16:55:54 | [diff] [blame] | 331 | // Removes |unfreezable_task_runner| for the task to be executed later. |
| 332 | void RemoveListenerUnfreezableTaskRunner( |
| 333 | int32_t routing_id); |
| 334 | |
Yuzu Saijo | 9acd7e6 | 2019-06-12 10:05:31 | [diff] [blame] | 335 | // Called on the I/O thread. |
| 336 | // Returns the unfreezable task runner associated with |routing_id|. |
| 337 | scoped_refptr<base::SingleThreadTaskRunner> GetUnfreezableTaskRunner( |
| 338 | int32_t routing_id); |
| 339 | |
| 340 | private: |
| 341 | ~UnfreezableMessageFilter() override; |
| 342 | RenderThreadImpl* render_thread_impl_; |
| 343 | base::Lock unfreezable_task_runners_lock_; |
| 344 | // Map of routing_id and listener's thread unfreezable task runner. |
| 345 | std::map<int32_t, scoped_refptr<base::SingleThreadTaskRunner>> |
| 346 | unfreezable_task_runners_ GUARDED_BY(unfreezable_task_runners_lock_); |
| 347 | }; |
| 348 | |
[email protected] | b2d9876 | 2012-09-03 17:04:06 | [diff] [blame] | 349 | // For producing custom V8 histograms. Custom histograms are produced if all |
| 350 | // RenderViews share the same host, and the host is in the pre-specified set |
| 351 | // of hosts we want to produce custom diagrams for. The name for a custom |
| 352 | // diagram is the name of the corresponding generic diagram plus a |
| 353 | // host-specific suffix. |
| 354 | class CONTENT_EXPORT HistogramCustomizer { |
| 355 | public: |
| 356 | HistogramCustomizer(); |
| 357 | ~HistogramCustomizer(); |
| 358 | |
| 359 | // Called when a top frame of a RenderView navigates. This function updates |
| 360 | // RenderThreadImpl's information about whether all RenderViews are |
| 361 | // displaying a page from the same host. |host| is the host where a |
| 362 | // RenderView navigated, and |view_count| is the number of RenderViews in |
| 363 | // this process. |
| 364 | void RenderViewNavigatedToHost(const std::string& host, size_t view_count); |
| 365 | |
| 366 | // Used for customizing some histograms if all RenderViews share the same |
| 367 | // host. Returns the current custom histogram name to use for |
| 368 | // |histogram_name|, or |histogram_name| if it shouldn't be customized. |
| 369 | std::string ConvertToCustomHistogramName(const char* histogram_name) const; |
| 370 | |
| 371 | private: |
hablich | d6a4f12 | 2015-10-28 11:34:49 | [diff] [blame] | 372 | FRIEND_TEST_ALL_PREFIXES(RenderThreadImplUnittest, |
| 373 | IdentifyAlexaTop10NonGoogleSite); |
[email protected] | b2d9876 | 2012-09-03 17:04:06 | [diff] [blame] | 374 | friend class RenderThreadImplUnittest; |
Yuzu Saijo | 9acd7e6 | 2019-06-12 10:05:31 | [diff] [blame] | 375 | friend class UnfreezableMessageFilter; |
[email protected] | b2d9876 | 2012-09-03 17:04:06 | [diff] [blame] | 376 | |
hablich | d6a4f12 | 2015-10-28 11:34:49 | [diff] [blame] | 377 | // Converts a host name to a suffix for histograms |
| 378 | std::string HostToCustomHistogramSuffix(const std::string& host); |
| 379 | |
| 380 | // Helper function to identify a certain set of top pages |
| 381 | bool IsAlexaTop10NonGoogleSite(const std::string& host); |
| 382 | |
[email protected] | b2d9876 | 2012-09-03 17:04:06 | [diff] [blame] | 383 | // Used for updating the information on which is the common host which all |
| 384 | // RenderView's share (if any). If there is no common host, this function is |
| 385 | // called with an empty string. |
| 386 | void SetCommonHost(const std::string& host); |
| 387 | |
| 388 | // The current common host of the RenderViews; empty string if there is no |
| 389 | // common host. |
| 390 | std::string common_host_; |
| 391 | // The corresponding suffix. |
| 392 | std::string common_host_histogram_suffix_; |
| 393 | // Set of histograms for which we want to produce a custom histogram if |
| 394 | // possible. |
| 395 | std::set<std::string> custom_histograms_; |
| 396 | |
| 397 | DISALLOW_COPY_AND_ASSIGN(HistogramCustomizer); |
| 398 | }; |
| 399 | |
| 400 | HistogramCustomizer* histogram_customizer() { |
| 401 | return &histogram_customizer_; |
| 402 | } |
| 403 | |
ben | f28ce88 | 2017-05-02 16:15:49 | [diff] [blame] | 404 | void RegisterPendingFrameCreate( |
ben | f28ce88 | 2017-05-02 16:15:49 | [diff] [blame] | 405 | int routing_id, |
Henrique Ferreiro | 3a9751c | 2019-09-30 13:54:07 | [diff] [blame] | 406 | mojo::PendingReceiver<mojom::Frame> frame); |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 407 | |
jam | 188f19f | 2017-06-07 03:56:24 | [diff] [blame] | 408 | mojom::RendererHost* GetRendererHost(); |
jam | c912ca3 | 2016-02-24 20:17:31 | [diff] [blame] | 409 | |
keishi | 51ed0d5 | 2017-01-12 10:04:46 | [diff] [blame] | 410 | struct RendererMemoryMetrics { |
| 411 | size_t partition_alloc_kb; |
| 412 | size_t blink_gc_kb; |
| 413 | size_t malloc_mb; |
| 414 | size_t discardable_kb; |
| 415 | size_t v8_main_thread_isolate_mb; |
| 416 | size_t total_allocated_mb; |
| 417 | size_t non_discardable_total_allocated_mb; |
| 418 | size_t total_allocated_per_render_view_mb; |
| 419 | }; |
bashi | a0ba0d4 | 2017-04-03 08:11:06 | [diff] [blame] | 420 | bool GetRendererMemoryMetrics(RendererMemoryMetrics* memory_metrics) const; |
keishi | 51ed0d5 | 2017-01-12 10:04:46 | [diff] [blame] | 421 | |
Takashi SAKAMOTO | 870f626 | 2017-08-22 04:08:27 | [diff] [blame] | 422 | bool NeedsToRecordFirstActivePaint(int metric_type) const; |
tasak | b95dbb50c | 2017-02-08 18:07:50 | [diff] [blame] | 423 | |
Aditya Keerthi | e84331b3 | 2019-03-20 15:25:52 | [diff] [blame] | 424 | void RecordMetricsForBackgroundedRendererPurge(); |
| 425 | |
Miguel Casas | 5e101805 | 2018-01-09 19:17:36 | [diff] [blame] | 426 | // Sets the current pipeline rendering color space. |
| 427 | void SetRenderingColorSpace(const gfx::ColorSpace& color_space); |
| 428 | |
CJ DiMeglio | 79f7c91a2 | 2018-08-30 22:24:43 | [diff] [blame] | 429 | scoped_refptr<base::SingleThreadTaskRunner> |
| 430 | CreateVideoFrameCompositorTaskRunner(); |
| 431 | |
CJ DiMeglio | b6eb9cd | 2018-11-06 23:44:01 | [diff] [blame] | 432 | // In the case of kOnDemand, we wont be using the task_runner created in |
| 433 | // CreateVideoFrameCompositorTaskRunner. |
| 434 | // TODO(https://crbug/901513): Remove once kOnDemand is removed. |
| 435 | void SetVideoFrameCompositorTaskRunner( |
| 436 | scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 437 | video_frame_compositor_task_runner_ = task_runner; |
| 438 | } |
| 439 | |
[email protected] | 8930d47 | 2009-02-21 08:05:28 | [diff] [blame] | 440 | private: |
Aditya Keerthi | c0d45b4 | 2019-02-25 18:53:00 | [diff] [blame] | 441 | friend class RenderThreadImplBrowserTest; |
| 442 | |
Nicholas Verne | 06de812 | 2017-11-16 04:47:38 | [diff] [blame] | 443 | void OnProcessFinalRelease() override; |
torne | 88b6645 | 2016-05-03 13:22:14 | [diff] [blame] | 444 | // IPC::Listener |
| 445 | void OnChannelError() override; |
| 446 | |
[email protected] | 57cf9788 | 2013-06-26 20:39:01 | [diff] [blame] | 447 | // ChildThread |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 448 | bool OnControlMessageReceived(const IPC::Message& msg) override; |
liberato | 3aeeb2c | 2016-02-25 17:54:38 | [diff] [blame] | 449 | void RecordAction(const base::UserMetricsAction& action) override; |
| 450 | void RecordComputedAction(const std::string& action) override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 451 | |
sadrul | 5354659 | 2016-12-17 01:44:21 | [diff] [blame] | 452 | bool IsMainThread(); |
[email protected] | 57cf9788 | 2013-06-26 20:39:01 | [diff] [blame] | 453 | |
bashi | b9058f28 | 2017-03-30 01:55:24 | [diff] [blame] | 454 | void RecordPurgeMemory(RendererMemoryMetrics before); |
| 455 | |
Greg Kraynov | f5d6027 | 2018-08-10 12:28:51 | [diff] [blame] | 456 | void Init(); |
vollick | 1050cc6 | 2015-12-03 07:04:54 | [diff] [blame] | 457 | void InitializeCompositorThread(); |
Ken Rockot | 13051c93 | 2019-11-14 20:11:51 | [diff] [blame] | 458 | void InitializeWebKit(mojo::BinderMap* binders); |
jam | 75c4422 | 2016-03-23 05:34:24 | [diff] [blame] | 459 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 460 | void OnTransferBitmap(const SkBitmap& bitmap, int resource_id); |
[email protected] | b3df5a4 | 2010-05-11 14:31:09 | [diff] [blame] | 461 | void OnGetAccessibilityTree(); |
blundell | c00adf44 | 2016-09-16 10:43:41 | [diff] [blame] | 462 | |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 463 | // mojom::Renderer: |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 464 | void CreateView(mojom::CreateViewParamsPtr params) override; |
Erik Chen | 3433ee0 | 2019-08-05 20:14:26 | [diff] [blame] | 465 | void DestroyView(int32_t view_id) override; |
rockot | 53be7caf | 2016-10-04 20:17:08 | [diff] [blame] | 466 | void CreateFrame(mojom::CreateFrameParamsPtr params) override; |
Dmitry Gozman | 8936121 | 2018-02-13 16:10:44 | [diff] [blame] | 467 | void CreateFrameProxy( |
| 468 | int32_t routing_id, |
| 469 | int32_t render_view_routing_id, |
| 470 | int32_t opener_routing_id, |
| 471 | int32_t parent_routing_id, |
| 472 | const FrameReplicationState& replicated_state, |
| 473 | const base::UnguessableToken& devtools_frame_token) override; |
rockot | a2db0da | 2016-10-18 17:39:11 | [diff] [blame] | 474 | void OnNetworkConnectionChanged( |
| 475 | net::NetworkChangeNotifier::ConnectionType type, |
| 476 | double max_bandwidth_mbps) override; |
tbansal | b612c5d | 2017-05-25 18:53:06 | [diff] [blame] | 477 | void OnNetworkQualityChanged(net::EffectiveConnectionType type, |
| 478 | base::TimeDelta http_rtt, |
tbansal | 99d8aeb | 2017-05-22 19:12:58 | [diff] [blame] | 479 | base::TimeDelta transport_rtt, |
tbansal | 15973c3 | 2017-05-10 18:40:44 | [diff] [blame] | 480 | double bandwidth_kbps) override; |
rockot | a2db0da | 2016-10-18 17:39:11 | [diff] [blame] | 481 | void SetWebKitSharedTimersSuspended(bool suspend) override; |
Yutaka Hirano | b0465f7 | 2018-05-17 05:48:25 | [diff] [blame] | 482 | void SetUserAgent(const std::string& user_agent) override; |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 483 | void SetUserAgentMetadata(const blink::UserAgentMetadata& metadata) override; |
rockot | a2db0da | 2016-10-18 17:39:11 | [diff] [blame] | 484 | void UpdateScrollbarTheme( |
| 485 | mojom::UpdateScrollbarThemeParamsPtr params) override; |
| 486 | void OnSystemColorsChanged(int32_t aqua_color_variant, |
| 487 | const std::string& highlight_text_color, |
| 488 | const std::string& highlight_color) override; |
Ionel Popescu | 237e8e3 | 2019-08-07 19:50:54 | [diff] [blame] | 489 | void UpdateSystemColorInfo( |
| 490 | mojom::UpdateSystemColorInfoParamsPtr params) override; |
rockot | a2db0da | 2016-10-18 17:39:11 | [diff] [blame] | 491 | void PurgePluginListCache(bool reload_pages) override; |
John Budorick | ee1c951 | 2019-10-17 15:32:19 | [diff] [blame] | 492 | void SetProcessState(mojom::RenderProcessBackgroundState background_state, |
| 493 | mojom::RenderProcessVisibleState visible_state) override; |
Shubhie Panicker | 45ce80a8 | 2018-02-01 01:40:19 | [diff] [blame] | 494 | void SetSchedulerKeepActive(bool keep_active) override; |
Nasko Oskov | 1c2c049 | 2019-03-14 20:13:39 | [diff] [blame] | 495 | void SetIsLockedToSite() override; |
Robert Sesek | 6e3d725c | 2018-06-06 14:38:02 | [diff] [blame] | 496 | void EnableV8LowMemoryMode() override; |
Sebastien Marchand | 836d04b3 | 2020-04-28 18:10:03 | [diff] [blame^] | 497 | #if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX) |
| 498 | void WriteClangProfilingProfile( |
| 499 | WriteClangProfilingProfileCallback callback) override; |
| 500 | #endif |
[email protected] | 5071cb2 | 2013-07-10 02:19:06 | [diff] [blame] | 501 | void OnMemoryPressure( |
| 502 | base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
rockot | a2db0da | 2016-10-18 17:39:11 | [diff] [blame] | 503 | |
rmcilroy | aa29605 | 2015-04-14 15:35:27 | [diff] [blame] | 504 | bool RendererIsHidden() const; |
| 505 | void OnRendererHidden(); |
| 506 | void OnRendererVisible(); |
[email protected] | b3df5a4 | 2010-05-11 14:31:09 | [diff] [blame] | 507 | |
Aditya Keerthi | c0d45b4 | 2019-02-25 18:53:00 | [diff] [blame] | 508 | bool RendererIsBackgrounded() const; |
| 509 | void OnRendererBackgrounded(); |
| 510 | void OnRendererForegrounded(); |
| 511 | |
tasak | 335a187 | 2017-06-14 09:50:23 | [diff] [blame] | 512 | void RecordMemoryUsageAfterBackgrounded(const char* suffix, |
| 513 | int foregrounded_count); |
Aditya Keerthi | e84331b3 | 2019-03-20 15:25:52 | [diff] [blame] | 514 | void OnRecordMetricsForBackgroundedRendererPurgeTimerExpired( |
tasak | bb0640b | 2017-05-15 09:02:26 | [diff] [blame] | 515 | const char* suffix, |
| 516 | int foregrounded_count_when_purged); |
tasak | b46626a | 2016-10-18 05:54:44 | [diff] [blame] | 517 | |
ssid | 0603ca9f | 2015-06-09 16:48:08 | [diff] [blame] | 518 | void ReleaseFreeMemory(); |
| 519 | |
hong.zheng | b28b533 | 2016-05-11 02:33:39 | [diff] [blame] | 520 | void OnSyncMemoryPressure( |
| 521 | base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 522 | |
Fady Samuel | c645ffe | 2017-07-24 17:28:20 | [diff] [blame] | 523 | std::unique_ptr<viz::SyntheticBeginFrameSource> |
samans | 09812d3 | 2017-03-27 19:51:50 | [diff] [blame] | 524 | CreateSyntheticBeginFrameSource(); |
| 525 | |
Julie Jeongeun Kim | 4e77af262 | 2019-09-11 03:36:45 | [diff] [blame] | 526 | void OnRendererInterfaceReceiver( |
| 527 | mojo::PendingAssociatedReceiver<mojom::Renderer> receiver); |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 528 | |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 529 | std::unique_ptr<base::DiscardableMemoryAllocator> |
| 530 | discardable_memory_allocator_; |
penghuang | 342762b | 2016-12-02 21:04:58 | [diff] [blame] | 531 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 532 | // These objects live solely on the render thread. |
Yuta Kitamura | deb91bb | 2018-05-29 05:53:20 | [diff] [blame] | 533 | std::unique_ptr<blink::scheduler::WebThreadScheduler> main_thread_scheduler_; |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 534 | std::unique_ptr<RendererBlinkPlatformImpl> blink_platform_impl_; |
John Abd-El-Malek | 6b56ef71 | 2017-10-21 22:52:46 | [diff] [blame] | 535 | std::unique_ptr<ResourceDispatcher> resource_dispatcher_; |
Yuzhu Shen | fe5f3a5 | 2018-01-11 21:24:13 | [diff] [blame] | 536 | std::unique_ptr<URLLoaderThrottleProvider> url_loader_throttle_provider_; |
[email protected] | 9291ed1 | 2009-07-23 17:33:22 | [diff] [blame] | 537 | |
Yuzu Saijo | 9acd7e6 | 2019-06-12 10:05:31 | [diff] [blame] | 538 | // Filter out unfreezable messages and pass it to unfreezable task runners. |
| 539 | scoped_refptr<UnfreezableMessageFilter> unfreezable_message_filter_; |
| 540 | |
Max Morin | 3d464a4 | 2018-01-15 11:17:00 | [diff] [blame] | 541 | // Provides AudioInputIPC objects for audio input devices. Initialized in |
| 542 | // Init. |
| 543 | base::Optional<AudioInputIPCFactory> audio_input_ipc_factory_; |
Max Morin | 2c38c28 | 2018-04-17 07:01:42 | [diff] [blame] | 544 | // Provides AudioOutputIPC objects for audio output devices. Initialized in |
| 545 | // Init. |
Max Morin | 3d464a4 | 2018-01-15 11:17:00 | [diff] [blame] | 546 | base::Optional<AudioOutputIPCFactory> audio_output_ipc_factory_; |
maxmorin | 017ba8c6 | 2017-06-02 10:23:09 | [diff] [blame] | 547 | |
liushouqun | 517b129 | 2016-09-14 05:58:59 | [diff] [blame] | 548 | // Used on the render thread. |
Antonio Gomes | 925f9b9 | 2019-07-30 23:23:23 | [diff] [blame] | 549 | std::unique_ptr<blink::WebVideoCaptureImplManager> vc_manager_; |
[email protected] | da9f30a | 2014-06-18 19:39:04 | [diff] [blame] | 550 | |
Aditya Keerthi | c0d45b4 | 2019-02-25 18:53:00 | [diff] [blame] | 551 | // Used to keep track of the renderer's backgrounded and visibility state. |
| 552 | // Updated via an IPC from the browser process. If nullopt, the browser |
| 553 | // process has yet to send an update and the state is unknown. |
John Budorick | ee1c951 | 2019-10-17 15:32:19 | [diff] [blame] | 554 | base::Optional<mojom::RenderProcessBackgroundState> background_state_; |
| 555 | base::Optional<mojom::RenderProcessVisibleState> visible_state_; |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 556 | |
Yutaka Hirano | b0465f7 | 2018-05-17 05:48:25 | [diff] [blame] | 557 | blink::WebString user_agent_; |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 558 | blink::UserAgentMetadata user_agent_metadata_; |
Yutaka Hirano | b0465f7 | 2018-05-17 05:48:25 | [diff] [blame] | 559 | |
Kent Tamura | 2eab5b1 | 2018-12-07 04:31:23 | [diff] [blame] | 560 | // Used to control web test specific behavior. |
danakj | becba32 | 2019-03-29 17:13:46 | [diff] [blame] | 561 | bool web_test_mode_ = false; |
[email protected] | 233567d | 2013-02-27 20:22:02 | [diff] [blame] | 562 | |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 563 | // Sticky once true, indicates that compositing is done without Gpu, so |
| 564 | // resources given to the compositor or to the viz service should be |
| 565 | // software-based. |
| 566 | bool is_gpu_compositing_disabled_ = false; |
| 567 | |
dcastagna | 7f45dada | 2015-10-19 20:17:35 | [diff] [blame] | 568 | // Utility class to provide GPU functionalities to media. |
dcastagna | 09bd6b3 | 2016-02-01 21:54:28 | [diff] [blame] | 569 | // TODO(dcastagna): This should be just one scoped_ptr once |
| 570 | // http://crbug.com/580386 is fixed. |
| 571 | // NOTE(dcastagna): At worst this accumulates a few bytes per context lost. |
Miguel Casas-Sanchez | cfcca5d5 | 2017-07-07 02:32:59 | [diff] [blame] | 572 | std::vector<std::unique_ptr<GpuVideoAcceleratorFactoriesImpl>> gpu_factories_; |
dcastagna | 7f45dada | 2015-10-19 20:17:35 | [diff] [blame] | 573 | |
[email protected] | c1330c8 | 2013-06-06 02:23:25 | [diff] [blame] | 574 | // Thread for running multimedia operations (e.g., video decoding). |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 575 | std::unique_ptr<base::Thread> media_thread_; |
[email protected] | c1330c8 | 2013-06-06 02:23:25 | [diff] [blame] | 576 | |
skyostil | 2d3b5bd | 2015-05-27 15:40:59 | [diff] [blame] | 577 | // Will point to appropriate task runner after initialization, |
[email protected] | ea5f70a | 2013-03-07 12:30:36 | [diff] [blame] | 578 | // regardless of whether |compositor_thread_| is overriden. |
skyostil | 2d3b5bd | 2015-05-27 15:40:59 | [diff] [blame] | 579 | scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
[email protected] | ea5f70a | 2013-03-07 12:30:36 | [diff] [blame] | 580 | |
CJ DiMeglio | 79f7c91a2 | 2018-08-30 22:24:43 | [diff] [blame] | 581 | // Task to run the VideoFrameCompositor on. |
| 582 | scoped_refptr<base::SingleThreadTaskRunner> |
| 583 | video_frame_compositor_task_runner_; |
| 584 | |
dcastagna | b880e8f | 2015-06-30 20:16:06 | [diff] [blame] | 585 | // Pool of workers used for raster operations (e.g., tile rasterization). |
prashant.n | fad657e | 2016-06-01 07:52:17 | [diff] [blame] | 586 | scoped_refptr<CategorizedWorkerPool> categorized_worker_pool_; |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 587 | |
boliu | bee541f4 | 2015-11-05 00:52:53 | [diff] [blame] | 588 | #if defined(OS_ANDROID) |
siva.gunturi | 5d4feb05 | 2015-11-15 16:15:31 | [diff] [blame] | 589 | scoped_refptr<StreamTextureFactory> stream_texture_factory_; |
boliu | bee541f4 | 2015-11-05 00:52:53 | [diff] [blame] | 590 | #endif |
| 591 | |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 592 | scoped_refptr<viz::ContextProviderCommandBuffer> shared_main_thread_contexts_; |
[email protected] | c29b7ff | 2013-03-06 03:51:04 | [diff] [blame] | 593 | |
Trent Apted | a250ec3ab | 2018-08-19 08:52:19 | [diff] [blame] | 594 | base::ObserverList<RenderThreadObserver>::Unchecked observers_; |
[email protected] | 1223d6ef | 2011-03-28 16:47:50 | [diff] [blame] | 595 | |
Sergey Ulanov | 83f4a15 | 2019-02-14 03:54:25 | [diff] [blame] | 596 | scoped_refptr<viz::RasterContextProvider> |
| 597 | video_frame_compositor_context_provider_; |
CJ DiMeglio | 79f7c91a2 | 2018-08-30 22:24:43 | [diff] [blame] | 598 | |
Victor Miura | ff648861 | 2017-12-21 04:16:15 | [diff] [blame] | 599 | scoped_refptr<viz::RasterContextProvider> shared_worker_context_provider_; |
[email protected] | 3b2afc3 | 2012-06-18 21:31:16 | [diff] [blame] | 600 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 601 | std::unique_ptr<AudioRendererMixerManager> audio_renderer_mixer_manager_; |
[email protected] | 3958e97 | 2012-07-17 00:25:41 | [diff] [blame] | 602 | |
[email protected] | b2d9876 | 2012-09-03 17:04:06 | [diff] [blame] | 603 | HistogramCustomizer histogram_customizer_; |
| 604 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 605 | std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
[email protected] | 5071cb2 | 2013-07-10 02:19:06 | [diff] [blame] | 606 | |
Robert Sesek | 6e3d725c | 2018-06-06 14:38:02 | [diff] [blame] | 607 | // Created in response to EnableV8LowMemoryMode(), this manages V8's |
| 608 | // memory saving mode. |
| 609 | std::unique_ptr<LowMemoryModeController> low_memory_mode_controller_; |
| 610 | |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 611 | std::unique_ptr<viz::Gpu> gpu_; |
sadrul | 9e0bb1d | 2016-08-04 20:18:39 | [diff] [blame] | 612 | |
Alex Clarke | 9fc39b9b | 2020-01-31 17:29:47 | [diff] [blame] | 613 | std::unique_ptr<VariationsRenderThreadObserver> variations_observer_; |
| 614 | |
skyostil | 457b0a1 | 2014-09-09 10:12:07 | [diff] [blame] | 615 | scoped_refptr<base::SingleThreadTaskRunner> |
| 616 | main_thread_compositor_task_runner_; |
skyostil | 457b0a1 | 2014-09-09 10:12:07 | [diff] [blame] | 617 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 618 | // Compositor settings. |
senorblanco | b60ba95 | 2015-01-27 19:12:36 | [diff] [blame] | 619 | int gpu_rasterization_msaa_sample_count_; |
[email protected] | a23530d | 2014-03-11 06:04:14 | [diff] [blame] | 620 | bool is_lcd_text_enabled_; |
[email protected] | 2cccfef | 2014-05-01 06:05:16 | [diff] [blame] | 621 | bool is_zero_copy_enabled_; |
ccameron | c7fcd13 | 2015-11-03 20:14:31 | [diff] [blame] | 622 | bool is_gpu_memory_buffer_compositor_resources_enabled_; |
ericrk | 1d17f75 | 2015-10-20 03:03:07 | [diff] [blame] | 623 | bool is_partial_raster_enabled_; |
ccameron | a764475 | 2014-12-30 01:16:31 | [diff] [blame] | 624 | bool is_elastic_overscroll_enabled_; |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 625 | bool is_zoom_for_dsf_enabled_; |
loyso | 65c93c60 | 2015-08-11 05:15:57 | [diff] [blame] | 626 | bool is_threaded_animation_enabled_; |
wjmaclean | 1d97062 | 2017-01-21 22:28:24 | [diff] [blame] | 627 | bool is_scroll_animator_enabled_; |
[email protected] | a23530d | 2014-03-11 06:04:14 | [diff] [blame] | 628 | |
Miguel Casas | 5e101805 | 2018-01-09 19:17:36 | [diff] [blame] | 629 | // Target rendering ColorSpace. |
| 630 | gfx::ColorSpace rendering_color_space_; |
| 631 | |
ben | 76f52b24 | 2016-06-18 05:42:48 | [diff] [blame] | 632 | class PendingFrameCreate : public base::RefCounted<PendingFrameCreate> { |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 633 | public: |
Ken Rockot | 13051c93 | 2019-11-14 20:11:51 | [diff] [blame] | 634 | PendingFrameCreate(int routing_id, |
Henrique Ferreiro | 3a9751c | 2019-09-30 13:54:07 | [diff] [blame] | 635 | mojo::PendingReceiver<mojom::Frame> frame_receiver); |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 636 | |
Henrique Ferreiro | 3a9751c | 2019-09-30 13:54:07 | [diff] [blame] | 637 | mojo::PendingReceiver<mojom::Frame> TakeFrameReceiver() { |
| 638 | return std::move(frame_receiver_); |
| 639 | } |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 640 | |
| 641 | private: |
ben | 76f52b24 | 2016-06-18 05:42:48 | [diff] [blame] | 642 | friend class base::RefCounted<PendingFrameCreate>; |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 643 | |
ben | 76f52b24 | 2016-06-18 05:42:48 | [diff] [blame] | 644 | ~PendingFrameCreate(); |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 645 | |
| 646 | // Mojo error handler. |
| 647 | void OnConnectionError(); |
| 648 | |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 649 | int routing_id_; |
Henrique Ferreiro | 3a9751c | 2019-09-30 13:54:07 | [diff] [blame] | 650 | mojo::PendingReceiver<mojom::Frame> frame_receiver_; |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 651 | }; |
| 652 | |
ben | 76f52b24 | 2016-06-18 05:42:48 | [diff] [blame] | 653 | using PendingFrameCreateMap = |
| 654 | std::map<int, scoped_refptr<PendingFrameCreate>>; |
| 655 | PendingFrameCreateMap pending_frame_creates_; |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 656 | |
Julie Jeongeun Kim | daa9aa1 | 2019-10-24 02:51:56 | [diff] [blame] | 657 | mojo::AssociatedRemote<mojom::RendererHost> renderer_host_; |
jam | c912ca3 | 2016-02-24 20:17:31 | [diff] [blame] | 658 | |
Ken Rockot | 26e4e80 | 2018-07-31 15:03:33 | [diff] [blame] | 659 | blink::AssociatedInterfaceRegistry associated_interfaces_; |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 660 | |
Julie Jeongeun Kim | 4e77af262 | 2019-09-11 03:36:45 | [diff] [blame] | 661 | mojo::AssociatedReceiver<mojom::Renderer> renderer_receiver_{this}; |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 662 | |
Julie Jeongeun Kim | 23966e2 | 2019-10-26 02:13:29 | [diff] [blame] | 663 | mojo::AssociatedRemote<mojom::RenderMessageFilter> render_message_filter_; |
rockot | 1587e33 | 2016-07-27 17:44:14 | [diff] [blame] | 664 | |
Kouhei Ueno | 23f0759f | 2020-02-17 04:50:42 | [diff] [blame] | 665 | std::unique_ptr<blink::WebIsolate> isolate_; |
| 666 | |
tasak | 72f6404 | 2017-01-19 14:02:53 | [diff] [blame] | 667 | RendererMemoryMetrics purge_and_suspend_memory_metrics_; |
tasak | b95dbb50c | 2017-02-08 18:07:50 | [diff] [blame] | 668 | bool needs_to_record_first_active_paint_; |
Takashi SAKAMOTO | 870f626 | 2017-08-22 04:08:27 | [diff] [blame] | 669 | base::TimeTicks was_backgrounded_time_; |
tasak | bb0640b | 2017-05-15 09:02:26 | [diff] [blame] | 670 | int process_foregrounded_count_; |
Nasko Oskov | 3d0d1dc | 2018-09-25 03:57:13 | [diff] [blame] | 671 | bool online_status_ = true; |
hajimehoshi | 6909327 | 2016-05-13 08:30:58 | [diff] [blame] | 672 | |
staraz | 067f5824 | 2016-11-07 21:06:41 | [diff] [blame] | 673 | int32_t client_id_; |
| 674 | |
Mario Sanchez Prada | 5492c9a | 2019-09-10 20:58:11 | [diff] [blame] | 675 | mojo::Remote<mojom::FrameSinkProvider> frame_sink_provider_; |
samans | 2040988b | 2017-04-11 23:58:35 | [diff] [blame] | 676 | |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 677 | // A mojo connection to the CompositingModeReporter service. |
Gyuyoung Kim | c9cf74a | 2019-11-05 00:54:35 | [diff] [blame] | 678 | mojo::Remote<viz::mojom::CompositingModeReporter> compositing_mode_reporter_; |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 679 | // The class is a CompositingModeWatcher, which is bound to mojo through |
danakj | 4ee301c | 2017-11-29 16:19:43 | [diff] [blame] | 680 | // this member. |
Gyuyoung Kim | ef648a2e7 | 2019-09-17 09:48:35 | [diff] [blame] | 681 | mojo::Receiver<viz::mojom::CompositingModeWatcher> |
| 682 | compositing_mode_watcher_receiver_{this}; |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 683 | |
Jeremy Roman | 3bca4bf | 2019-07-11 03:41:25 | [diff] [blame] | 684 | base::WeakPtrFactory<RenderThreadImpl> weak_factory_{this}; |
Ben Goodger | f180ce1 | 2018-02-09 22:54:01 | [diff] [blame] | 685 | |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 686 | DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 687 | }; |
| 688 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 689 | } // namespace content |
| 690 | |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 691 | #endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ |