[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" |
Tal Pressman | c951ed9 | 2020-09-01 00:24:23 | [diff] [blame] | 20 | #include "base/containers/unique_ptr_adapters.h" |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 21 | #include "base/macros.h" |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 22 | #include "base/memory/discardable_memory_allocator.h" |
[email protected] | 5071cb2 | 2013-07-10 02:19:06 | [diff] [blame] | 23 | #include "base/memory/memory_pressure_listener.h" |
rockot | 775ce0d | 2015-01-27 18:35:01 | [diff] [blame] | 24 | #include "base/memory/ref_counted.h" |
[email protected] | e6e30ac | 2014-01-13 21:24:39 | [diff] [blame] | 25 | #include "base/metrics/user_metrics_action.h" |
[email protected] | 1223d6ef | 2011-03-28 16:47:50 | [diff] [blame] | 26 | #include "base/observer_list.h" |
maxmorin | 017ba8c6 | 2017-06-02 10:23:09 | [diff] [blame] | 27 | #include "base/optional.h" |
tbansal | 99d8aeb | 2017-05-22 19:12:58 | [diff] [blame] | 28 | #include "base/time/time.h" |
Peter Kasting | 796cde2 | 2020-11-18 21:06:53 | [diff] [blame] | 29 | #include "base/types/pass_key.h" |
[email protected] | 037fce0 | 2009-01-22 01:42:15 | [diff] [blame] | 30 | #include "build/build_config.h" |
jam | 8a021512a | 2015-02-03 18:16:08 | [diff] [blame] | 31 | #include "content/child/child_thread_impl.h" |
Tal Pressman | c951ed9 | 2020-09-01 00:24:23 | [diff] [blame] | 32 | #include "content/common/agent_scheduling_group.mojom.h" |
[email protected] | 8d128d6 | 2011-09-13 22:11:57 | [diff] [blame] | 33 | #include "content/common/content_export.h" |
ben | 76f52b24 | 2016-06-18 05:42:48 | [diff] [blame] | 34 | #include "content/common/frame.mojom.h" |
rockot | e261d211 | 2016-09-21 22:22:23 | [diff] [blame] | 35 | #include "content/common/render_message_filter.mojom.h" |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 36 | #include "content/common/renderer.mojom.h" |
jam | 188f19f | 2017-06-07 03:56:24 | [diff] [blame] | 37 | #include "content/common/renderer_host.mojom.h" |
[email protected] | 52647690 | 2011-10-06 20:34:06 | [diff] [blame] | 38 | #include "content/public/renderer/render_thread.h" |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 39 | #include "content/renderer/discardable_memory_utils.h" |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 40 | #include "gpu/ipc/client/gpu_channel_host.h" |
Antoine Labour | e55c9ef8 | 2017-11-10 18:51:23 | [diff] [blame] | 41 | #include "ipc/ipc_sync_channel.h" |
Scott Violet | a35f9a4 | 2018-03-22 22:00:44 | [diff] [blame] | 42 | #include "media/media_buildflags.h" |
Julie Jeongeun Kim | 4e77af262 | 2019-09-11 03:36:45 | [diff] [blame] | 43 | #include "mojo/public/cpp/bindings/associated_receiver.h" |
Julie Jeongeun Kim | daa9aa1 | 2019-10-24 02:51:56 | [diff] [blame] | 44 | #include "mojo/public/cpp/bindings/associated_remote.h" |
Julie Jeongeun Kim | 4e77af262 | 2019-09-11 03:36:45 | [diff] [blame] | 45 | #include "mojo/public/cpp/bindings/pending_associated_receiver.h" |
Julie Jeongeun Kim | 4421c2e | 2019-09-11 06:34:39 | [diff] [blame] | 46 | #include "mojo/public/cpp/bindings/pending_receiver.h" |
Julie Jeongeun Kim | 6f4b7e0 | 2019-09-11 05:05:46 | [diff] [blame] | 47 | #include "mojo/public/cpp/bindings/pending_remote.h" |
Gyuyoung Kim | ef648a2e7 | 2019-09-17 09:48:35 | [diff] [blame] | 48 | #include "mojo/public/cpp/bindings/receiver.h" |
Mario Sanchez Prada | 5492c9a | 2019-09-10 20:58:11 | [diff] [blame] | 49 | #include "mojo/public/cpp/bindings/remote.h" |
[email protected] | d7ff5fb | 2014-05-29 19:50:25 | [diff] [blame] | 50 | #include "net/base/network_change_notifier.h" |
tbansal | b612c5d | 2017-05-25 18:53:06 | [diff] [blame] | 51 | #include "net/nqe/effective_connection_type.h" |
Miyoung Shin | 99505dd | 2019-07-27 12:45:35 | [diff] [blame] | 52 | #include "services/viz/public/mojom/compositing/compositing_mode_watcher.mojom.h" |
Ken Rockot | 26e4e80 | 2018-07-31 15:03:33 | [diff] [blame] | 53 | #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 54 | #include "third_party/blink/public/common/user_agent/user_agent_metadata.h" |
Kent Tamura | 38fb434 | 2018-07-25 12:47:53 | [diff] [blame] | 55 | #include "third_party/blink/public/platform/scheduler/web_rail_mode_observer.h" |
Daniel Murphy | 738378c | 2019-05-31 21:59:25 | [diff] [blame] | 56 | #include "third_party/blink/public/platform/scheduler/web_thread_scheduler.h" |
Minggang Wang | 1df377df | 2021-03-08 04:45:40 | [diff] [blame] | 57 | #include "third_party/blink/public/platform/url_loader_throttle_provider.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 58 | #include "third_party/blink/public/platform/web_connection_type.h" |
| 59 | #include "third_party/blink/public/web/web_memory_statistics.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 60 | #include "ui/gfx/native_widget_types.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 61 | |
[email protected] | 39008c0 | 2009-02-11 23:59:25 | [diff] [blame] | 62 | class SkBitmap; |
[email protected] | 46f36a49 | 2010-07-28 19:36:41 | [diff] [blame] | 63 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 64 | namespace blink { |
Minggang Wang | 8cd77ac | 2021-01-30 18:00:44 | [diff] [blame] | 65 | class WebResourceRequestSenderDelegate; |
Antonio Gomes | 925f9b9 | 2019-07-30 23:23:23 | [diff] [blame] | 66 | class WebVideoCaptureImplManager; |
[email protected] | b7c7bcf | 2009-10-03 07:07:34 | [diff] [blame] | 67 | } |
| 68 | |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 69 | namespace base { |
skyostil | 457b0a1 | 2014-09-09 10:12:07 | [diff] [blame] | 70 | class SingleThreadTaskRunner; |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 71 | class Thread; |
| 72 | } |
| 73 | |
[email protected] | c29b7ff | 2013-03-06 03:51:04 | [diff] [blame] | 74 | namespace cc { |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 75 | class TaskGraphRunner; |
[email protected] | c29b7ff | 2013-03-06 03:51:04 | [diff] [blame] | 76 | } |
| 77 | |
Bo Liu | 8a39c478 | 2021-03-06 00:50:54 | [diff] [blame] | 78 | namespace gfx { |
| 79 | class RenderingPipeline; |
| 80 | } |
| 81 | |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 82 | namespace gpu { |
| 83 | class GpuChannelHost; |
| 84 | } |
| 85 | |
[email protected] | 563d665f | 2013-02-01 04:42:39 | [diff] [blame] | 86 | namespace media { |
Frank Liberato | 3afa598 | 2020-12-10 06:13:44 | [diff] [blame] | 87 | class DecoderFactory; |
[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; |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 99 | } // namespace viz |
Scott Violet | 7e33efc | 2018-08-29 22:30:15 | [diff] [blame] | 100 | |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 101 | namespace content { |
Tal Pressman | 9780e2c | 2020-08-26 06:35:09 | [diff] [blame] | 102 | class AgentSchedulingGroup; |
John Abd-El-Malek | e1d4de3 | 2017-10-21 16:14:29 | [diff] [blame] | 103 | class CategorizedWorkerPool; |
John Abd-El-Malek | e1d4de3 | 2017-10-21 16:14:29 | [diff] [blame] | 104 | class GpuVideoAcceleratorFactoriesImpl; |
Frank Liberato | 3afa598 | 2020-12-10 06:13:44 | [diff] [blame] | 105 | class MediaInterfaceFactory; |
danakj | 0bdfacd | 2021-01-20 19:27:18 | [diff] [blame] | 106 | class RenderFrameImpl; |
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; |
Alex Clarke | 9fc39b9b | 2020-01-31 17:29:47 | [diff] [blame] | 109 | class VariationsRenderThreadObserver; |
[email protected] | cb25aa1 | 2012-08-07 19:13:43 | [diff] [blame] | 110 | |
boliu | bee541f4 | 2015-11-05 00:52:53 | [diff] [blame] | 111 | #if defined(OS_ANDROID) |
siva.gunturi | 5d4feb05 | 2015-11-15 16:15:31 | [diff] [blame] | 112 | class StreamTextureFactory; |
boliu | bee541f4 | 2015-11-05 00:52:53 | [diff] [blame] | 113 | #endif |
| 114 | |
Matt Falkenhagen | ef13d78 | 2019-05-30 21:02:12 | [diff] [blame] | 115 | // The RenderThreadImpl class represents the main thread, where RenderView |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 116 | // instances live. The RenderThread supports an API that is used by its |
| 117 | // consumer to talk indirectly to the RenderViews and supporting objects. |
| 118 | // 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] | 119 | // process (i.e., their corresponding WebContentsImpl). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 120 | // |
| 121 | // Most of the communication occurs in the form of IPC messages. They are |
| 122 | // routed to the RenderThread according to the routing IDs of the messages. |
| 123 | // The routing IDs correspond to RenderView instances. |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 124 | class CONTENT_EXPORT RenderThreadImpl |
| 125 | : public RenderThread, |
jam | 8a021512a | 2015-02-03 18:16:08 | [diff] [blame] | 126 | public ChildThreadImpl, |
Nico Weber | 43ddd7a3 | 2017-08-15 19:19:27 | [diff] [blame] | 127 | public mojom::Renderer, |
Dave Tapuska | b0d6713 | 2021-05-12 03:14:24 | [diff] [blame] | 128 | public viz::mojom::CompositingModeWatcher { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 129 | public: |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 130 | static RenderThreadImpl* current(); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 131 | static mojom::RenderMessageFilter* current_render_message_filter(); |
olegmax | 045f7fb1 | 2017-05-19 07:58:55 | [diff] [blame] | 132 | static RendererBlinkPlatformImpl* current_blink_platform_impl(); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 133 | |
| 134 | static void SetRenderMessageFilterForTesting( |
| 135 | mojom::RenderMessageFilter* render_message_filter); |
olegmax | 045f7fb1 | 2017-05-19 07:58:55 | [diff] [blame] | 136 | static void SetRendererBlinkPlatformImplForTesting( |
| 137 | RendererBlinkPlatformImpl* blink_platform_impl); |
[email protected] | 52647690 | 2011-10-06 20:34:06 | [diff] [blame] | 138 | |
John Abd-El-Malek | d488264 | 2017-12-04 21:45:19 | [diff] [blame] | 139 | // Returns the task runner for the main thread where the RenderThread lives. |
Hajime Hoshi | 20578c6 | 2018-01-12 09:43:26 | [diff] [blame] | 140 | static scoped_refptr<base::SingleThreadTaskRunner> |
| 141 | DeprecatedGetMainTaskRunner(); |
John Abd-El-Malek | d488264 | 2017-12-04 21:45:19 | [diff] [blame] | 142 | |
Wez | 6979109b | 2018-09-07 17:30:56 | [diff] [blame] | 143 | RenderThreadImpl( |
| 144 | base::RepeatingClosure quit_closure, |
Greg Kraynov | f5d6027 | 2018-08-10 12:28:51 | [diff] [blame] | 145 | std::unique_ptr<blink::scheduler::WebThreadScheduler> scheduler); |
| 146 | RenderThreadImpl( |
| 147 | const InProcessChildThreadParams& params, |
Sunny Sachanandani | e3e58250 | 2019-10-22 20:10:38 | [diff] [blame] | 148 | int32_t client_id, |
Greg Kraynov | f5d6027 | 2018-08-10 12:28:51 | [diff] [blame] | 149 | std::unique_ptr<blink::scheduler::WebThreadScheduler> scheduler); |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 150 | ~RenderThreadImpl() override; |
| 151 | void Shutdown() override; |
haraken | bbfdd9f0 | 2017-01-12 07:14:04 | [diff] [blame] | 152 | bool ShouldBeDestroyed() override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 153 | |
[email protected] | 58436a1 | 2012-03-21 17:10:26 | [diff] [blame] | 154 | // When initializing WebKit, ensure that any schemes needed for the content |
| 155 | // module are registered properly. Static to allow sharing with tests. |
| 156 | static void RegisterSchemes(); |
| 157 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 158 | // RenderThread implementation: |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 159 | IPC::SyncChannel* GetChannel() override; |
| 160 | std::string GetLocale() override; |
| 161 | IPC::SyncMessageFilter* GetSyncMessageFilter() override; |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 162 | void AddRoute(int32_t routing_id, IPC::Listener* listener) override; |
danakj | 0bdfacd | 2021-01-20 19:27:18 | [diff] [blame] | 163 | void AttachTaskRunnerToRoute( |
| 164 | int32_t routing_id, |
| 165 | scoped_refptr<base::SingleThreadTaskRunner> task_runner) override; |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 166 | void RemoveRoute(int32_t routing_id) override; |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 167 | int GenerateRoutingID() override; |
Dave Tapuska | 4e60c23 | 2020-11-05 15:49:32 | [diff] [blame] | 168 | bool GenerateFrameRoutingID( |
| 169 | int32_t& routing_id, |
Chris Hamilton | 6c60a83 | 2021-02-19 20:35:46 | [diff] [blame] | 170 | blink::LocalFrameToken& frame_token, |
Dave Tapuska | 4e60c23 | 2020-11-05 15:49:32 | [diff] [blame] | 171 | base::UnguessableToken& devtools_frame_token) override; |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 172 | void AddFilter(IPC::MessageFilter* filter) override; |
| 173 | void RemoveFilter(IPC::MessageFilter* filter) override; |
tyoshino | 832a58a | 2016-04-18 08:14:08 | [diff] [blame] | 174 | void AddObserver(RenderThreadObserver* observer) override; |
| 175 | void RemoveObserver(RenderThreadObserver* observer) override; |
Minggang Wang | 8cd77ac | 2021-01-30 18:00:44 | [diff] [blame] | 176 | void SetResourceRequestSenderDelegate( |
| 177 | blink::WebResourceRequestSenderDelegate* delegate) override; |
| 178 | blink::WebResourceRequestSenderDelegate* GetResourceRequestSenderDelegate() { |
| 179 | return resource_request_sender_delegate_; |
| 180 | } |
Clemens Hammacher | 38b6a76 | 2019-02-05 13:07:22 | [diff] [blame] | 181 | void RegisterExtension(std::unique_ptr<v8::Extension> extension) override; |
danakj | 710b4c0 | 2019-11-28 16:08:45 | [diff] [blame] | 182 | int PostTaskToAllWebWorkers(base::RepeatingClosure closure) override; |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 183 | base::WaitableEvent* GetShutdownEvent() override; |
staraz | 067f5824 | 2016-11-07 21:06:41 | [diff] [blame] | 184 | int32_t GetClientId() override; |
Karan Bhatia | c89897f | 2017-08-10 01:06:40 | [diff] [blame] | 185 | void SetRendererProcessType( |
Yuta Kitamura | 6359350 | 2018-11-12 09:27:13 | [diff] [blame] | 186 | blink::scheduler::WebRendererProcessType type) override; |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 187 | blink::WebString GetUserAgent() override; |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 188 | const blink::UserAgentMetadata& GetUserAgentMetadata() override; |
Virender Singh | dfc6c79 | 2019-12-03 05:40:03 | [diff] [blame] | 189 | bool IsUseZoomForDSF() override; |
[email protected] | 1223d6ef | 2011-03-28 16:47:50 | [diff] [blame] | 190 | |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 191 | // IPC::Listener implementation via ChildThreadImpl: |
| 192 | void OnAssociatedInterfaceRequest( |
| 193 | const std::string& name, |
| 194 | mojo::ScopedInterfaceEndpointHandle handle) override; |
| 195 | |
weili | fabbf757 | 2017-05-22 19:05:16 | [diff] [blame] | 196 | // ChildThread implementation via ChildThreadImpl: |
| 197 | scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner() override; |
| 198 | |
Dave Tapuska | 067234e | 2021-05-05 18:28:14 | [diff] [blame] | 199 | blink::scheduler::WebThreadScheduler* GetWebMainThreadScheduler(); |
Dave Tapuska | 009e357 | 2021-05-11 18:42:33 | [diff] [blame] | 200 | cc::TaskGraphRunner* GetTaskGraphRunner(); |
| 201 | gfx::RenderingPipeline* GetMainThreadPipeline(); |
| 202 | gfx::RenderingPipeline* GetCompositorThreadPipeline(); |
Dave Tapuska | b3c39b5 | 2021-01-05 21:05:15 | [diff] [blame] | 203 | bool IsLcdTextEnabled(); |
| 204 | bool IsElasticOverscrollEnabled(); |
| 205 | bool IsScrollAnimatorEnabled(); |
| 206 | |
Tal Pressman | 7a45dfa | 2020-10-23 08:38:02 | [diff] [blame] | 207 | // TODO(crbug.com/1111231): The `enable_scroll_animator` flag is currently |
| 208 | // being passed as part of `CreateViewParams`, despite it looking like a |
| 209 | // global setting. It should probably be moved to some `mojom::Renderer` API |
| 210 | // and this method should be removed. |
| 211 | void SetScrollAnimatorEnabled(bool enable_scroll_animator, |
Peter Kasting | 796cde2 | 2020-11-18 21:06:53 | [diff] [blame] | 212 | base::PassKey<AgentSchedulingGroup>); |
Tal Pressman | 7a45dfa | 2020-10-23 08:38:02 | [diff] [blame] | 213 | |
danakj | e6da4f1 | 2018-07-04 17:41:30 | [diff] [blame] | 214 | bool IsThreadedAnimationEnabled(); |
| 215 | |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 216 | // viz::mojom::CompositingModeWatcher implementation. |
| 217 | void CompositingModeFallbackToSoftware() override; |
| 218 | |
| 219 | // Whether gpu compositing is being used or is disabled for software |
| 220 | // compositing. Clients of the compositor should give resources that match |
| 221 | // the appropriate mode. |
Kenneth Russell | b159303 | 2021-04-20 23:57:47 | [diff] [blame] | 222 | bool IsGpuCompositingDisabled() const { return is_gpu_compositing_disabled_; } |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 223 | |
[email protected] | b3e83de | 2012-02-07 03:33:28 | [diff] [blame] | 224 | // Synchronously establish a channel to the GPU plugin if not previously |
| 225 | // established or if it has been lost (for example if the GPU plugin crashed). |
| 226 | // If there is a pending asynchronous request, it will be completed by the |
Bo Liu | d1ef1c3 | 2017-12-08 06:15:50 | [diff] [blame] | 227 | // time this routine returns. |
| 228 | scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync(); |
[email protected] | b3e83de | 2012-02-07 03:33:28 | [diff] [blame] | 229 | |
piman | c44437a2 | 2016-10-29 00:09:22 | [diff] [blame] | 230 | gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager(); |
| 231 | |
Sam McNally | 52e5028 | 2017-11-29 00:54:02 | [diff] [blame] | 232 | blink::AssociatedInterfaceRegistry* GetAssociatedInterfaceRegistry(); |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 233 | |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 234 | base::DiscardableMemoryAllocator* GetDiscardableMemoryAllocatorForTest() |
| 235 | const { |
| 236 | return discardable_memory_allocator_.get(); |
penghuang | 342762b | 2016-12-02 21:04:58 | [diff] [blame] | 237 | } |
| 238 | |
tfarina | 556a723 | 2014-10-05 01:02:09 | [diff] [blame] | 239 | RendererBlinkPlatformImpl* blink_platform_impl() const { |
| 240 | DCHECK(blink_platform_impl_); |
| 241 | return blink_platform_impl_.get(); |
[email protected] | 078780b | 2014-06-20 16:57:06 | [diff] [blame] | 242 | } |
| 243 | |
Yuta Kitamura | 4e256bfc | 2018-09-27 06:32:35 | [diff] [blame] | 244 | // Returns the task runner on the compositor thread. |
| 245 | // |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 246 | // Will be null if threaded compositing has not been enabled. |
skyostil | 2d3b5bd | 2015-05-27 15:40:59 | [diff] [blame] | 247 | scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner() const { |
| 248 | return compositor_task_runner_; |
[email protected] | a9fb30aa | 2011-10-06 06:58:46 | [diff] [blame] | 249 | } |
| 250 | |
Minggang Wang | 8cd77ac | 2021-01-30 18:00:44 | [diff] [blame] | 251 | const std::vector<std::string> cors_exempt_header_list() const { |
| 252 | return cors_exempt_header_list_; |
John Abd-El-Malek | 6b56ef71 | 2017-10-21 22:52:46 | [diff] [blame] | 253 | } |
| 254 | |
Minggang Wang | 1df377df | 2021-03-08 04:45:40 | [diff] [blame] | 255 | blink::URLLoaderThrottleProvider* url_loader_throttle_provider() const { |
Yuzhu Shen | fe5f3a5 | 2018-01-11 21:24:13 | [diff] [blame] | 256 | return url_loader_throttle_provider_.get(); |
| 257 | } |
| 258 | |
[email protected] | 6ca6a08 | 2013-09-22 20:10:05 | [diff] [blame] | 259 | #if defined(OS_ANDROID) |
siva.gunturi | 5d4feb05 | 2015-11-15 16:15:31 | [diff] [blame] | 260 | scoped_refptr<StreamTextureFactory> GetStreamTexureFactory(); |
boliu | f8753bf6 | 2016-02-11 20:09:42 | [diff] [blame] | 261 | bool EnableStreamTextureCopy(); |
[email protected] | 6ca6a08 | 2013-09-22 20:10:05 | [diff] [blame] | 262 | #endif |
| 263 | |
Antonio Gomes | 925f9b9 | 2019-07-30 23:23:23 | [diff] [blame] | 264 | blink::WebVideoCaptureImplManager* video_capture_impl_manager() const { |
[email protected] | 80b161a | 2011-06-27 17:42:11 | [diff] [blame] | 265 | return vc_manager_.get(); |
| 266 | } |
| 267 | |
rockot | e261d211 | 2016-09-21 22:22:23 | [diff] [blame] | 268 | mojom::RenderMessageFilter* render_message_filter(); |
rockot | 1587e33 | 2016-07-27 17:44:14 | [diff] [blame] | 269 | |
[email protected] | 6217d39 | 2010-03-25 22:08:35 | [diff] [blame] | 270 | // Get the GPU channel. Returns NULL if the channel is not established or |
| 271 | // has been lost. |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 272 | gpu::GpuChannelHost* GetGpuChannel(); |
[email protected] | 6217d39 | 2010-03-25 22:08:35 | [diff] [blame] | 273 | |
skyostil | 2d3b5bd | 2015-05-27 15:40:59 | [diff] [blame] | 274 | // Returns a SingleThreadTaskRunner instance corresponding to the message loop |
[email protected] | c1330c8 | 2013-06-06 02:23:25 | [diff] [blame] | 275 | // of the thread on which media operations should be run. Must be called |
| 276 | // on the renderer's main thread. |
acolwell | b403494 | 2014-08-28 15:42:43 | [diff] [blame] | 277 | scoped_refptr<base::SingleThreadTaskRunner> GetMediaThreadTaskRunner(); |
[email protected] | c1330c8 | 2013-06-06 02:23:25 | [diff] [blame] | 278 | |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 279 | // A TaskRunner instance that runs tasks on the raster worker pool. |
| 280 | base::TaskRunner* GetWorkerTaskRunner(); |
dcastagna | b880e8f | 2015-06-30 20:16:06 | [diff] [blame] | 281 | |
CJ DiMeglio | 79f7c91a2 | 2018-08-30 22:24:43 | [diff] [blame] | 282 | // Creates a ContextProvider if yet created, and returns it to be used for |
| 283 | // video frame compositing. The ContextProvider given as an argument is |
| 284 | // one that has been lost, and is a hint to the RenderThreadImpl to clear |
| 285 | // it's |video_frame_compositor_context_provider_| if it matches. |
Sergey Ulanov | 83f4a15 | 2019-02-14 03:54:25 | [diff] [blame] | 286 | scoped_refptr<viz::RasterContextProvider> |
| 287 | GetVideoFrameCompositorContextProvider( |
| 288 | scoped_refptr<viz::RasterContextProvider>); |
CJ DiMeglio | 79f7c91a2 | 2018-08-30 22:24:43 | [diff] [blame] | 289 | |
danakj | 0b4b94e3 | 2016-05-10 22:33:01 | [diff] [blame] | 290 | // Returns a worker context provider that will be bound on the compositor |
| 291 | // thread. |
Victor Miura | ff648861 | 2017-12-21 04:16:15 | [diff] [blame] | 292 | scoped_refptr<viz::RasterContextProvider> |
Jonathan Backer | 8e4f35d | 2018-10-15 20:56:42 | [diff] [blame] | 293 | SharedCompositorWorkerContextProvider(bool try_gpu_rasterization); |
reveman | d180dfc3 | 2015-09-24 00:19:43 | [diff] [blame] | 294 | |
dcastagna | 7f45dada | 2015-10-19 20:17:35 | [diff] [blame] | 295 | media::GpuVideoAcceleratorFactories* GetGpuFactories(); |
Frank Liberato | 3afa598 | 2020-12-10 06:13:44 | [diff] [blame] | 296 | media::DecoderFactory* GetMediaDecoderFactory(); |
[email protected] | 3bb8bb3 | 2013-07-11 13:13:03 | [diff] [blame] | 297 | |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 298 | scoped_refptr<viz::ContextProviderCommandBuffer> |
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 299 | SharedMainThreadContextProvider(); |
[email protected] | c29b7ff | 2013-03-06 03:51:04 | [diff] [blame] | 300 | |
[email protected] | b2d9876 | 2012-09-03 17:04:06 | [diff] [blame] | 301 | // For producing custom V8 histograms. Custom histograms are produced if all |
| 302 | // RenderViews share the same host, and the host is in the pre-specified set |
| 303 | // of hosts we want to produce custom diagrams for. The name for a custom |
| 304 | // diagram is the name of the corresponding generic diagram plus a |
| 305 | // host-specific suffix. |
| 306 | class CONTENT_EXPORT HistogramCustomizer { |
| 307 | public: |
| 308 | HistogramCustomizer(); |
| 309 | ~HistogramCustomizer(); |
| 310 | |
| 311 | // Called when a top frame of a RenderView navigates. This function updates |
| 312 | // RenderThreadImpl's information about whether all RenderViews are |
| 313 | // displaying a page from the same host. |host| is the host where a |
| 314 | // RenderView navigated, and |view_count| is the number of RenderViews in |
| 315 | // this process. |
| 316 | void RenderViewNavigatedToHost(const std::string& host, size_t view_count); |
| 317 | |
| 318 | // Used for customizing some histograms if all RenderViews share the same |
| 319 | // host. Returns the current custom histogram name to use for |
| 320 | // |histogram_name|, or |histogram_name| if it shouldn't be customized. |
| 321 | std::string ConvertToCustomHistogramName(const char* histogram_name) const; |
| 322 | |
| 323 | private: |
hablich | d6a4f12 | 2015-10-28 11:34:49 | [diff] [blame] | 324 | FRIEND_TEST_ALL_PREFIXES(RenderThreadImplUnittest, |
| 325 | IdentifyAlexaTop10NonGoogleSite); |
[email protected] | b2d9876 | 2012-09-03 17:04:06 | [diff] [blame] | 326 | friend class RenderThreadImplUnittest; |
| 327 | |
hablich | d6a4f12 | 2015-10-28 11:34:49 | [diff] [blame] | 328 | // Converts a host name to a suffix for histograms |
| 329 | std::string HostToCustomHistogramSuffix(const std::string& host); |
| 330 | |
| 331 | // Helper function to identify a certain set of top pages |
| 332 | bool IsAlexaTop10NonGoogleSite(const std::string& host); |
| 333 | |
[email protected] | b2d9876 | 2012-09-03 17:04:06 | [diff] [blame] | 334 | // Used for updating the information on which is the common host which all |
| 335 | // RenderView's share (if any). If there is no common host, this function is |
| 336 | // called with an empty string. |
| 337 | void SetCommonHost(const std::string& host); |
| 338 | |
| 339 | // The current common host of the RenderViews; empty string if there is no |
| 340 | // common host. |
| 341 | std::string common_host_; |
| 342 | // The corresponding suffix. |
| 343 | std::string common_host_histogram_suffix_; |
| 344 | // Set of histograms for which we want to produce a custom histogram if |
| 345 | // possible. |
| 346 | std::set<std::string> custom_histograms_; |
| 347 | |
| 348 | DISALLOW_COPY_AND_ASSIGN(HistogramCustomizer); |
| 349 | }; |
| 350 | |
| 351 | HistogramCustomizer* histogram_customizer() { |
| 352 | return &histogram_customizer_; |
| 353 | } |
| 354 | |
ben | f28ce88 | 2017-05-02 16:15:49 | [diff] [blame] | 355 | void RegisterPendingFrameCreate( |
ben | f28ce88 | 2017-05-02 16:15:49 | [diff] [blame] | 356 | int routing_id, |
Henrique Ferreiro | 3a9751c | 2019-09-30 13:54:07 | [diff] [blame] | 357 | mojo::PendingReceiver<mojom::Frame> frame); |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 358 | |
jam | 188f19f | 2017-06-07 03:56:24 | [diff] [blame] | 359 | mojom::RendererHost* GetRendererHost(); |
jam | c912ca3 | 2016-02-24 20:17:31 | [diff] [blame] | 360 | |
keishi | 51ed0d5 | 2017-01-12 10:04:46 | [diff] [blame] | 361 | struct RendererMemoryMetrics { |
| 362 | size_t partition_alloc_kb; |
| 363 | size_t blink_gc_kb; |
| 364 | size_t malloc_mb; |
| 365 | size_t discardable_kb; |
| 366 | size_t v8_main_thread_isolate_mb; |
| 367 | size_t total_allocated_mb; |
| 368 | size_t non_discardable_total_allocated_mb; |
| 369 | size_t total_allocated_per_render_view_mb; |
| 370 | }; |
bashi | a0ba0d4 | 2017-04-03 08:11:06 | [diff] [blame] | 371 | bool GetRendererMemoryMetrics(RendererMemoryMetrics* memory_metrics) const; |
keishi | 51ed0d5 | 2017-01-12 10:04:46 | [diff] [blame] | 372 | |
Aditya Keerthi | e84331b3 | 2019-03-20 15:25:52 | [diff] [blame] | 373 | void RecordMetricsForBackgroundedRendererPurge(); |
| 374 | |
Miguel Casas | 5e101805 | 2018-01-09 19:17:36 | [diff] [blame] | 375 | // Sets the current pipeline rendering color space. |
| 376 | void SetRenderingColorSpace(const gfx::ColorSpace& color_space); |
| 377 | |
philipel | 637690342 | 2021-03-04 16:18:45 | [diff] [blame] | 378 | gfx::ColorSpace GetRenderingColorSpace(); |
| 379 | |
CJ DiMeglio | 79f7c91a2 | 2018-08-30 22:24:43 | [diff] [blame] | 380 | scoped_refptr<base::SingleThreadTaskRunner> |
| 381 | CreateVideoFrameCompositorTaskRunner(); |
| 382 | |
CJ DiMeglio | b6eb9cd | 2018-11-06 23:44:01 | [diff] [blame] | 383 | // In the case of kOnDemand, we wont be using the task_runner created in |
| 384 | // CreateVideoFrameCompositorTaskRunner. |
| 385 | // TODO(https://crbug/901513): Remove once kOnDemand is removed. |
| 386 | void SetVideoFrameCompositorTaskRunner( |
| 387 | scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 388 | video_frame_compositor_task_runner_ = task_runner; |
| 389 | } |
| 390 | |
[email protected] | 8930d47 | 2009-02-21 08:05:28 | [diff] [blame] | 391 | private: |
Aditya Keerthi | c0d45b4 | 2019-02-25 18:53:00 | [diff] [blame] | 392 | friend class RenderThreadImplBrowserTest; |
Dominic Farolino | 08c26569 | 2020-09-24 06:59:42 | [diff] [blame] | 393 | friend class AgentSchedulingGroup; |
Aditya Keerthi | c0d45b4 | 2019-02-25 18:53:00 | [diff] [blame] | 394 | |
Nicholas Verne | 06de812 | 2017-11-16 04:47:38 | [diff] [blame] | 395 | void OnProcessFinalRelease() override; |
torne | 88b6645 | 2016-05-03 13:22:14 | [diff] [blame] | 396 | // IPC::Listener |
| 397 | void OnChannelError() override; |
| 398 | |
[email protected] | 57cf9788 | 2013-06-26 20:39:01 | [diff] [blame] | 399 | // ChildThread |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 400 | bool OnControlMessageReceived(const IPC::Message& msg) override; |
liberato | 3aeeb2c | 2016-02-25 17:54:38 | [diff] [blame] | 401 | void RecordAction(const base::UserMetricsAction& action) override; |
| 402 | void RecordComputedAction(const std::string& action) override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 403 | |
sadrul | 5354659 | 2016-12-17 01:44:21 | [diff] [blame] | 404 | bool IsMainThread(); |
[email protected] | 57cf9788 | 2013-06-26 20:39:01 | [diff] [blame] | 405 | |
Greg Kraynov | f5d6027 | 2018-08-10 12:28:51 | [diff] [blame] | 406 | void Init(); |
vollick | 1050cc6 | 2015-12-03 07:04:54 | [diff] [blame] | 407 | void InitializeCompositorThread(); |
Ken Rockot | 13051c93 | 2019-11-14 20:11:51 | [diff] [blame] | 408 | void InitializeWebKit(mojo::BinderMap* binders); |
jam | 75c4422 | 2016-03-23 05:34:24 | [diff] [blame] | 409 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 410 | void OnTransferBitmap(const SkBitmap& bitmap, int resource_id); |
[email protected] | b3df5a4 | 2010-05-11 14:31:09 | [diff] [blame] | 411 | void OnGetAccessibilityTree(); |
blundell | c00adf44 | 2016-09-16 10:43:41 | [diff] [blame] | 412 | |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 413 | // mojom::Renderer: |
Tal Pressman | c951ed9 | 2020-09-01 00:24:23 | [diff] [blame] | 414 | void CreateAgentSchedulingGroup( |
Tal Pressman | d12a6811 | 2021-02-12 04:29:01 | [diff] [blame] | 415 | mojo::PendingReceiver<IPC::mojom::ChannelBootstrap> bootstrap, |
| 416 | mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker> broker_remote) |
| 417 | override; |
Tal Pressman | 25d1eae | 2020-09-14 02:35:47 | [diff] [blame] | 418 | void CreateAssociatedAgentSchedulingGroup( |
Tal Pressman | 25d1eae | 2020-09-14 02:35:47 | [diff] [blame] | 419 | mojo::PendingAssociatedReceiver<mojom::AgentSchedulingGroup> |
Tal Pressman | d12a6811 | 2021-02-12 04:29:01 | [diff] [blame] | 420 | agent_scheduling_group, |
| 421 | mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker> broker_remote) |
| 422 | override; |
rockot | a2db0da | 2016-10-18 17:39:11 | [diff] [blame] | 423 | void OnNetworkConnectionChanged( |
| 424 | net::NetworkChangeNotifier::ConnectionType type, |
| 425 | double max_bandwidth_mbps) override; |
tbansal | b612c5d | 2017-05-25 18:53:06 | [diff] [blame] | 426 | void OnNetworkQualityChanged(net::EffectiveConnectionType type, |
| 427 | base::TimeDelta http_rtt, |
tbansal | 99d8aeb | 2017-05-22 19:12:58 | [diff] [blame] | 428 | base::TimeDelta transport_rtt, |
tbansal | 15973c3 | 2017-05-10 18:40:44 | [diff] [blame] | 429 | double bandwidth_kbps) override; |
rockot | a2db0da | 2016-10-18 17:39:11 | [diff] [blame] | 430 | void SetWebKitSharedTimersSuspended(bool suspend) override; |
Yutaka Hirano | b0465f7 | 2018-05-17 05:48:25 | [diff] [blame] | 431 | void SetUserAgent(const std::string& user_agent) override; |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 432 | void SetUserAgentMetadata(const blink::UserAgentMetadata& metadata) override; |
John Abd-El-Malek | 4058ad2 | 2020-06-03 21:16:04 | [diff] [blame] | 433 | void SetCorsExemptHeaderList(const std::vector<std::string>& list) override; |
rockot | a2db0da | 2016-10-18 17:39:11 | [diff] [blame] | 434 | void UpdateScrollbarTheme( |
| 435 | mojom::UpdateScrollbarThemeParamsPtr params) override; |
| 436 | void OnSystemColorsChanged(int32_t aqua_color_variant, |
| 437 | const std::string& highlight_text_color, |
| 438 | const std::string& highlight_color) override; |
Ionel Popescu | 237e8e3 | 2019-08-07 19:50:54 | [diff] [blame] | 439 | void UpdateSystemColorInfo( |
| 440 | mojom::UpdateSystemColorInfoParamsPtr params) override; |
rockot | a2db0da | 2016-10-18 17:39:11 | [diff] [blame] | 441 | void PurgePluginListCache(bool reload_pages) override; |
John Budorick | ee1c951 | 2019-10-17 15:32:19 | [diff] [blame] | 442 | void SetProcessState(mojom::RenderProcessBackgroundState background_state, |
| 443 | mojom::RenderProcessVisibleState visible_state) override; |
Shubhie Panicker | 45ce80a8 | 2018-02-01 01:40:19 | [diff] [blame] | 444 | void SetSchedulerKeepActive(bool keep_active) override; |
Nasko Oskov | 1c2c049 | 2019-03-14 20:13:39 | [diff] [blame] | 445 | void SetIsLockedToSite() override; |
Sebastien Marchand | 836d04b3 | 2020-04-28 18:10:03 | [diff] [blame] | 446 | #if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX) |
| 447 | void WriteClangProfilingProfile( |
| 448 | WriteClangProfilingProfileCallback callback) override; |
| 449 | #endif |
Yutaka Hirano | 9881e99a | 2020-06-22 06:54:05 | [diff] [blame] | 450 | void SetIsCrossOriginIsolated(bool value) override; |
Mike West | f9cd945 | 2021-05-07 15:53:23 | [diff] [blame] | 451 | void SetIsDirectSocketEnabled(bool value) override; |
[email protected] | 5071cb2 | 2013-07-10 02:19:06 | [diff] [blame] | 452 | void OnMemoryPressure( |
| 453 | base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
rockot | a2db0da | 2016-10-18 17:39:11 | [diff] [blame] | 454 | |
rmcilroy | aa29605 | 2015-04-14 15:35:27 | [diff] [blame] | 455 | bool RendererIsHidden() const; |
| 456 | void OnRendererHidden(); |
| 457 | void OnRendererVisible(); |
[email protected] | b3df5a4 | 2010-05-11 14:31:09 | [diff] [blame] | 458 | |
Aditya Keerthi | c0d45b4 | 2019-02-25 18:53:00 | [diff] [blame] | 459 | bool RendererIsBackgrounded() const; |
| 460 | void OnRendererBackgrounded(); |
| 461 | void OnRendererForegrounded(); |
| 462 | |
tasak | 335a187 | 2017-06-14 09:50:23 | [diff] [blame] | 463 | void RecordMemoryUsageAfterBackgrounded(const char* suffix, |
| 464 | int foregrounded_count); |
Aditya Keerthi | e84331b3 | 2019-03-20 15:25:52 | [diff] [blame] | 465 | void OnRecordMetricsForBackgroundedRendererPurgeTimerExpired( |
tasak | bb0640b | 2017-05-15 09:02:26 | [diff] [blame] | 466 | const char* suffix, |
| 467 | int foregrounded_count_when_purged); |
tasak | b46626a | 2016-10-18 05:54:44 | [diff] [blame] | 468 | |
ssid | 0603ca9f | 2015-06-09 16:48:08 | [diff] [blame] | 469 | void ReleaseFreeMemory(); |
| 470 | |
hong.zheng | b28b533 | 2016-05-11 02:33:39 | [diff] [blame] | 471 | void OnSyncMemoryPressure( |
| 472 | base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 473 | |
Julie Jeongeun Kim | 4e77af262 | 2019-09-11 03:36:45 | [diff] [blame] | 474 | void OnRendererInterfaceReceiver( |
| 475 | mojo::PendingAssociatedReceiver<mojom::Renderer> receiver); |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 476 | |
Thiabaud Engelbrecht | c4c4239 | 2020-12-01 18:24:39 | [diff] [blame] | 477 | scoped_refptr<discardable_memory::ClientDiscardableSharedMemoryManager> |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 478 | discardable_memory_allocator_; |
penghuang | 342762b | 2016-12-02 21:04:58 | [diff] [blame] | 479 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 480 | // These objects live solely on the render thread. |
Yuta Kitamura | deb91bb | 2018-05-29 05:53:20 | [diff] [blame] | 481 | std::unique_ptr<blink::scheduler::WebThreadScheduler> main_thread_scheduler_; |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 482 | std::unique_ptr<RendererBlinkPlatformImpl> blink_platform_impl_; |
Minggang Wang | 1df377df | 2021-03-08 04:45:40 | [diff] [blame] | 483 | std::unique_ptr<blink::URLLoaderThrottleProvider> |
| 484 | url_loader_throttle_provider_; |
[email protected] | 9291ed1 | 2009-07-23 17:33:22 | [diff] [blame] | 485 | |
Minggang Wang | 8cd77ac | 2021-01-30 18:00:44 | [diff] [blame] | 486 | std::vector<std::string> cors_exempt_header_list_; |
| 487 | |
liushouqun | 517b129 | 2016-09-14 05:58:59 | [diff] [blame] | 488 | // Used on the render thread. |
Antonio Gomes | 925f9b9 | 2019-07-30 23:23:23 | [diff] [blame] | 489 | std::unique_ptr<blink::WebVideoCaptureImplManager> vc_manager_; |
[email protected] | da9f30a | 2014-06-18 19:39:04 | [diff] [blame] | 490 | |
Aditya Keerthi | c0d45b4 | 2019-02-25 18:53:00 | [diff] [blame] | 491 | // Used to keep track of the renderer's backgrounded and visibility state. |
| 492 | // Updated via an IPC from the browser process. If nullopt, the browser |
| 493 | // process has yet to send an update and the state is unknown. |
John Budorick | ee1c951 | 2019-10-17 15:32:19 | [diff] [blame] | 494 | base::Optional<mojom::RenderProcessBackgroundState> background_state_; |
| 495 | base::Optional<mojom::RenderProcessVisibleState> visible_state_; |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 496 | |
Yutaka Hirano | b0465f7 | 2018-05-17 05:48:25 | [diff] [blame] | 497 | blink::WebString user_agent_; |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 498 | blink::UserAgentMetadata user_agent_metadata_; |
Yutaka Hirano | b0465f7 | 2018-05-17 05:48:25 | [diff] [blame] | 499 | |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 500 | // Sticky once true, indicates that compositing is done without Gpu, so |
| 501 | // resources given to the compositor or to the viz service should be |
| 502 | // software-based. |
| 503 | bool is_gpu_compositing_disabled_ = false; |
| 504 | |
dcastagna | 7f45dada | 2015-10-19 20:17:35 | [diff] [blame] | 505 | // Utility class to provide GPU functionalities to media. |
dcastagna | 09bd6b3 | 2016-02-01 21:54:28 | [diff] [blame] | 506 | // TODO(dcastagna): This should be just one scoped_ptr once |
| 507 | // http://crbug.com/580386 is fixed. |
| 508 | // NOTE(dcastagna): At worst this accumulates a few bytes per context lost. |
Miguel Casas-Sanchez | cfcca5d5 | 2017-07-07 02:32:59 | [diff] [blame] | 509 | std::vector<std::unique_ptr<GpuVideoAcceleratorFactoriesImpl>> gpu_factories_; |
dcastagna | 7f45dada | 2015-10-19 20:17:35 | [diff] [blame] | 510 | |
Frank Liberato | 3afa598 | 2020-12-10 06:13:44 | [diff] [blame] | 511 | // Utility classes to allow WebRTC to create video decoders. |
| 512 | std::unique_ptr<MediaInterfaceFactory> media_interface_factory_; |
| 513 | std::unique_ptr<media::DecoderFactory> media_decoder_factory_; |
| 514 | |
[email protected] | c1330c8 | 2013-06-06 02:23:25 | [diff] [blame] | 515 | // Thread for running multimedia operations (e.g., video decoding). |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 516 | std::unique_ptr<base::Thread> media_thread_; |
[email protected] | c1330c8 | 2013-06-06 02:23:25 | [diff] [blame] | 517 | |
Bo Liu | 8a39c478 | 2021-03-06 00:50:54 | [diff] [blame] | 518 | std::unique_ptr<gfx::RenderingPipeline> main_thread_pipeline_; |
| 519 | std::unique_ptr<gfx::RenderingPipeline> compositor_thread_pipeline_; |
| 520 | |
skyostil | 2d3b5bd | 2015-05-27 15:40:59 | [diff] [blame] | 521 | // Will point to appropriate task runner after initialization, |
[email protected] | ea5f70a | 2013-03-07 12:30:36 | [diff] [blame] | 522 | // regardless of whether |compositor_thread_| is overriden. |
skyostil | 2d3b5bd | 2015-05-27 15:40:59 | [diff] [blame] | 523 | scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
[email protected] | ea5f70a | 2013-03-07 12:30:36 | [diff] [blame] | 524 | |
CJ DiMeglio | 79f7c91a2 | 2018-08-30 22:24:43 | [diff] [blame] | 525 | // Task to run the VideoFrameCompositor on. |
| 526 | scoped_refptr<base::SingleThreadTaskRunner> |
| 527 | video_frame_compositor_task_runner_; |
| 528 | |
dcastagna | b880e8f | 2015-06-30 20:16:06 | [diff] [blame] | 529 | // Pool of workers used for raster operations (e.g., tile rasterization). |
prashant.n | fad657e | 2016-06-01 07:52:17 | [diff] [blame] | 530 | scoped_refptr<CategorizedWorkerPool> categorized_worker_pool_; |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 531 | |
boliu | bee541f4 | 2015-11-05 00:52:53 | [diff] [blame] | 532 | #if defined(OS_ANDROID) |
siva.gunturi | 5d4feb05 | 2015-11-15 16:15:31 | [diff] [blame] | 533 | scoped_refptr<StreamTextureFactory> stream_texture_factory_; |
boliu | bee541f4 | 2015-11-05 00:52:53 | [diff] [blame] | 534 | #endif |
| 535 | |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 536 | scoped_refptr<viz::ContextProviderCommandBuffer> shared_main_thread_contexts_; |
[email protected] | c29b7ff | 2013-03-06 03:51:04 | [diff] [blame] | 537 | |
Trent Apted | a250ec3ab | 2018-08-19 08:52:19 | [diff] [blame] | 538 | base::ObserverList<RenderThreadObserver>::Unchecked observers_; |
[email protected] | 1223d6ef | 2011-03-28 16:47:50 | [diff] [blame] | 539 | |
Sergey Ulanov | 83f4a15 | 2019-02-14 03:54:25 | [diff] [blame] | 540 | scoped_refptr<viz::RasterContextProvider> |
| 541 | video_frame_compositor_context_provider_; |
CJ DiMeglio | 79f7c91a2 | 2018-08-30 22:24:43 | [diff] [blame] | 542 | |
Victor Miura | ff648861 | 2017-12-21 04:16:15 | [diff] [blame] | 543 | scoped_refptr<viz::RasterContextProvider> shared_worker_context_provider_; |
[email protected] | 3b2afc3 | 2012-06-18 21:31:16 | [diff] [blame] | 544 | |
[email protected] | b2d9876 | 2012-09-03 17:04:06 | [diff] [blame] | 545 | HistogramCustomizer histogram_customizer_; |
| 546 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 547 | std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
[email protected] | 5071cb2 | 2013-07-10 02:19:06 | [diff] [blame] | 548 | |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 549 | std::unique_ptr<viz::Gpu> gpu_; |
sadrul | 9e0bb1d | 2016-08-04 20:18:39 | [diff] [blame] | 550 | |
Alex Clarke | 9fc39b9b | 2020-01-31 17:29:47 | [diff] [blame] | 551 | std::unique_ptr<VariationsRenderThreadObserver> variations_observer_; |
| 552 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 553 | // Compositor settings. |
senorblanco | b60ba95 | 2015-01-27 19:12:36 | [diff] [blame] | 554 | int gpu_rasterization_msaa_sample_count_; |
[email protected] | a23530d | 2014-03-11 06:04:14 | [diff] [blame] | 555 | bool is_lcd_text_enabled_; |
[email protected] | 2cccfef | 2014-05-01 06:05:16 | [diff] [blame] | 556 | bool is_zero_copy_enabled_; |
ccameron | c7fcd13 | 2015-11-03 20:14:31 | [diff] [blame] | 557 | bool is_gpu_memory_buffer_compositor_resources_enabled_; |
ericrk | 1d17f75 | 2015-10-20 03:03:07 | [diff] [blame] | 558 | bool is_partial_raster_enabled_; |
ccameron | a764475 | 2014-12-30 01:16:31 | [diff] [blame] | 559 | bool is_elastic_overscroll_enabled_; |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 560 | bool is_zoom_for_dsf_enabled_; |
loyso | 65c93c60 | 2015-08-11 05:15:57 | [diff] [blame] | 561 | bool is_threaded_animation_enabled_; |
wjmaclean | 1d97062 | 2017-01-21 22:28:24 | [diff] [blame] | 562 | bool is_scroll_animator_enabled_; |
[email protected] | a23530d | 2014-03-11 06:04:14 | [diff] [blame] | 563 | |
Miguel Casas | 5e101805 | 2018-01-09 19:17:36 | [diff] [blame] | 564 | // Target rendering ColorSpace. |
| 565 | gfx::ColorSpace rendering_color_space_; |
| 566 | |
Scott Violet | 9b2d60dc | 2020-05-13 04:05:04 | [diff] [blame] | 567 | // Used when AddRoute() is called and the RenderFrameImpl hasn't been created |
| 568 | // yet. |
| 569 | std::map<int, mojo::PendingReceiver<mojom::Frame>> pending_frames_; |
rockot | f8fdd9b | 2015-12-16 22:22:35 | [diff] [blame] | 570 | |
Julie Jeongeun Kim | daa9aa1 | 2019-10-24 02:51:56 | [diff] [blame] | 571 | mojo::AssociatedRemote<mojom::RendererHost> renderer_host_; |
jam | c912ca3 | 2016-02-24 20:17:31 | [diff] [blame] | 572 | |
Ken Rockot | 26e4e80 | 2018-07-31 15:03:33 | [diff] [blame] | 573 | blink::AssociatedInterfaceRegistry associated_interfaces_; |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 574 | |
Julie Jeongeun Kim | 4e77af262 | 2019-09-11 03:36:45 | [diff] [blame] | 575 | mojo::AssociatedReceiver<mojom::Renderer> renderer_receiver_{this}; |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 576 | |
Julie Jeongeun Kim | 23966e2 | 2019-10-26 02:13:29 | [diff] [blame] | 577 | mojo::AssociatedRemote<mojom::RenderMessageFilter> render_message_filter_; |
rockot | 1587e33 | 2016-07-27 17:44:14 | [diff] [blame] | 578 | |
Tal Pressman | c951ed9 | 2020-09-01 00:24:23 | [diff] [blame] | 579 | std::set<std::unique_ptr<AgentSchedulingGroup>, base::UniquePtrComparator> |
| 580 | agent_scheduling_groups_; |
Tal Pressman | 9780e2c | 2020-08-26 06:35:09 | [diff] [blame] | 581 | |
tasak | 72f6404 | 2017-01-19 14:02:53 | [diff] [blame] | 582 | RendererMemoryMetrics purge_and_suspend_memory_metrics_; |
tasak | bb0640b | 2017-05-15 09:02:26 | [diff] [blame] | 583 | int process_foregrounded_count_; |
hajimehoshi | 6909327 | 2016-05-13 08:30:58 | [diff] [blame] | 584 | |
staraz | 067f5824 | 2016-11-07 21:06:41 | [diff] [blame] | 585 | int32_t client_id_; |
| 586 | |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 587 | // A mojo connection to the CompositingModeReporter service. |
Gyuyoung Kim | c9cf74a | 2019-11-05 00:54:35 | [diff] [blame] | 588 | mojo::Remote<viz::mojom::CompositingModeReporter> compositing_mode_reporter_; |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 589 | // The class is a CompositingModeWatcher, which is bound to mojo through |
danakj | 4ee301c | 2017-11-29 16:19:43 | [diff] [blame] | 590 | // this member. |
Gyuyoung Kim | ef648a2e7 | 2019-09-17 09:48:35 | [diff] [blame] | 591 | mojo::Receiver<viz::mojom::CompositingModeWatcher> |
| 592 | compositing_mode_watcher_receiver_{this}; |
danakj | ab9ef4d | 2017-10-31 23:38:33 | [diff] [blame] | 593 | |
Minggang Wang | 8cd77ac | 2021-01-30 18:00:44 | [diff] [blame] | 594 | // Delegate is expected to live as long as requests may be sent. |
| 595 | blink::WebResourceRequestSenderDelegate* resource_request_sender_delegate_ = |
| 596 | nullptr; |
| 597 | |
Jeremy Roman | 3bca4bf | 2019-07-11 03:41:25 | [diff] [blame] | 598 | base::WeakPtrFactory<RenderThreadImpl> weak_factory_{this}; |
Ben Goodger | f180ce1 | 2018-02-09 22:54:01 | [diff] [blame] | 599 | |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 600 | DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 601 | }; |
| 602 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 603 | } // namespace content |
| 604 | |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 605 | #endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ |