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