blob: c7aeb9f406144b7d53ab16ef28d987e4e9a5cfb0 [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
[email protected]6779aa12011-03-29 17:32:248#include <set>
[email protected]b68d5ed2009-04-16 02:41:289#include <string>
[email protected]1bc83062009-02-06 00:16:3710#include <vector>
11
jdduke691dd572014-12-02 20:47:5212#include "base/cancelable_callback.h"
[email protected]5071cb22013-07-10 02:19:0613#include "base/memory/memory_pressure_listener.h"
rockot775ce0d2015-01-27 18:35:0114#include "base/memory/ref_counted.h"
[email protected]e6e30ac2014-01-13 21:24:3915#include "base/metrics/user_metrics_action.h"
[email protected]1223d6ef2011-03-28 16:47:5016#include "base/observer_list.h"
[email protected]21aa99682013-06-11 07:17:0117#include "base/strings/string16.h"
[email protected]88105162013-12-05 01:02:1218#include "base/threading/thread_checker.h"
[email protected]abb522162013-06-28 01:54:1619#include "base/timer/timer.h"
[email protected]037fce02009-01-22 01:42:1520#include "build/build_config.h"
jam8a021512a2015-02-03 18:16:0821#include "content/child/child_thread_impl.h"
[email protected]8d128d62011-09-13 22:11:5722#include "content/common/content_export.h"
alexmosbc7eafa2014-12-06 01:38:0923#include "content/common/frame_replication_state.h"
[email protected]c26ad882012-02-07 06:41:2024#include "content/common/gpu/client/gpu_channel_host.h"
[email protected]a2c351d2014-07-14 23:42:3925#include "content/common/gpu/gpu_result_codes.h"
[email protected]526476902011-10-06 20:34:0626#include "content/public/renderer/render_thread.h"
danakj6e3bf8012014-12-16 18:27:5327#include "content/renderer/gpu/compositor_dependencies.h"
[email protected]d7ff5fb2014-05-29 19:50:2528#include "net/base/network_change_notifier.h"
29#include "third_party/WebKit/public/platform/WebConnectionType.h"
[email protected]08397d52011-02-05 01:53:3830#include "ui/gfx/native_widget_types.h"
initial.commit09911bf2008-07-26 23:55:2931
[email protected]291857a2014-01-23 17:49:1132#if defined(OS_MACOSX)
33#include "third_party/WebKit/public/web/mac/WebScrollbarTheme.h"
34#endif
35
[email protected]c29b7ff2013-03-06 03:51:0436class GrContext;
[email protected]39008c02009-02-11 23:59:2537class SkBitmap;
alexmos9f8705a2015-05-06 19:58:5938struct FrameMsg_NewFrame_Params;
[email protected]9a292e22012-10-22 15:19:3139struct ViewMsg_New_Params;
kerrnelc39eeb72015-06-25 21:11:4840struct ViewMsg_UpdateScrollbarTheme_Params;
[email protected]0ec90d522014-03-12 16:28:1941struct WorkerProcessMsg_CreateWorker_Params;
[email protected]46f36a492010-07-28 19:36:4142
[email protected]180ef242013-11-07 06:50:4643namespace blink {
[email protected]ca998e5e2013-08-06 14:59:0944class WebGamepads;
[email protected]c29b7ff2013-03-06 03:51:0445class WebGraphicsContext3D;
[email protected]d8cd8372012-03-09 10:49:5146class WebMediaStreamCenter;
47class WebMediaStreamCenterClient;
[email protected]b7c7bcf2009-10-03 07:07:3448}
49
[email protected]64ffa0442011-10-03 22:08:3650namespace base {
skyostil457b0a12014-09-09 10:12:0751class SingleThreadTaskRunner;
[email protected]64ffa0442011-10-03 22:08:3652class Thread;
53}
54
[email protected]c29b7ff2013-03-06 03:51:0455namespace cc {
56class ContextProvider;
reveman34b7a1522015-03-23 20:27:4757class TaskGraphRunner;
[email protected]c29b7ff2013-03-06 03:51:0458}
59
tfarinaae8232df2015-02-04 13:10:0260namespace cc_blink {
61class ContextProviderWebContext;
62}
63
[email protected]1842fe22012-08-13 23:24:3564namespace IPC {
[email protected]74122042014-04-25 00:07:3065class MessageFilter;
[email protected]1842fe22012-08-13 23:24:3566}
67
[email protected]563d665f2013-02-01 04:42:3968namespace media {
hayato5713bf142015-03-31 02:02:0469class AudioHardwareConfig;
[email protected]2329bfc72014-02-28 02:03:2170class GpuVideoAcceleratorFactories;
[email protected]563d665f2013-02-01 04:42:3971}
72
jochen83c639f02015-04-22 17:07:3773namespace scheduler {
74class RendererScheduler;
75}
76
[email protected]e9ff79c2012-10-19 21:31:2677namespace v8 {
78class Extension;
79}
80
[email protected]64ffa0442011-10-03 22:08:3681namespace content {
[email protected]e9ff79c2012-10-19 21:31:2682
[email protected]eb398192012-10-22 20:16:1983class AppCacheDispatcher;
[email protected]da9f30a2014-06-18 19:39:0484class AecDumpMessageFilter;
[email protected]9a292e22012-10-22 15:19:3185class AudioInputMessageFilter;
86class AudioMessageFilter;
[email protected]3958e972012-07-17 00:25:4187class AudioRendererMixerManager;
jyasskinf89a11b2015-07-21 00:27:4888class BluetoothMessageFilter;
fsamuel6c1dfeb2014-12-18 19:21:3389class BrowserPluginManager;
jsbell279efb42015-03-31 17:02:4690class CacheStorageDispatcher;
simonhonga7e3ac42014-11-11 20:50:2291class CompositorForwardingMessageFilter;
[email protected]a45c46e2013-03-07 01:04:4692class ContextProviderCommandBuffer;
[email protected]3827e9702012-10-23 06:19:2893class DBMessageFilter;
[email protected]e9ff79c2012-10-19 21:31:2694class DevToolsAgentFilter;
95class DomStorageDispatcher;
[email protected]7670d4332013-11-29 04:35:0096class EmbeddedWorkerDispatcher;
[email protected]eb398192012-10-22 20:16:1997class GpuChannelHost;
98class IndexedDBDispatcher;
[email protected]ea5f70a2013-03-07 12:30:3699class InputHandlerManager;
[email protected]d8cd8372012-03-09 10:49:51100class MediaStreamCenter;
[email protected]fdeac262014-07-10 12:52:51101class MemoryObserver;
[email protected]6e068ea2014-02-04 07:05:47102class MidiMessageFilter;
[email protected]d7ff5fb2014-05-29 19:50:25103class NetInfoDispatcher;
[email protected]4761cf12012-09-12 10:37:55104class P2PSocketDispatcher;
jsbellabadb9b2015-03-23 21:03:44105class PeerConnectionDependencyFactory;
[email protected]af089972013-01-10 04:04:40106class PeerConnectionTracker;
dcastagnab880e8f2015-06-30 20:16:06107class RasterWorkerPool;
[email protected]64ffa0442011-10-03 22:08:36108class RenderProcessObserver;
tfarina556a7232014-10-05 01:02:09109class RendererBlinkPlatformImpl;
110class RendererDemuxerAndroid;
jdduke94ae1f32015-02-05 06:27:13111class ResourceDispatchThrottler;
alexclarke0bc36e8d32014-12-17 17:29:20112class ResourceSchedulingFilter;
alph666f80f2014-12-08 15:52:11113class V8SamplingProfiler;
[email protected]9a292e22012-10-22 15:19:31114class VideoCaptureImplManager;
[email protected]eb398192012-10-22 20:16:19115class WebGraphicsContext3DCommandBufferImpl;
[email protected]921480f62013-07-20 03:42:57116class WebRTCIdentityService;
[email protected]cb25aa12012-08-07 19:13:43117
jam8a021512a2015-02-03 18:16:08118#if defined(COMPILER_MSVC)
119// See explanation for other RenderViewHostImpl which is the same issue.
120#pragma warning(push)
121#pragma warning(disable: 4250)
122#endif
123
[email protected]f1a29a02011-10-06 23:08:44124// The RenderThreadImpl class represents a background thread where RenderView
initial.commit09911bf2008-07-26 23:55:29125// instances live. The RenderThread supports an API that is used by its
126// consumer to talk indirectly to the RenderViews and supporting objects.
127// Likewise, it provides an API for the RenderViews to talk back to the main
[email protected]770005b2012-04-16 15:58:13128// process (i.e., their corresponding WebContentsImpl).
initial.commit09911bf2008-07-26 23:55:29129//
130// Most of the communication occurs in the form of IPC messages. They are
131// routed to the RenderThread according to the routing IDs of the messages.
132// The routing IDs correspond to RenderView instances.
danakj6e3bf8012014-12-16 18:27:53133class CONTENT_EXPORT RenderThreadImpl
134 : public RenderThread,
jam8a021512a2015-02-03 18:16:08135 public ChildThreadImpl,
danakj6e3bf8012014-12-16 18:27:53136 public GpuChannelHostFactory,
137 NON_EXPORTED_BASE(public CompositorDependencies) {
initial.commit09911bf2008-07-26 23:55:29138 public:
leon.han2c0f9f12015-07-11 02:01:19139 static RenderThreadImpl* Create(const InProcessChildThreadParams& params);
140 static RenderThreadImpl* Create(
skyostil246a86402015-07-18 01:43:50141 scoped_ptr<base::MessageLoop> main_message_loop,
142 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler);
[email protected]f1a29a02011-10-06 23:08:44143 static RenderThreadImpl* current();
[email protected]526476902011-10-06 20:34:06144
dcheng6d18e402014-10-21 12:32:52145 ~RenderThreadImpl() override;
146 void Shutdown() override;
initial.commit09911bf2008-07-26 23:55:29147
[email protected]58436a12012-03-21 17:10:26148 // When initializing WebKit, ensure that any schemes needed for the content
149 // module are registered properly. Static to allow sharing with tests.
150 static void RegisterSchemes();
151
[email protected]df9accd2014-03-13 18:18:30152 // Notify V8 that the date/time configuration of the system might have
153 // changed.
154 static void NotifyTimezoneChange();
155
[email protected]e9ff79c2012-10-19 21:31:26156 // RenderThread implementation:
dcheng6d18e402014-10-21 12:32:52157 bool Send(IPC::Message* msg) override;
dcheng6d18e402014-10-21 12:32:52158 IPC::SyncChannel* GetChannel() override;
159 std::string GetLocale() override;
160 IPC::SyncMessageFilter* GetSyncMessageFilter() override;
skyostil12262cf2015-05-21 14:49:31161 scoped_refptr<base::SingleThreadTaskRunner> GetIOMessageLoopProxy() override;
dcheng6d18e402014-10-21 12:32:52162 void AddRoute(int32 routing_id, IPC::Listener* listener) override;
163 void RemoveRoute(int32 routing_id) override;
164 int GenerateRoutingID() override;
165 void AddFilter(IPC::MessageFilter* filter) override;
166 void RemoveFilter(IPC::MessageFilter* filter) override;
167 void AddObserver(RenderProcessObserver* observer) override;
168 void RemoveObserver(RenderProcessObserver* observer) override;
169 void SetResourceDispatcherDelegate(
mohan.reddyee0b42a2014-10-08 04:53:14170 ResourceDispatcherDelegate* delegate) override;
dcheng6d18e402014-10-21 12:32:52171 void EnsureWebKitInitialized() override;
172 void RecordAction(const base::UserMetricsAction& action) override;
173 void RecordComputedAction(const std::string& action) override;
174 scoped_ptr<base::SharedMemory> HostAllocateSharedMemoryBuffer(
mohan.reddyee0b42a2014-10-08 04:53:14175 size_t buffer_size) override;
jbauman2f5c1942014-12-06 03:28:24176 cc::SharedBitmapManager* GetSharedBitmapManager() override;
dcheng6d18e402014-10-21 12:32:52177 void RegisterExtension(v8::Extension* extension) override;
178 void ScheduleIdleHandler(int64 initial_delay_ms) override;
179 void IdleHandler() override;
180 int64 GetIdleNotificationDelayInMs() const override;
181 void SetIdleNotificationDelayInMs(
mohan.reddyee0b42a2014-10-08 04:53:14182 int64 idle_notification_delay_in_ms) override;
dcheng6d18e402014-10-21 12:32:52183 void UpdateHistograms(int sequence_number) override;
184 int PostTaskToAllWebWorkers(const base::Closure& closure) override;
185 bool ResolveProxy(const GURL& url, std::string* proxy_list) override;
186 base::WaitableEvent* GetShutdownEvent() override;
dcheng6d18e402014-10-21 12:32:52187 ServiceRegistry* GetServiceRegistry() override;
[email protected]1223d6ef2011-03-28 16:47:50188
danakj6e3bf8012014-12-16 18:27:53189 // CompositorDependencies implementation.
danakj6e3bf8012014-12-16 18:27:53190 bool IsGpuRasterizationForced() override;
191 bool IsGpuRasterizationEnabled() override;
senorblancob60ba952015-01-27 19:12:36192 int GetGpuRasterizationMSAASampleCount() override;
danakj6e3bf8012014-12-16 18:27:53193 bool IsLcdTextEnabled() override;
194 bool IsDistanceFieldTextEnabled() override;
195 bool IsZeroCopyEnabled() override;
196 bool IsOneCopyEnabled() override;
ccamerona7644752014-12-30 01:16:31197 bool IsElasticOverscrollEnabled() override;
jie.a.chen0ffadce32015-08-07 12:59:23198 std::vector<unsigned> GetImageTextureTargets() override;
danakj6e3bf8012014-12-16 18:27:53199 scoped_refptr<base::SingleThreadTaskRunner>
200 GetCompositorMainThreadTaskRunner() override;
201 scoped_refptr<base::SingleThreadTaskRunner>
202 GetCompositorImplThreadTaskRunner() override;
203 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
jochen83c639f02015-04-22 17:07:37204 scheduler::RendererScheduler* GetRendererScheduler() override;
danakj6e3bf8012014-12-16 18:27:53205 cc::ContextProvider* GetSharedMainThreadContextProvider() override;
206 scoped_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource(
207 int routing_id) override;
reveman34b7a1522015-03-23 20:27:47208 cc::TaskGraphRunner* GetTaskGraphRunner() override;
209 bool IsGatherPixelRefsEnabled() override;
danakj6e3bf8012014-12-16 18:27:53210
[email protected]b3e83de2012-02-07 03:33:28211 // Synchronously establish a channel to the GPU plugin if not previously
212 // established or if it has been lost (for example if the GPU plugin crashed).
213 // If there is a pending asynchronous request, it will be completed by the
214 // time this routine returns.
[email protected]96ab016c2013-10-23 00:50:29215 GpuChannelHost* EstablishGpuChannelSync(CauseForGpuLaunch);
[email protected]b3e83de2012-02-07 03:33:28216
217
jdduked73ae5412015-05-11 20:07:16218 // This method modifies how the next message is sent. Normally, when sending
[email protected]c1f50aa2010-02-18 03:46:57219 // a synchronous message that runs a nested message loop, we need to suspend
220 // callbacks into WebKit. This involves disabling timers and deferring
221 // resource loads. However, there are exceptions when we need to customize
222 // the behavior.
[email protected]c1f50aa2010-02-18 03:46:57223 void DoNotNotifyWebKitOfModalLoop();
224
[email protected]70dee7e2013-05-29 18:28:30225 // True if we are running layout tests. This currently disables forwarding
226 // various status messages to the console, skips network error pages, and
227 // short circuits size update and focus events.
228 bool layout_test_mode() const {
229 return layout_test_mode_;
[email protected]233567d2013-02-27 20:22:02230 }
[email protected]70dee7e2013-05-29 18:28:30231 void set_layout_test_mode(bool layout_test_mode) {
232 layout_test_mode_ = layout_test_mode;
[email protected]ac7f5a02013-03-16 16:14:41233 }
234
tfarina556a7232014-10-05 01:02:09235 RendererBlinkPlatformImpl* blink_platform_impl() const {
236 DCHECK(blink_platform_impl_);
237 return blink_platform_impl_.get();
[email protected]078780b2014-06-20 16:57:06238 }
239
simonhonga7e3ac42014-11-11 20:50:22240 CompositorForwardingMessageFilter* compositor_message_filter() const {
241 return compositor_message_filter_.get();
[email protected]1842fe22012-08-13 23:24:35242 }
243
[email protected]ea5f70a2013-03-07 12:30:36244 InputHandlerManager* input_handler_manager() const {
245 return input_handler_manager_.get();
246 }
247
danakj6e3bf8012014-12-16 18:27:53248 // Will be null if threaded compositing has not been enabled.
skyostil2d3b5bd2015-05-27 15:40:59249 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner() const {
250 return compositor_task_runner_;
[email protected]a9fb30aa2011-10-06 06:58:46251 }
252
[email protected]f430b5712009-08-21 21:46:31253 AppCacheDispatcher* appcache_dispatcher() const {
254 return appcache_dispatcher_.get();
255 }
256
[email protected]19b49512012-05-30 19:22:09257 DomStorageDispatcher* dom_storage_dispatcher() const {
258 return dom_storage_dispatcher_.get();
259 }
260
[email protected]7670d4332013-11-29 04:35:00261 EmbeddedWorkerDispatcher* embedded_worker_dispatcher() const {
262 return embedded_worker_dispatcher_.get();
263 }
264
[email protected]f7eb0a392011-07-12 10:19:51265 AudioInputMessageFilter* audio_input_message_filter() {
266 return audio_input_message_filter_.get();
267 }
268
269 AudioMessageFilter* audio_message_filter() {
270 return audio_message_filter_.get();
271 }
272
[email protected]6e068ea2014-02-04 07:05:47273 MidiMessageFilter* midi_message_filter() {
[email protected]a9875152013-06-22 04:03:03274 return midi_message_filter_.get();
275 }
[email protected]6ee10bd2012-09-13 09:01:53276
[email protected]6ca6a082013-09-22 20:10:05277#if defined(OS_ANDROID)
278 RendererDemuxerAndroid* renderer_demuxer() {
279 return renderer_demuxer_.get();
280 }
281#endif
282
[email protected]d8cd8372012-03-09 10:49:51283 // Creates the embedder implementation of WebMediaStreamCenter.
284 // The resulting object is owned by WebKit and deleted by WebKit at tear-down.
[email protected]180ef242013-11-07 06:50:46285 blink::WebMediaStreamCenter* CreateMediaStreamCenter(
286 blink::WebMediaStreamCenterClient* client);
[email protected]d8cd8372012-03-09 10:49:51287
fsamuel6c1dfeb2014-12-18 19:21:33288 BrowserPluginManager* browser_plugin_manager() const {
289 return browser_plugin_manager_.get();
290 }
291
[email protected]22fe91d2014-08-12 17:07:12292#if defined(ENABLE_WEBRTC)
[email protected]6ee10bd2012-09-13 09:01:53293 // Returns a factory used for creating RTC PeerConnection objects.
[email protected]0107d8a2014-05-16 10:20:34294 PeerConnectionDependencyFactory* GetPeerConnectionDependencyFactory();
[email protected]6ee10bd2012-09-13 09:01:53295
[email protected]af089972013-01-10 04:04:40296 PeerConnectionTracker* peer_connection_tracker() {
297 return peer_connection_tracker_.get();
298 }
299
[email protected]4761cf12012-09-12 10:37:55300 // Current P2PSocketDispatcher. Set to NULL if P2P API is disabled.
[email protected]e9ff79c2012-10-19 21:31:26301 P2PSocketDispatcher* p2p_socket_dispatcher() {
[email protected]4761cf12012-09-12 10:37:55302 return p2p_socket_dispatcher_.get();
303 }
[email protected]22fe91d2014-08-12 17:07:12304#endif
[email protected]4761cf12012-09-12 10:37:55305
[email protected]80b161a2011-06-27 17:42:11306 VideoCaptureImplManager* video_capture_impl_manager() const {
307 return vc_manager_.get();
308 }
309
[email protected]6217d392010-03-25 22:08:35310 // Get the GPU channel. Returns NULL if the channel is not established or
311 // has been lost.
312 GpuChannelHost* GetGpuChannel();
313
skyostil2d3b5bd2015-05-27 15:40:59314 // Returns a SingleThreadTaskRunner instance corresponding to the message loop
[email protected]c6a7b862010-08-20 22:19:38315 // of the thread on which file operations should be run. Must be called
316 // on the renderer's main thread.
skyostil2d3b5bd2015-05-27 15:40:59317 scoped_refptr<base::SingleThreadTaskRunner> GetFileThreadMessageLoopProxy();
[email protected]c6a7b862010-08-20 22:19:38318
acolwellb4034942014-08-28 15:42:43319 // Returns a SingleThreadTaskRunner instance corresponding to the message loop
[email protected]c1330c82013-06-06 02:23:25320 // of the thread on which media operations should be run. Must be called
321 // on the renderer's main thread.
acolwellb4034942014-08-28 15:42:43322 scoped_refptr<base::SingleThreadTaskRunner> GetMediaThreadTaskRunner();
[email protected]c1330c82013-06-06 02:23:25323
dcastagna4517a182015-08-05 19:51:03324 // A TaskRunner instance that runs tasks on the raster worker pool.
325 base::TaskRunner* GetWorkerTaskRunner();
dcastagnab880e8f2015-06-30 20:16:06326
[email protected]1784b2f2011-11-24 10:53:48327 // Causes the idle handler to skip sending idle notifications
328 // on the two next scheduled calls, so idle notifications are
329 // not sent for at least one notification delay.
330 void PostponeIdleNotification();
331
[email protected]2329bfc72014-02-28 02:03:21332 scoped_refptr<media::GpuVideoAcceleratorFactories> GetGpuFactories();
[email protected]3bb8bb32013-07-11 13:13:03333
tfarinaae8232df2015-02-04 13:10:02334 scoped_refptr<cc_blink::ContextProviderWebContext>
335 SharedMainThreadContextProvider();
[email protected]c29b7ff2013-03-06 03:51:04336
[email protected]3958e972012-07-17 00:25:41337 // AudioRendererMixerManager instance which manages renderer side mixer
338 // instances shared based on configured audio parameters. Lazily created on
339 // first call.
[email protected]e9ff79c2012-10-19 21:31:26340 AudioRendererMixerManager* GetAudioRendererMixerManager();
[email protected]3958e972012-07-17 00:25:41341
[email protected]563d665f2013-02-01 04:42:39342 // AudioHardwareConfig contains audio hardware configuration for
343 // renderer side clients. Creation requires a synchronous IPC call so it is
344 // lazily created on the first call.
345 media::AudioHardwareConfig* GetAudioHardwareConfig();
346
[email protected]feb32372012-11-21 01:14:56347#if defined(OS_WIN)
[email protected]fcf75d42013-12-03 20:11:26348 void PreCacheFontCharacters(const LOGFONT& log_font,
349 const base::string16& str);
[email protected]feb32372012-11-21 01:14:56350#endif
351
[email protected]921480f62013-07-20 03:42:57352#if defined(ENABLE_WEBRTC)
353 WebRTCIdentityService* get_webrtc_identity_service() {
354 return webrtc_identity_service_.get();
355 }
356#endif
357
[email protected]b2d98762012-09-03 17:04:06358 // For producing custom V8 histograms. Custom histograms are produced if all
359 // RenderViews share the same host, and the host is in the pre-specified set
360 // of hosts we want to produce custom diagrams for. The name for a custom
361 // diagram is the name of the corresponding generic diagram plus a
362 // host-specific suffix.
363 class CONTENT_EXPORT HistogramCustomizer {
364 public:
365 HistogramCustomizer();
366 ~HistogramCustomizer();
367
368 // Called when a top frame of a RenderView navigates. This function updates
369 // RenderThreadImpl's information about whether all RenderViews are
370 // displaying a page from the same host. |host| is the host where a
371 // RenderView navigated, and |view_count| is the number of RenderViews in
372 // this process.
373 void RenderViewNavigatedToHost(const std::string& host, size_t view_count);
374
375 // Used for customizing some histograms if all RenderViews share the same
376 // host. Returns the current custom histogram name to use for
377 // |histogram_name|, or |histogram_name| if it shouldn't be customized.
378 std::string ConvertToCustomHistogramName(const char* histogram_name) const;
379
380 private:
381 friend class RenderThreadImplUnittest;
382
383 // Used for updating the information on which is the common host which all
384 // RenderView's share (if any). If there is no common host, this function is
385 // called with an empty string.
386 void SetCommonHost(const std::string& host);
387
388 // The current common host of the RenderViews; empty string if there is no
389 // common host.
390 std::string common_host_;
391 // The corresponding suffix.
392 std::string common_host_histogram_suffix_;
393 // Set of histograms for which we want to produce a custom histogram if
394 // possible.
395 std::set<std::string> custom_histograms_;
396
397 DISALLOW_COPY_AND_ASSIGN(HistogramCustomizer);
398 };
399
400 HistogramCustomizer* histogram_customizer() {
401 return &histogram_customizer_;
402 }
403
[email protected]ca998e5e2013-08-06 14:59:09404 // Retrieve current gamepad data.
[email protected]180ef242013-11-07 06:50:46405 void SampleGamepads(blink::WebGamepads* data);
[email protected]ca998e5e2013-08-06 14:59:09406
[email protected]b2db9272014-01-10 17:42:00407 // Called by a RenderWidget when it is created or destroyed. This
408 // allows the process to know when there are no visible widgets.
409 void WidgetCreated();
rmcilroyaa296052015-04-14 15:35:27410 // Note: A widget must not be hidden when it is destroyed - ensure that
411 // WidgetRestored is called before WidgetDestroyed for any hidden widget.
[email protected]b2db9272014-01-10 17:42:00412 void WidgetDestroyed();
413 void WidgetHidden();
414 void WidgetRestored();
415
[email protected]a620b132014-04-30 22:39:17416 void AddEmbeddedWorkerRoute(int32 routing_id, IPC::Listener* listener);
417 void RemoveEmbeddedWorkerRoute(int32 routing_id);
[email protected]48e52e42014-03-20 06:58:07418
rockot775ce0d2015-01-27 18:35:01419 void RegisterPendingRenderFrameConnect(
420 int routing_id,
421 mojo::InterfaceRequest<mojo::ServiceProvider> services,
422 mojo::ServiceProviderPtr exposed_services);
[email protected]c52a1412014-06-25 06:09:25423
alexclarke0bc36e8d32014-12-17 17:29:20424 protected:
leon.han2c0f9f12015-07-11 02:01:19425 RenderThreadImpl(const InProcessChildThreadParams& params,
426 scoped_ptr<scheduler::RendererScheduler> scheduler);
427 RenderThreadImpl(scoped_ptr<base::MessageLoop> main_message_loop,
428 scoped_ptr<scheduler::RendererScheduler> scheduler);
alexclarke0bc36e8d32014-12-17 17:29:20429 virtual void SetResourceDispatchTaskQueue(
430 const scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue);
431
[email protected]8930d472009-02-21 08:05:28432 private:
[email protected]57cf97882013-06-26 20:39:01433 // ChildThread
dcheng6d18e402014-10-21 12:32:52434 bool OnControlMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29435
[email protected]57cf97882013-06-26 20:39:01436 // GpuChannelHostFactory implementation:
dcheng6d18e402014-10-21 12:32:52437 bool IsMainThread() override;
skyostild4452912015-05-14 14:41:53438 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
dcheng6d18e402014-10-21 12:32:52439 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override;
440 CreateCommandBufferResult CreateViewCommandBuffer(
[email protected]57cf97882013-06-26 20:39:01441 int32 surface_id,
[email protected]0d78ec0e2014-04-08 23:35:23442 const GPUCreateCommandBufferConfig& init_params,
mohan.reddyee0b42a2014-10-08 04:53:14443 int32 route_id) override;
[email protected]57cf97882013-06-26 20:39:01444
[email protected]42f1d7822009-07-23 18:17:55445 void Init();
initial.commit09911bf2008-07-26 23:55:29446
alexmos9f8705a2015-05-06 19:58:59447 void OnCreateNewFrame(FrameMsg_NewFrame_Params params);
[email protected]82307f6b2014-08-07 03:30:12448 void OnCreateNewFrameProxy(int routing_id,
449 int parent_routing_id,
alexmosbc7eafa2014-12-06 01:38:09450 int render_view_routing_id,
451 const FrameReplicationState& replicated_state);
[email protected]367c5c1d2013-03-11 18:59:02452 void OnSetZoomLevelForCurrentURL(const std::string& scheme,
453 const std::string& host,
454 double zoom_level);
[email protected]4e6419c2010-01-15 04:50:34455 void OnCreateNewView(const ViewMsg_New_Params& params);
initial.commit09911bf2008-07-26 23:55:29456 void OnTransferBitmap(const SkBitmap& bitmap, int resource_id);
thestigc4cac8f2014-09-04 21:17:50457#if defined(ENABLE_PLUGINS)
[email protected]b78e168b2009-09-21 22:05:45458 void OnPurgePluginListCache(bool reload_pages);
thestigc4cac8f2014-09-04 21:17:50459#endif
[email protected]8c2a34b2014-06-10 16:27:27460 void OnNetworkTypeChanged(net::NetworkChangeNotifier::ConnectionType type);
[email protected]b3df5a42010-05-11 14:31:09461 void OnGetAccessibilityTree();
jshin0a9aa632015-04-29 18:35:29462 void OnUpdateTimezone(const std::string& zoneId);
[email protected]5071cb22013-07-10 02:19:06463 void OnMemoryPressure(
464 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
[email protected]b0988b22013-11-08 08:25:58465#if defined(OS_ANDROID)
466 void OnSetWebKitSharedTimersSuspended(bool suspend);
467#endif
468#if defined(OS_MACOSX)
kerrnelc39eeb72015-06-25 21:11:48469 void OnUpdateScrollbarTheme(
470 const ViewMsg_UpdateScrollbarTheme_Params& params);
[email protected]b0988b22013-11-08 08:25:58471#endif
[email protected]0ec90d522014-03-12 16:28:19472 void OnCreateNewSharedWorker(
473 const WorkerProcessMsg_CreateWorker_Params& params);
rmcilroyaa296052015-04-14 15:35:27474 bool RendererIsHidden() const;
475 void OnRendererHidden();
476 void OnRendererVisible();
[email protected]b3df5a42010-05-11 14:31:09477
ssid0603ca9f2015-06-09 16:48:08478 void ReleaseFreeMemory();
479
[email protected]c29b7ff2013-03-06 03:51:04480 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateOffscreenContext3d();
481
initial.commit09911bf2008-07-26 23:55:29482 // These objects live solely on the render thread.
[email protected]f430b5712009-08-21 21:46:31483 scoped_ptr<AppCacheDispatcher> appcache_dispatcher_;
[email protected]1910fe82012-05-10 00:04:10484 scoped_ptr<DomStorageDispatcher> dom_storage_dispatcher_;
[email protected]31bfae72011-12-16 02:04:38485 scoped_ptr<IndexedDBDispatcher> main_thread_indexed_db_dispatcher_;
jochen83c639f02015-04-22 17:07:37486 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler_;
tfarina556a7232014-10-05 01:02:09487 scoped_ptr<RendererBlinkPlatformImpl> blink_platform_impl_;
jdduke94ae1f32015-02-05 06:27:13488 scoped_ptr<ResourceDispatchThrottler> resource_dispatch_throttler_;
jsbell279efb42015-03-31 17:02:46489 scoped_ptr<CacheStorageDispatcher> main_thread_cache_storage_dispatcher_;
[email protected]7670d4332013-11-29 04:35:00490 scoped_ptr<EmbeddedWorkerDispatcher> embedded_worker_dispatcher_;
[email protected]9291ed12009-07-23 17:33:22491
[email protected]d8cd8372012-03-09 10:49:51492 // Used on the render thread and deleted by WebKit at shutdown.
[email protected]180ef242013-11-07 06:50:46493 blink::WebMediaStreamCenter* media_stream_center_;
[email protected]d8cd8372012-03-09 10:49:51494
[email protected]e2b2d4a2009-10-24 03:32:59495 // Used on the renderer and IPC threads.
[email protected]017022b2009-07-27 23:06:34496 scoped_refptr<DBMessageFilter> db_message_filter_;
[email protected]f7eb0a392011-07-12 10:19:51497 scoped_refptr<AudioInputMessageFilter> audio_input_message_filter_;
498 scoped_refptr<AudioMessageFilter> audio_message_filter_;
[email protected]6e068ea2014-02-04 07:05:47499 scoped_refptr<MidiMessageFilter> midi_message_filter_;
[email protected]6ca6a082013-09-22 20:10:05500#if defined(OS_ANDROID)
501 scoped_refptr<RendererDemuxerAndroid> renderer_demuxer_;
502#endif
[email protected]82622452011-07-22 09:57:20503 scoped_refptr<DevToolsAgentFilter> devtools_agent_message_filter_;
alph666f80f2014-12-08 15:52:11504 scoped_ptr<V8SamplingProfiler> v8_sampling_profiler_;
[email protected]017022b2009-07-27 23:06:34505
fsamuel6c1dfeb2014-12-18 19:21:33506 scoped_ptr<BrowserPluginManager> browser_plugin_manager_;
507
[email protected]22fe91d2014-08-12 17:07:12508#if defined(ENABLE_WEBRTC)
[email protected]83e0a482014-05-22 18:07:18509 scoped_ptr<PeerConnectionDependencyFactory> peer_connection_factory_;
[email protected]6ee10bd2012-09-13 09:01:53510
[email protected]af089972013-01-10 04:04:40511 // This is used to communicate to the browser process the status
512 // of all the peer connections created in the renderer.
513 scoped_ptr<PeerConnectionTracker> peer_connection_tracker_;
514
[email protected]4761cf12012-09-12 10:37:55515 // Dispatches all P2P sockets.
[email protected]e9ff79c2012-10-19 21:31:26516 scoped_refptr<P2PSocketDispatcher> p2p_socket_dispatcher_;
[email protected]22fe91d2014-08-12 17:07:12517#endif
[email protected]4761cf12012-09-12 10:37:55518
[email protected]45048072014-01-14 13:51:29519 // Used on the render thread.
520 scoped_ptr<VideoCaptureImplManager> vc_manager_;
[email protected]80b161a2011-06-27 17:42:11521
[email protected]da9f30a2014-06-18 19:39:04522 // Used for communicating registering AEC dump consumers with the browser and
523 // receving AEC dump file handles when AEC dump is enabled. An AEC dump is
524 // diagnostic audio data for WebRTC stored locally when enabled by the user in
525 // chrome://webrtc-internals.
526 scoped_refptr<AecDumpMessageFilter> aec_dump_message_filter_;
527
[email protected]bee16aab2009-08-26 15:55:03528 // The count of RenderWidgets running through this thread.
529 int widget_count_;
530
531 // The count of hidden RenderWidgets running through this thread.
532 int hidden_widget_count_;
533
534 // The current value of the idle notification timer delay.
[email protected]6593ae12011-11-14 12:09:44535 int64 idle_notification_delay_in_ms_;
[email protected]bee16aab2009-08-26 15:55:03536
[email protected]1784b2f2011-11-24 10:53:48537 // The number of idle handler calls that skip sending idle notifications.
538 int idle_notifications_to_skip_;
539
[email protected]80fc08c52010-03-09 07:43:50540 bool notify_webkit_of_modal_loop_;
[email protected]26e82322014-01-20 14:18:22541 bool webkit_shared_timer_suspended_;
[email protected]c1f50aa2010-02-18 03:46:57542
[email protected]70dee7e2013-05-29 18:28:30543 // The following flag is used to control layout test specific behavior.
544 bool layout_test_mode_;
[email protected]233567d2013-02-27 20:22:02545
[email protected]71d6d852009-12-07 22:12:36546 // Timer that periodically calls IdleHandler.
[email protected]f1a29a02011-10-06 23:08:44547 base::RepeatingTimer<RenderThreadImpl> idle_timer_;
[email protected]71d6d852009-12-07 22:12:36548
[email protected]6217d392010-03-25 22:08:35549 // The channel from the renderer process to the GPU process.
550 scoped_refptr<GpuChannelHost> gpu_channel_;
551
[email protected]57cf97882013-06-26 20:39:01552 // Cache of variables that are needed on the compositor thread by
553 // GpuChannelHostFactory methods.
skyostild4452912015-05-14 14:41:53554 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
[email protected]57cf97882013-06-26 20:39:01555
haraken53f081d2014-11-11 01:03:40556 // The message loop of the renderer main thread.
557 // This message loop should be destructed before the RenderThreadImpl
558 // shuts down Blink.
559 scoped_ptr<base::MessageLoop> main_message_loop_;
560
[email protected]c6a7b862010-08-20 22:19:38561 // A lazily initiated thread on which file operations are run.
562 scoped_ptr<base::Thread> file_thread_;
563
[email protected]ea5f70a2013-03-07 12:30:36564 // May be null if overridden by ContentRendererClient.
565 scoped_ptr<base::Thread> compositor_thread_;
566
[email protected]c1330c82013-06-06 02:23:25567 // Thread for running multimedia operations (e.g., video decoding).
568 scoped_ptr<base::Thread> media_thread_;
569
skyostil2d3b5bd2015-05-27 15:40:59570 // Will point to appropriate task runner after initialization,
[email protected]ea5f70a2013-03-07 12:30:36571 // regardless of whether |compositor_thread_| is overriden.
skyostil2d3b5bd2015-05-27 15:40:59572 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
[email protected]ea5f70a2013-03-07 12:30:36573
dcastagnab880e8f2015-06-30 20:16:06574 // Pool of workers used for raster operations (e.g., tile rasterization).
575 scoped_refptr<RasterWorkerPool> raster_worker_pool_;
reveman34b7a1522015-03-23 20:27:47576
jdduke691dd572014-12-02 20:47:52577 base::CancelableCallback<void(const IPC::Message&)> main_input_callback_;
578 scoped_refptr<IPC::MessageFilter> input_event_filter_;
[email protected]ea5f70a2013-03-07 12:30:36579 scoped_ptr<InputHandlerManager> input_handler_manager_;
simonhonga7e3ac42014-11-11 20:50:22580 scoped_refptr<CompositorForwardingMessageFilter> compositor_message_filter_;
[email protected]1842fe22012-08-13 23:24:35581
jyasskinf89a11b2015-07-21 00:27:48582 scoped_refptr<BluetoothMessageFilter> bluetooth_message_filter_;
583
tfarinaae8232df2015-02-04 13:10:02584 scoped_refptr<cc_blink::ContextProviderWebContext>
[email protected]807567a2014-08-11 19:48:41585 shared_main_thread_contexts_;
[email protected]c29b7ff2013-03-06 03:51:04586
brettw236d3172015-06-03 16:31:43587 base::ObserverList<RenderProcessObserver> observers_;
[email protected]1223d6ef2011-03-28 16:47:50588
[email protected]93274ae2013-09-19 00:53:55589 scoped_refptr<ContextProviderCommandBuffer> gpu_va_context_provider_;
[email protected]3b2afc32012-06-18 21:31:16590
[email protected]e9ff79c2012-10-19 21:31:26591 scoped_ptr<AudioRendererMixerManager> audio_renderer_mixer_manager_;
hayato5713bf142015-03-31 02:02:04592 scoped_ptr<media::AudioHardwareConfig> audio_hardware_config_;
[email protected]3958e972012-07-17 00:25:41593
[email protected]b2d98762012-09-03 17:04:06594 HistogramCustomizer histogram_customizer_;
595
[email protected]5071cb22013-07-10 02:19:06596 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
597
[email protected]22fe91d2014-08-12 17:07:12598#if defined(ENABLE_WEBRTC)
[email protected]921480f62013-07-20 03:42:57599 scoped_ptr<WebRTCIdentityService> webrtc_identity_service_;
[email protected]22fe91d2014-08-12 17:07:12600#endif
[email protected]921480f62013-07-20 03:42:57601
[email protected]fdeac262014-07-10 12:52:51602 scoped_ptr<MemoryObserver> memory_observer_;
603
skyostil457b0a12014-09-09 10:12:07604 scoped_refptr<base::SingleThreadTaskRunner>
605 main_thread_compositor_task_runner_;
skyostil457b0a12014-09-09 10:12:07606
alexclarke0bc36e8d32014-12-17 17:29:20607 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter_;
608
danakj6e3bf8012014-12-16 18:27:53609 // Compositor settings.
[email protected]a23530d2014-03-11 06:04:14610 bool is_gpu_rasterization_enabled_;
611 bool is_gpu_rasterization_forced_;
senorblancob60ba952015-01-27 19:12:36612 int gpu_rasterization_msaa_sample_count_;
[email protected]a23530d2014-03-11 06:04:14613 bool is_lcd_text_enabled_;
[email protected]b242b142014-05-07 14:48:49614 bool is_distance_field_text_enabled_;
[email protected]2cccfef2014-05-01 06:05:16615 bool is_zero_copy_enabled_;
616 bool is_one_copy_enabled_;
ccamerona7644752014-12-30 01:16:31617 bool is_elastic_overscroll_enabled_;
jie.a.chen0ffadce32015-08-07 12:59:23618 std::vector<unsigned> use_image_texture_targets_;
reveman34b7a1522015-03-23 20:27:47619 bool is_gather_pixel_refs_enabled_;
[email protected]a23530d2014-03-11 06:04:14620
sammc00150c12015-03-15 23:25:51621 class PendingRenderFrameConnect
lwchkga15bee4c2015-07-11 04:50:49622 : public base::RefCounted<PendingRenderFrameConnect> {
sammc00150c12015-03-15 23:25:51623 public:
rockot775ce0d2015-01-27 18:35:01624 PendingRenderFrameConnect(
sammc00150c12015-03-15 23:25:51625 int routing_id,
rockot775ce0d2015-01-27 18:35:01626 mojo::InterfaceRequest<mojo::ServiceProvider> services,
627 mojo::ServiceProviderPtr exposed_services);
628
sammc00150c12015-03-15 23:25:51629 mojo::InterfaceRequest<mojo::ServiceProvider>& services() {
630 return services_;
631 }
632
633 mojo::ServiceProviderPtr& exposed_services() { return exposed_services_; }
rockot775ce0d2015-01-27 18:35:01634
635 private:
636 friend class base::RefCounted<PendingRenderFrameConnect>;
637
lwchkga15bee4c2015-07-11 04:50:49638 ~PendingRenderFrameConnect();
sammc00150c12015-03-15 23:25:51639
lwchkga15bee4c2015-07-11 04:50:49640 // Mojo error handler.
641 void OnConnectionError();
sammc00150c12015-03-15 23:25:51642
643 int routing_id_;
644 mojo::InterfaceRequest<mojo::ServiceProvider> services_;
645 mojo::ServiceProviderPtr exposed_services_;
rockot775ce0d2015-01-27 18:35:01646 };
647
648 typedef std::map<int, scoped_refptr<PendingRenderFrameConnect>>
649 PendingRenderFrameConnectMap;
650 PendingRenderFrameConnectMap pending_render_frame_connects_;
[email protected]c52a1412014-06-25 06:09:25651
[email protected]f1a29a02011-10-06 23:08:44652 DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl);
initial.commit09911bf2008-07-26 23:55:29653};
654
jam8a021512a2015-02-03 18:16:08655#if defined(COMPILER_MSVC)
656#pragma warning(pop)
657#endif
658
[email protected]e9ff79c2012-10-19 21:31:26659} // namespace content
660
[email protected]f1a29a02011-10-06 23:08:44661#endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_