blob: 7772c8d9c21d7010933d23421956e4b511b3713f [file] [log] [blame]
[email protected]d3d6325d2012-01-03 21:17:361// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]f1a29a02011-10-06 23:08:445#ifndef CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
6#define CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
initial.commit09911bf2008-07-26 23:55:297
avi1023d012015-12-25 02:39:148#include <stddef.h>
9#include <stdint.h>
10
maxmorin017ba8c62017-06-02 10:23:0911#include <map>
leon.han21e0e482017-02-23 04:13:3212#include <memory>
[email protected]6779aa12011-03-29 17:32:2413#include <set>
[email protected]b68d5ed2009-04-16 02:41:2814#include <string>
maxmorin017ba8c62017-06-02 10:23:0915#include <utility>
[email protected]1bc83062009-02-06 00:16:3716#include <vector>
17
jdduke691dd572014-12-02 20:47:5218#include "base/cancelable_callback.h"
Sebastien Marchand836d04b32020-04-28 18:10:0319#include "base/clang_profiling_buildflags.h"
Tal Pressmanc951ed92020-09-01 00:24:2320#include "base/containers/unique_ptr_adapters.h"
avi1023d012015-12-25 02:39:1421#include "base/macros.h"
Gordon Guan96c21ee2019-11-06 15:05:3922#include "base/memory/discardable_memory_allocator.h"
[email protected]5071cb22013-07-10 02:19:0623#include "base/memory/memory_pressure_listener.h"
rockot775ce0d2015-01-27 18:35:0124#include "base/memory/ref_counted.h"
[email protected]e6e30ac2014-01-13 21:24:3925#include "base/metrics/user_metrics_action.h"
[email protected]1223d6ef2011-03-28 16:47:5026#include "base/observer_list.h"
maxmorin017ba8c62017-06-02 10:23:0927#include "base/optional.h"
tbansal99d8aeb2017-05-22 19:12:5828#include "base/time/time.h"
Peter Kasting796cde22020-11-18 21:06:5329#include "base/types/pass_key.h"
[email protected]037fce02009-01-22 01:42:1530#include "build/build_config.h"
jam8a021512a2015-02-03 18:16:0831#include "content/child/child_thread_impl.h"
Tal Pressmanc951ed92020-09-01 00:24:2332#include "content/common/agent_scheduling_group.mojom.h"
[email protected]8d128d62011-09-13 22:11:5733#include "content/common/content_export.h"
ben76f52b242016-06-18 05:42:4834#include "content/common/frame.mojom.h"
rockote261d2112016-09-21 22:22:2335#include "content/common/render_message_filter.mojom.h"
rockot067ca55f2016-09-30 22:00:1536#include "content/common/renderer.mojom.h"
jam188f19f2017-06-07 03:56:2437#include "content/common/renderer_host.mojom.h"
[email protected]526476902011-10-06 20:34:0638#include "content/public/renderer/render_thread.h"
Gordon Guan96c21ee2019-11-06 15:05:3939#include "content/renderer/discardable_memory_utils.h"
penghuang346a46f92016-03-31 21:37:5240#include "gpu/ipc/client/gpu_channel_host.h"
Antoine Laboure55c9ef82017-11-10 18:51:2341#include "ipc/ipc_sync_channel.h"
Scott Violeta35f9a42018-03-22 22:00:4442#include "media/media_buildflags.h"
Julie Jeongeun Kim4e77af2622019-09-11 03:36:4543#include "mojo/public/cpp/bindings/associated_receiver.h"
Julie Jeongeun Kimdaa9aa12019-10-24 02:51:5644#include "mojo/public/cpp/bindings/associated_remote.h"
Julie Jeongeun Kim4e77af2622019-09-11 03:36:4545#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
Julie Jeongeun Kim4421c2e2019-09-11 06:34:3946#include "mojo/public/cpp/bindings/pending_receiver.h"
Julie Jeongeun Kim6f4b7e02019-09-11 05:05:4647#include "mojo/public/cpp/bindings/pending_remote.h"
Gyuyoung Kimef648a2e72019-09-17 09:48:3548#include "mojo/public/cpp/bindings/receiver.h"
Mario Sanchez Prada5492c9a2019-09-10 20:58:1149#include "mojo/public/cpp/bindings/remote.h"
[email protected]d7ff5fb2014-05-29 19:50:2550#include "net/base/network_change_notifier.h"
tbansalb612c5d2017-05-25 18:53:0651#include "net/nqe/effective_connection_type.h"
Miyoung Shin99505dd2019-07-27 12:45:3552#include "services/viz/public/mojom/compositing/compositing_mode_watcher.mojom.h"
Ken Rockot26e4e802018-07-31 15:03:3353#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
Mike West6e4cbb32019-02-13 09:40:1754#include "third_party/blink/public/common/user_agent/user_agent_metadata.h"
Kent Tamura38fb4342018-07-25 12:47:5355#include "third_party/blink/public/platform/scheduler/web_rail_mode_observer.h"
Daniel Murphy738378c2019-05-31 21:59:2556#include "third_party/blink/public/platform/scheduler/web_thread_scheduler.h"
Minggang Wang1df377df2021-03-08 04:45:4057#include "third_party/blink/public/platform/url_loader_throttle_provider.h"
Blink Reformata30d4232018-04-07 15:31:0658#include "third_party/blink/public/platform/web_connection_type.h"
59#include "third_party/blink/public/web/web_memory_statistics.h"
[email protected]08397d52011-02-05 01:53:3860#include "ui/gfx/native_widget_types.h"
initial.commit09911bf2008-07-26 23:55:2961
[email protected]39008c02009-02-11 23:59:2562class SkBitmap;
[email protected]46f36a492010-07-28 19:36:4163
[email protected]180ef242013-11-07 06:50:4664namespace blink {
Minggang Wang8cd77ac2021-01-30 18:00:4465class WebResourceRequestSenderDelegate;
Antonio Gomes925f9b92019-07-30 23:23:2366class WebVideoCaptureImplManager;
[email protected]b7c7bcf2009-10-03 07:07:3467}
68
[email protected]64ffa0442011-10-03 22:08:3669namespace base {
skyostil457b0a12014-09-09 10:12:0770class SingleThreadTaskRunner;
[email protected]64ffa0442011-10-03 22:08:3671class Thread;
72}
73
[email protected]c29b7ff2013-03-06 03:51:0474namespace cc {
reveman34b7a1522015-03-23 20:27:4775class TaskGraphRunner;
[email protected]c29b7ff2013-03-06 03:51:0476}
77
Bo Liu8a39c4782021-03-06 00:50:5478namespace gfx {
79class RenderingPipeline;
80}
81
penghuang346a46f92016-03-31 21:37:5282namespace gpu {
83class GpuChannelHost;
84}
85
[email protected]563d665f2013-02-01 04:42:3986namespace media {
Frank Liberato3afa5982020-12-10 06:13:4487class DecoderFactory;
[email protected]2329bfc72014-02-28 02:03:2188class GpuVideoAcceleratorFactories;
[email protected]563d665f2013-02-01 04:42:3989}
90
Ken Rockot13051c932019-11-14 20:11:5191namespace mojo {
92class BinderMap;
93}
94
danakj92429852017-06-29 00:19:0395namespace viz {
Scott Violet7e33efc2018-08-29 22:30:1596class ContextProviderCommandBuffer;
97class Gpu;
Scott Violet703b8242019-06-11 19:34:3698class RasterContextProvider;
Scott Violet703b8242019-06-11 19:34:3699} // namespace viz
Scott Violet7e33efc2018-08-29 22:30:15100
[email protected]64ffa0442011-10-03 22:08:36101namespace content {
Tal Pressman9780e2c2020-08-26 06:35:09102class AgentSchedulingGroup;
John Abd-El-Maleke1d4de32017-10-21 16:14:29103class CategorizedWorkerPool;
John Abd-El-Maleke1d4de32017-10-21 16:14:29104class GpuVideoAcceleratorFactoriesImpl;
Frank Liberato3afa5982020-12-10 06:13:44105class MediaInterfaceFactory;
danakj0bdfacd2021-01-20 19:27:18106class RenderFrameImpl;
tyoshino832a58a2016-04-18 08:14:08107class RenderThreadObserver;
tfarina556a7232014-10-05 01:02:09108class RendererBlinkPlatformImpl;
Alex Clarke9fc39b9b2020-01-31 17:29:47109class VariationsRenderThreadObserver;
[email protected]cb25aa12012-08-07 19:13:43110
boliubee541f42015-11-05 00:52:53111#if defined(OS_ANDROID)
siva.gunturi5d4feb052015-11-15 16:15:31112class StreamTextureFactory;
boliubee541f42015-11-05 00:52:53113#endif
114
Matt Falkenhagenef13d782019-05-30 21:02:12115// The RenderThreadImpl class represents the main thread, where RenderView
initial.commit09911bf2008-07-26 23:55:29116// 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]770005b2012-04-16 15:58:13119// process (i.e., their corresponding WebContentsImpl).
initial.commit09911bf2008-07-26 23:55:29120//
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.
danakj6e3bf8012014-12-16 18:27:53124class CONTENT_EXPORT RenderThreadImpl
125 : public RenderThread,
jam8a021512a2015-02-03 18:16:08126 public ChildThreadImpl,
Nico Weber43ddd7a32017-08-15 19:19:27127 public mojom::Renderer,
Dave Tapuskab0d67132021-05-12 03:14:24128 public viz::mojom::CompositingModeWatcher {
initial.commit09911bf2008-07-26 23:55:29129 public:
[email protected]f1a29a02011-10-06 23:08:44130 static RenderThreadImpl* current();
rockot5c478a72016-09-28 23:14:18131 static mojom::RenderMessageFilter* current_render_message_filter();
olegmax045f7fb12017-05-19 07:58:55132 static RendererBlinkPlatformImpl* current_blink_platform_impl();
rockot5c478a72016-09-28 23:14:18133
134 static void SetRenderMessageFilterForTesting(
135 mojom::RenderMessageFilter* render_message_filter);
olegmax045f7fb12017-05-19 07:58:55136 static void SetRendererBlinkPlatformImplForTesting(
137 RendererBlinkPlatformImpl* blink_platform_impl);
[email protected]526476902011-10-06 20:34:06138
John Abd-El-Malekd4882642017-12-04 21:45:19139 // Returns the task runner for the main thread where the RenderThread lives.
Hajime Hoshi20578c62018-01-12 09:43:26140 static scoped_refptr<base::SingleThreadTaskRunner>
141 DeprecatedGetMainTaskRunner();
John Abd-El-Malekd4882642017-12-04 21:45:19142
Wez6979109b2018-09-07 17:30:56143 RenderThreadImpl(
144 base::RepeatingClosure quit_closure,
Greg Kraynovf5d60272018-08-10 12:28:51145 std::unique_ptr<blink::scheduler::WebThreadScheduler> scheduler);
146 RenderThreadImpl(
147 const InProcessChildThreadParams& params,
Sunny Sachanandanie3e582502019-10-22 20:10:38148 int32_t client_id,
Greg Kraynovf5d60272018-08-10 12:28:51149 std::unique_ptr<blink::scheduler::WebThreadScheduler> scheduler);
dcheng6d18e402014-10-21 12:32:52150 ~RenderThreadImpl() override;
151 void Shutdown() override;
harakenbbfdd9f02017-01-12 07:14:04152 bool ShouldBeDestroyed() override;
initial.commit09911bf2008-07-26 23:55:29153
[email protected]58436a12012-03-21 17:10:26154 // 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]e9ff79c2012-10-19 21:31:26158 // RenderThread implementation:
dcheng6d18e402014-10-21 12:32:52159 IPC::SyncChannel* GetChannel() override;
160 std::string GetLocale() override;
161 IPC::SyncMessageFilter* GetSyncMessageFilter() override;
avi1023d012015-12-25 02:39:14162 void AddRoute(int32_t routing_id, IPC::Listener* listener) override;
danakj0bdfacd2021-01-20 19:27:18163 void AttachTaskRunnerToRoute(
164 int32_t routing_id,
165 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override;
avi1023d012015-12-25 02:39:14166 void RemoveRoute(int32_t routing_id) override;
dcheng6d18e402014-10-21 12:32:52167 int GenerateRoutingID() override;
Dave Tapuska4e60c232020-11-05 15:49:32168 bool GenerateFrameRoutingID(
169 int32_t& routing_id,
Chris Hamilton6c60a832021-02-19 20:35:46170 blink::LocalFrameToken& frame_token,
Dave Tapuska4e60c232020-11-05 15:49:32171 base::UnguessableToken& devtools_frame_token) override;
dcheng6d18e402014-10-21 12:32:52172 void AddFilter(IPC::MessageFilter* filter) override;
173 void RemoveFilter(IPC::MessageFilter* filter) override;
tyoshino832a58a2016-04-18 08:14:08174 void AddObserver(RenderThreadObserver* observer) override;
175 void RemoveObserver(RenderThreadObserver* observer) override;
Minggang Wang8cd77ac2021-01-30 18:00:44176 void SetResourceRequestSenderDelegate(
177 blink::WebResourceRequestSenderDelegate* delegate) override;
178 blink::WebResourceRequestSenderDelegate* GetResourceRequestSenderDelegate() {
179 return resource_request_sender_delegate_;
180 }
Clemens Hammacher38b6a762019-02-05 13:07:22181 void RegisterExtension(std::unique_ptr<v8::Extension> extension) override;
danakj710b4c02019-11-28 16:08:45182 int PostTaskToAllWebWorkers(base::RepeatingClosure closure) override;
dcheng6d18e402014-10-21 12:32:52183 base::WaitableEvent* GetShutdownEvent() override;
staraz067f58242016-11-07 21:06:41184 int32_t GetClientId() override;
Karan Bhatiac89897f2017-08-10 01:06:40185 void SetRendererProcessType(
Yuta Kitamura63593502018-11-12 09:27:13186 blink::scheduler::WebRendererProcessType type) override;
Lucas Furukawa Gadanid51ff5d62018-12-07 21:26:49187 blink::WebString GetUserAgent() override;
Mike West6e4cbb32019-02-13 09:40:17188 const blink::UserAgentMetadata& GetUserAgentMetadata() override;
Virender Singhdfc6c792019-12-03 05:40:03189 bool IsUseZoomForDSF() override;
[email protected]1223d6ef2011-03-28 16:47:50190
rockot067ca55f2016-09-30 22:00:15191 // IPC::Listener implementation via ChildThreadImpl:
192 void OnAssociatedInterfaceRequest(
193 const std::string& name,
194 mojo::ScopedInterfaceEndpointHandle handle) override;
195
weilifabbf7572017-05-22 19:05:16196 // ChildThread implementation via ChildThreadImpl:
197 scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner() override;
198
Dave Tapuska067234e2021-05-05 18:28:14199 blink::scheduler::WebThreadScheduler* GetWebMainThreadScheduler();
Dave Tapuska009e3572021-05-11 18:42:33200 cc::TaskGraphRunner* GetTaskGraphRunner();
201 gfx::RenderingPipeline* GetMainThreadPipeline();
202 gfx::RenderingPipeline* GetCompositorThreadPipeline();
Dave Tapuskab3c39b52021-01-05 21:05:15203 bool IsLcdTextEnabled();
204 bool IsElasticOverscrollEnabled();
205 bool IsScrollAnimatorEnabled();
206
Tal Pressman7a45dfa2020-10-23 08:38:02207 // 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 Kasting796cde22020-11-18 21:06:53212 base::PassKey<AgentSchedulingGroup>);
Tal Pressman7a45dfa2020-10-23 08:38:02213
danakje6da4f12018-07-04 17:41:30214 bool IsThreadedAnimationEnabled();
215
danakjab9ef4d2017-10-31 23:38:33216 // 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 Russellb1593032021-04-20 23:57:47222 bool IsGpuCompositingDisabled() const { return is_gpu_compositing_disabled_; }
danakjab9ef4d2017-10-31 23:38:33223
[email protected]b3e83de2012-02-07 03:33:28224 // 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 Liud1ef1c32017-12-08 06:15:50227 // time this routine returns.
228 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync();
[email protected]b3e83de2012-02-07 03:33:28229
pimanc44437a22016-10-29 00:09:22230 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager();
231
Sam McNally52e50282017-11-29 00:54:02232 blink::AssociatedInterfaceRegistry* GetAssociatedInterfaceRegistry();
rockot067ca55f2016-09-30 22:00:15233
Gordon Guan96c21ee2019-11-06 15:05:39234 base::DiscardableMemoryAllocator* GetDiscardableMemoryAllocatorForTest()
235 const {
236 return discardable_memory_allocator_.get();
penghuang342762b2016-12-02 21:04:58237 }
238
tfarina556a7232014-10-05 01:02:09239 RendererBlinkPlatformImpl* blink_platform_impl() const {
240 DCHECK(blink_platform_impl_);
241 return blink_platform_impl_.get();
[email protected]078780b2014-06-20 16:57:06242 }
243
Yuta Kitamura4e256bfc2018-09-27 06:32:35244 // Returns the task runner on the compositor thread.
245 //
danakj6e3bf8012014-12-16 18:27:53246 // Will be null if threaded compositing has not been enabled.
skyostil2d3b5bd2015-05-27 15:40:59247 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner() const {
248 return compositor_task_runner_;
[email protected]a9fb30aa2011-10-06 06:58:46249 }
250
Minggang Wang8cd77ac2021-01-30 18:00:44251 const std::vector<std::string> cors_exempt_header_list() const {
252 return cors_exempt_header_list_;
John Abd-El-Malek6b56ef712017-10-21 22:52:46253 }
254
Minggang Wang1df377df2021-03-08 04:45:40255 blink::URLLoaderThrottleProvider* url_loader_throttle_provider() const {
Yuzhu Shenfe5f3a52018-01-11 21:24:13256 return url_loader_throttle_provider_.get();
257 }
258
[email protected]6ca6a082013-09-22 20:10:05259#if defined(OS_ANDROID)
siva.gunturi5d4feb052015-11-15 16:15:31260 scoped_refptr<StreamTextureFactory> GetStreamTexureFactory();
boliuf8753bf62016-02-11 20:09:42261 bool EnableStreamTextureCopy();
[email protected]6ca6a082013-09-22 20:10:05262#endif
263
Antonio Gomes925f9b92019-07-30 23:23:23264 blink::WebVideoCaptureImplManager* video_capture_impl_manager() const {
[email protected]80b161a2011-06-27 17:42:11265 return vc_manager_.get();
266 }
267
rockote261d2112016-09-21 22:22:23268 mojom::RenderMessageFilter* render_message_filter();
rockot1587e332016-07-27 17:44:14269
[email protected]6217d392010-03-25 22:08:35270 // Get the GPU channel. Returns NULL if the channel is not established or
271 // has been lost.
penghuang346a46f92016-03-31 21:37:52272 gpu::GpuChannelHost* GetGpuChannel();
[email protected]6217d392010-03-25 22:08:35273
skyostil2d3b5bd2015-05-27 15:40:59274 // Returns a SingleThreadTaskRunner instance corresponding to the message loop
[email protected]c1330c82013-06-06 02:23:25275 // of the thread on which media operations should be run. Must be called
276 // on the renderer's main thread.
acolwellb4034942014-08-28 15:42:43277 scoped_refptr<base::SingleThreadTaskRunner> GetMediaThreadTaskRunner();
[email protected]c1330c82013-06-06 02:23:25278
dcastagna4517a182015-08-05 19:51:03279 // A TaskRunner instance that runs tasks on the raster worker pool.
280 base::TaskRunner* GetWorkerTaskRunner();
dcastagnab880e8f2015-06-30 20:16:06281
CJ DiMeglio79f7c91a22018-08-30 22:24:43282 // 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 Ulanov83f4a152019-02-14 03:54:25286 scoped_refptr<viz::RasterContextProvider>
287 GetVideoFrameCompositorContextProvider(
288 scoped_refptr<viz::RasterContextProvider>);
CJ DiMeglio79f7c91a22018-08-30 22:24:43289
danakj0b4b94e32016-05-10 22:33:01290 // Returns a worker context provider that will be bound on the compositor
291 // thread.
Victor Miuraff6488612017-12-21 04:16:15292 scoped_refptr<viz::RasterContextProvider>
Jonathan Backer8e4f35d2018-10-15 20:56:42293 SharedCompositorWorkerContextProvider(bool try_gpu_rasterization);
revemand180dfc32015-09-24 00:19:43294
dcastagna7f45dada2015-10-19 20:17:35295 media::GpuVideoAcceleratorFactories* GetGpuFactories();
Frank Liberato3afa5982020-12-10 06:13:44296 media::DecoderFactory* GetMediaDecoderFactory();
[email protected]3bb8bb32013-07-11 13:13:03297
Scott Violet703b8242019-06-11 19:34:36298 scoped_refptr<viz::ContextProviderCommandBuffer>
sadrul85cc5d82016-12-20 03:37:41299 SharedMainThreadContextProvider();
[email protected]c29b7ff2013-03-06 03:51:04300
[email protected]b2d98762012-09-03 17:04:06301 // 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:
hablichd6a4f122015-10-28 11:34:49324 FRIEND_TEST_ALL_PREFIXES(RenderThreadImplUnittest,
325 IdentifyAlexaTop10NonGoogleSite);
[email protected]b2d98762012-09-03 17:04:06326 friend class RenderThreadImplUnittest;
327
hablichd6a4f122015-10-28 11:34:49328 // 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]b2d98762012-09-03 17:04:06334 // 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
benf28ce882017-05-02 16:15:49355 void RegisterPendingFrameCreate(
benf28ce882017-05-02 16:15:49356 int routing_id,
Henrique Ferreiro3a9751c2019-09-30 13:54:07357 mojo::PendingReceiver<mojom::Frame> frame);
rockotf8fdd9b2015-12-16 22:22:35358
jam188f19f2017-06-07 03:56:24359 mojom::RendererHost* GetRendererHost();
jamc912ca32016-02-24 20:17:31360
keishi51ed0d52017-01-12 10:04:46361 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 };
bashia0ba0d42017-04-03 08:11:06371 bool GetRendererMemoryMetrics(RendererMemoryMetrics* memory_metrics) const;
keishi51ed0d52017-01-12 10:04:46372
Aditya Keerthie84331b32019-03-20 15:25:52373 void RecordMetricsForBackgroundedRendererPurge();
374
Miguel Casas5e1018052018-01-09 19:17:36375 // Sets the current pipeline rendering color space.
376 void SetRenderingColorSpace(const gfx::ColorSpace& color_space);
377
philipel6376903422021-03-04 16:18:45378 gfx::ColorSpace GetRenderingColorSpace();
379
CJ DiMeglio79f7c91a22018-08-30 22:24:43380 scoped_refptr<base::SingleThreadTaskRunner>
381 CreateVideoFrameCompositorTaskRunner();
382
CJ DiMegliob6eb9cd2018-11-06 23:44:01383 // 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]8930d472009-02-21 08:05:28391 private:
Aditya Keerthic0d45b42019-02-25 18:53:00392 friend class RenderThreadImplBrowserTest;
Dominic Farolino08c265692020-09-24 06:59:42393 friend class AgentSchedulingGroup;
Aditya Keerthic0d45b42019-02-25 18:53:00394
Nicholas Verne06de8122017-11-16 04:47:38395 void OnProcessFinalRelease() override;
torne88b66452016-05-03 13:22:14396 // IPC::Listener
397 void OnChannelError() override;
398
[email protected]57cf97882013-06-26 20:39:01399 // ChildThread
dcheng6d18e402014-10-21 12:32:52400 bool OnControlMessageReceived(const IPC::Message& msg) override;
liberato3aeeb2c2016-02-25 17:54:38401 void RecordAction(const base::UserMetricsAction& action) override;
402 void RecordComputedAction(const std::string& action) override;
initial.commit09911bf2008-07-26 23:55:29403
sadrul53546592016-12-17 01:44:21404 bool IsMainThread();
[email protected]57cf97882013-06-26 20:39:01405
Greg Kraynovf5d60272018-08-10 12:28:51406 void Init();
vollick1050cc62015-12-03 07:04:54407 void InitializeCompositorThread();
Ken Rockot13051c932019-11-14 20:11:51408 void InitializeWebKit(mojo::BinderMap* binders);
jam75c44222016-03-23 05:34:24409
initial.commit09911bf2008-07-26 23:55:29410 void OnTransferBitmap(const SkBitmap& bitmap, int resource_id);
[email protected]b3df5a42010-05-11 14:31:09411 void OnGetAccessibilityTree();
blundellc00adf442016-09-16 10:43:41412
rockot067ca55f2016-09-30 22:00:15413 // mojom::Renderer:
Tal Pressmanc951ed92020-09-01 00:24:23414 void CreateAgentSchedulingGroup(
Tal Pressmand12a68112021-02-12 04:29:01415 mojo::PendingReceiver<IPC::mojom::ChannelBootstrap> bootstrap,
416 mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker> broker_remote)
417 override;
Tal Pressman25d1eae2020-09-14 02:35:47418 void CreateAssociatedAgentSchedulingGroup(
Tal Pressman25d1eae2020-09-14 02:35:47419 mojo::PendingAssociatedReceiver<mojom::AgentSchedulingGroup>
Tal Pressmand12a68112021-02-12 04:29:01420 agent_scheduling_group,
421 mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker> broker_remote)
422 override;
rockota2db0da2016-10-18 17:39:11423 void OnNetworkConnectionChanged(
424 net::NetworkChangeNotifier::ConnectionType type,
425 double max_bandwidth_mbps) override;
tbansalb612c5d2017-05-25 18:53:06426 void OnNetworkQualityChanged(net::EffectiveConnectionType type,
427 base::TimeDelta http_rtt,
tbansal99d8aeb2017-05-22 19:12:58428 base::TimeDelta transport_rtt,
tbansal15973c32017-05-10 18:40:44429 double bandwidth_kbps) override;
rockota2db0da2016-10-18 17:39:11430 void SetWebKitSharedTimersSuspended(bool suspend) override;
Yutaka Hiranob0465f72018-05-17 05:48:25431 void SetUserAgent(const std::string& user_agent) override;
Mike West6e4cbb32019-02-13 09:40:17432 void SetUserAgentMetadata(const blink::UserAgentMetadata& metadata) override;
John Abd-El-Malek4058ad22020-06-03 21:16:04433 void SetCorsExemptHeaderList(const std::vector<std::string>& list) override;
rockota2db0da2016-10-18 17:39:11434 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 Popescu237e8e32019-08-07 19:50:54439 void UpdateSystemColorInfo(
440 mojom::UpdateSystemColorInfoParamsPtr params) override;
rockota2db0da2016-10-18 17:39:11441 void PurgePluginListCache(bool reload_pages) override;
John Budorickee1c9512019-10-17 15:32:19442 void SetProcessState(mojom::RenderProcessBackgroundState background_state,
443 mojom::RenderProcessVisibleState visible_state) override;
Shubhie Panicker45ce80a82018-02-01 01:40:19444 void SetSchedulerKeepActive(bool keep_active) override;
Nasko Oskov1c2c0492019-03-14 20:13:39445 void SetIsLockedToSite() override;
Sebastien Marchand836d04b32020-04-28 18:10:03446#if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX)
447 void WriteClangProfilingProfile(
448 WriteClangProfilingProfileCallback callback) override;
449#endif
Yutaka Hirano9881e99a2020-06-22 06:54:05450 void SetIsCrossOriginIsolated(bool value) override;
Mike Westf9cd9452021-05-07 15:53:23451 void SetIsDirectSocketEnabled(bool value) override;
[email protected]5071cb22013-07-10 02:19:06452 void OnMemoryPressure(
453 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
rockota2db0da2016-10-18 17:39:11454
rmcilroyaa296052015-04-14 15:35:27455 bool RendererIsHidden() const;
456 void OnRendererHidden();
457 void OnRendererVisible();
[email protected]b3df5a42010-05-11 14:31:09458
Aditya Keerthic0d45b42019-02-25 18:53:00459 bool RendererIsBackgrounded() const;
460 void OnRendererBackgrounded();
461 void OnRendererForegrounded();
462
tasak335a1872017-06-14 09:50:23463 void RecordMemoryUsageAfterBackgrounded(const char* suffix,
464 int foregrounded_count);
Aditya Keerthie84331b32019-03-20 15:25:52465 void OnRecordMetricsForBackgroundedRendererPurgeTimerExpired(
tasakbb0640b2017-05-15 09:02:26466 const char* suffix,
467 int foregrounded_count_when_purged);
tasakb46626a2016-10-18 05:54:44468
ssid0603ca9f2015-06-09 16:48:08469 void ReleaseFreeMemory();
470
hong.zhengb28b5332016-05-11 02:33:39471 void OnSyncMemoryPressure(
472 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
473
Julie Jeongeun Kim4e77af2622019-09-11 03:36:45474 void OnRendererInterfaceReceiver(
475 mojo::PendingAssociatedReceiver<mojom::Renderer> receiver);
rockot067ca55f2016-09-30 22:00:15476
Thiabaud Engelbrechtc4c42392020-12-01 18:24:39477 scoped_refptr<discardable_memory::ClientDiscardableSharedMemoryManager>
Gordon Guan96c21ee2019-11-06 15:05:39478 discardable_memory_allocator_;
penghuang342762b2016-12-02 21:04:58479
initial.commit09911bf2008-07-26 23:55:29480 // These objects live solely on the render thread.
Yuta Kitamuradeb91bb2018-05-29 05:53:20481 std::unique_ptr<blink::scheduler::WebThreadScheduler> main_thread_scheduler_;
dchengcedca5612016-04-09 01:40:15482 std::unique_ptr<RendererBlinkPlatformImpl> blink_platform_impl_;
Minggang Wang1df377df2021-03-08 04:45:40483 std::unique_ptr<blink::URLLoaderThrottleProvider>
484 url_loader_throttle_provider_;
[email protected]9291ed12009-07-23 17:33:22485
Minggang Wang8cd77ac2021-01-30 18:00:44486 std::vector<std::string> cors_exempt_header_list_;
487
liushouqun517b1292016-09-14 05:58:59488 // Used on the render thread.
Antonio Gomes925f9b92019-07-30 23:23:23489 std::unique_ptr<blink::WebVideoCaptureImplManager> vc_manager_;
[email protected]da9f30a2014-06-18 19:39:04490
Aditya Keerthic0d45b42019-02-25 18:53:00491 // 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 Budorickee1c9512019-10-17 15:32:19494 base::Optional<mojom::RenderProcessBackgroundState> background_state_;
495 base::Optional<mojom::RenderProcessVisibleState> visible_state_;
[email protected]bee16aab2009-08-26 15:55:03496
Yutaka Hiranob0465f72018-05-17 05:48:25497 blink::WebString user_agent_;
Mike West6e4cbb32019-02-13 09:40:17498 blink::UserAgentMetadata user_agent_metadata_;
Yutaka Hiranob0465f72018-05-17 05:48:25499
danakjab9ef4d2017-10-31 23:38:33500 // 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
dcastagna7f45dada2015-10-19 20:17:35505 // Utility class to provide GPU functionalities to media.
dcastagna09bd6b32016-02-01 21:54:28506 // 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-Sanchezcfcca5d52017-07-07 02:32:59509 std::vector<std::unique_ptr<GpuVideoAcceleratorFactoriesImpl>> gpu_factories_;
dcastagna7f45dada2015-10-19 20:17:35510
Frank Liberato3afa5982020-12-10 06:13:44511 // 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]c1330c82013-06-06 02:23:25515 // Thread for running multimedia operations (e.g., video decoding).
dchengcedca5612016-04-09 01:40:15516 std::unique_ptr<base::Thread> media_thread_;
[email protected]c1330c82013-06-06 02:23:25517
Bo Liu8a39c4782021-03-06 00:50:54518 std::unique_ptr<gfx::RenderingPipeline> main_thread_pipeline_;
519 std::unique_ptr<gfx::RenderingPipeline> compositor_thread_pipeline_;
520
skyostil2d3b5bd2015-05-27 15:40:59521 // Will point to appropriate task runner after initialization,
[email protected]ea5f70a2013-03-07 12:30:36522 // regardless of whether |compositor_thread_| is overriden.
skyostil2d3b5bd2015-05-27 15:40:59523 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
[email protected]ea5f70a2013-03-07 12:30:36524
CJ DiMeglio79f7c91a22018-08-30 22:24:43525 // Task to run the VideoFrameCompositor on.
526 scoped_refptr<base::SingleThreadTaskRunner>
527 video_frame_compositor_task_runner_;
528
dcastagnab880e8f2015-06-30 20:16:06529 // Pool of workers used for raster operations (e.g., tile rasterization).
prashant.nfad657e2016-06-01 07:52:17530 scoped_refptr<CategorizedWorkerPool> categorized_worker_pool_;
reveman34b7a1522015-03-23 20:27:47531
boliubee541f42015-11-05 00:52:53532#if defined(OS_ANDROID)
siva.gunturi5d4feb052015-11-15 16:15:31533 scoped_refptr<StreamTextureFactory> stream_texture_factory_;
boliubee541f42015-11-05 00:52:53534#endif
535
Scott Violet703b8242019-06-11 19:34:36536 scoped_refptr<viz::ContextProviderCommandBuffer> shared_main_thread_contexts_;
[email protected]c29b7ff2013-03-06 03:51:04537
Trent Apteda250ec3ab2018-08-19 08:52:19538 base::ObserverList<RenderThreadObserver>::Unchecked observers_;
[email protected]1223d6ef2011-03-28 16:47:50539
Sergey Ulanov83f4a152019-02-14 03:54:25540 scoped_refptr<viz::RasterContextProvider>
541 video_frame_compositor_context_provider_;
CJ DiMeglio79f7c91a22018-08-30 22:24:43542
Victor Miuraff6488612017-12-21 04:16:15543 scoped_refptr<viz::RasterContextProvider> shared_worker_context_provider_;
[email protected]3b2afc32012-06-18 21:31:16544
[email protected]b2d98762012-09-03 17:04:06545 HistogramCustomizer histogram_customizer_;
546
dchengcedca5612016-04-09 01:40:15547 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
[email protected]5071cb22013-07-10 02:19:06548
Scott Violet703b8242019-06-11 19:34:36549 std::unique_ptr<viz::Gpu> gpu_;
sadrul9e0bb1d2016-08-04 20:18:39550
Alex Clarke9fc39b9b2020-01-31 17:29:47551 std::unique_ptr<VariationsRenderThreadObserver> variations_observer_;
552
danakj6e3bf8012014-12-16 18:27:53553 // Compositor settings.
senorblancob60ba952015-01-27 19:12:36554 int gpu_rasterization_msaa_sample_count_;
[email protected]a23530d2014-03-11 06:04:14555 bool is_lcd_text_enabled_;
[email protected]2cccfef2014-05-01 06:05:16556 bool is_zero_copy_enabled_;
ccameronc7fcd132015-11-03 20:14:31557 bool is_gpu_memory_buffer_compositor_resources_enabled_;
ericrk1d17f752015-10-20 03:03:07558 bool is_partial_raster_enabled_;
ccamerona7644752014-12-30 01:16:31559 bool is_elastic_overscroll_enabled_;
danakj4b347212018-07-04 17:55:17560 bool is_zoom_for_dsf_enabled_;
loyso65c93c602015-08-11 05:15:57561 bool is_threaded_animation_enabled_;
wjmaclean1d970622017-01-21 22:28:24562 bool is_scroll_animator_enabled_;
[email protected]a23530d2014-03-11 06:04:14563
Miguel Casas5e1018052018-01-09 19:17:36564 // Target rendering ColorSpace.
565 gfx::ColorSpace rendering_color_space_;
566
Scott Violet9b2d60dc2020-05-13 04:05:04567 // Used when AddRoute() is called and the RenderFrameImpl hasn't been created
568 // yet.
569 std::map<int, mojo::PendingReceiver<mojom::Frame>> pending_frames_;
rockotf8fdd9b2015-12-16 22:22:35570
Julie Jeongeun Kimdaa9aa12019-10-24 02:51:56571 mojo::AssociatedRemote<mojom::RendererHost> renderer_host_;
jamc912ca32016-02-24 20:17:31572
Ken Rockot26e4e802018-07-31 15:03:33573 blink::AssociatedInterfaceRegistry associated_interfaces_;
rockot067ca55f2016-09-30 22:00:15574
Julie Jeongeun Kim4e77af2622019-09-11 03:36:45575 mojo::AssociatedReceiver<mojom::Renderer> renderer_receiver_{this};
rockot067ca55f2016-09-30 22:00:15576
Julie Jeongeun Kim23966e22019-10-26 02:13:29577 mojo::AssociatedRemote<mojom::RenderMessageFilter> render_message_filter_;
rockot1587e332016-07-27 17:44:14578
Tal Pressmanc951ed92020-09-01 00:24:23579 std::set<std::unique_ptr<AgentSchedulingGroup>, base::UniquePtrComparator>
580 agent_scheduling_groups_;
Tal Pressman9780e2c2020-08-26 06:35:09581
tasak72f64042017-01-19 14:02:53582 RendererMemoryMetrics purge_and_suspend_memory_metrics_;
tasakbb0640b2017-05-15 09:02:26583 int process_foregrounded_count_;
hajimehoshi69093272016-05-13 08:30:58584
staraz067f58242016-11-07 21:06:41585 int32_t client_id_;
586
danakjab9ef4d2017-10-31 23:38:33587 // A mojo connection to the CompositingModeReporter service.
Gyuyoung Kimc9cf74a2019-11-05 00:54:35588 mojo::Remote<viz::mojom::CompositingModeReporter> compositing_mode_reporter_;
danakjab9ef4d2017-10-31 23:38:33589 // The class is a CompositingModeWatcher, which is bound to mojo through
danakj4ee301c2017-11-29 16:19:43590 // this member.
Gyuyoung Kimef648a2e72019-09-17 09:48:35591 mojo::Receiver<viz::mojom::CompositingModeWatcher>
592 compositing_mode_watcher_receiver_{this};
danakjab9ef4d2017-10-31 23:38:33593
Minggang Wang8cd77ac2021-01-30 18:00:44594 // Delegate is expected to live as long as requests may be sent.
595 blink::WebResourceRequestSenderDelegate* resource_request_sender_delegate_ =
596 nullptr;
597
Jeremy Roman3bca4bf2019-07-11 03:41:25598 base::WeakPtrFactory<RenderThreadImpl> weak_factory_{this};
Ben Goodgerf180ce12018-02-09 22:54:01599
[email protected]f1a29a02011-10-06 23:08:44600 DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl);
initial.commit09911bf2008-07-26 23:55:29601};
602
[email protected]e9ff79c2012-10-19 21:31:26603} // namespace content
604
[email protected]f1a29a02011-10-06 23:08:44605#endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_