OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_RENDER_THREAD_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_THREAD_H_ |
6 #define CONTENT_RENDERER_RENDER_THREAD_H_ | 6 #define CONTENT_RENDERER_RENDER_THREAD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/shared_memory.h" | 14 #include "base/shared_memory.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/timer.h" | 16 #include "base/timer.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/common/child_thread.h" | 18 #include "content/common/child_thread.h" |
19 #include "content/common/css_colors.h" | 19 #include "content/common/css_colors.h" |
20 #include "content/common/gpu_process_launch_causes.h" | 20 #include "content/common/gpu_process_launch_causes.h" |
21 #include "ipc/ipc_channel_proxy.h" | 21 #include "ipc/ipc_channel_proxy.h" |
22 #include "ui/gfx/native_widget_types.h" | 22 #include "ui/gfx/native_widget_types.h" |
23 | 23 |
24 class AppCacheDispatcher; | 24 class AppCacheDispatcher; |
25 class CookieMessageFilter; | |
26 class DBMessageFilter; | 25 class DBMessageFilter; |
27 class FilePath; | 26 class FilePath; |
28 class GpuChannelHost; | 27 class GpuChannelHost; |
29 class IndexedDBDispatcher; | 28 class IndexedDBDispatcher; |
30 class RendererHistogram; | 29 class RendererHistogram; |
31 class RendererHistogramSnapshots; | 30 class RendererHistogramSnapshots; |
32 class RenderProcessObserver; | 31 class RenderProcessObserver; |
33 class RendererNetPredictor; | 32 class RendererNetPredictor; |
34 class RendererWebKitClientImpl; | 33 class RendererWebKitClientImpl; |
35 class SkBitmap; | 34 class SkBitmap; |
36 class WebDatabaseObserverImpl; | 35 class WebDatabaseObserverImpl; |
37 | 36 |
38 struct ContentSettings; | |
39 struct RendererPreferences; | 37 struct RendererPreferences; |
40 struct DOMStorageMsg_Event_Params; | 38 struct DOMStorageMsg_Event_Params; |
41 struct GPUInfo; | 39 struct GPUInfo; |
42 struct ViewMsg_New_Params; | 40 struct ViewMsg_New_Params; |
43 struct WebPreferences; | 41 struct WebPreferences; |
44 | 42 |
45 namespace base { | 43 namespace base { |
46 class MessageLoopProxy; | 44 class MessageLoopProxy; |
47 class Thread; | 45 class Thread; |
48 } | 46 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // These methods normally get delegated to a MessageRouter. | 97 // These methods normally get delegated to a MessageRouter. |
100 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) = 0; | 98 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) = 0; |
101 virtual void RemoveRoute(int32 routing_id) = 0; | 99 virtual void RemoveRoute(int32 routing_id) = 0; |
102 | 100 |
103 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; | 101 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; |
104 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; | 102 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; |
105 | 103 |
106 // Called by a RenderWidget when it is hidden or restored. | 104 // Called by a RenderWidget when it is hidden or restored. |
107 virtual void WidgetHidden() = 0; | 105 virtual void WidgetHidden() = 0; |
108 virtual void WidgetRestored() = 0; | 106 virtual void WidgetRestored() = 0; |
109 | |
110 // True if this process is running in an incognito profile. | |
111 virtual bool IsIncognitoProcess() const = 0; | |
112 }; | 107 }; |
113 | 108 |
114 // The RenderThread class represents a background thread where RenderView | 109 // The RenderThread class represents a background thread where RenderView |
115 // instances live. The RenderThread supports an API that is used by its | 110 // instances live. The RenderThread supports an API that is used by its |
116 // consumer to talk indirectly to the RenderViews and supporting objects. | 111 // consumer to talk indirectly to the RenderViews and supporting objects. |
117 // Likewise, it provides an API for the RenderViews to talk back to the main | 112 // Likewise, it provides an API for the RenderViews to talk back to the main |
118 // process (i.e., their corresponding TabContents). | 113 // process (i.e., their corresponding TabContents). |
119 // | 114 // |
120 // Most of the communication occurs in the form of IPC messages. They are | 115 // Most of the communication occurs in the form of IPC messages. They are |
121 // routed to the RenderThread according to the routing IDs of the messages. | 116 // routed to the RenderThread according to the routing IDs of the messages. |
(...skipping 20 matching lines...) Expand all Loading... |
142 static int32 RoutingIDForCurrentContext(); | 137 static int32 RoutingIDForCurrentContext(); |
143 | 138 |
144 // Overridden from RenderThreadBase. | 139 // Overridden from RenderThreadBase. |
145 virtual bool Send(IPC::Message* msg); | 140 virtual bool Send(IPC::Message* msg); |
146 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); | 141 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); |
147 virtual void RemoveRoute(int32 routing_id); | 142 virtual void RemoveRoute(int32 routing_id); |
148 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter); | 143 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter); |
149 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter); | 144 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter); |
150 virtual void WidgetHidden(); | 145 virtual void WidgetHidden(); |
151 virtual void WidgetRestored(); | 146 virtual void WidgetRestored(); |
152 virtual bool IsIncognitoProcess() const; | |
153 | 147 |
154 void AddObserver(RenderProcessObserver* observer); | 148 void AddObserver(RenderProcessObserver* observer); |
155 void RemoveObserver(RenderProcessObserver* observer); | 149 void RemoveObserver(RenderProcessObserver* observer); |
156 | 150 |
157 // These methods modify how the next message is sent. Normally, when sending | 151 // These methods modify how the next message is sent. Normally, when sending |
158 // a synchronous message that runs a nested message loop, we need to suspend | 152 // a synchronous message that runs a nested message loop, we need to suspend |
159 // callbacks into WebKit. This involves disabling timers and deferring | 153 // callbacks into WebKit. This involves disabling timers and deferring |
160 // resource loads. However, there are exceptions when we need to customize | 154 // resource loads. However, there are exceptions when we need to customize |
161 // the behavior. | 155 // the behavior. |
162 void DoNotSuspendWebKitSharedTimer(); | 156 void DoNotSuspendWebKitSharedTimer(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 234 |
241 // Registers the given V8 extension with WebKit. | 235 // Registers the given V8 extension with WebKit. |
242 void RegisterExtension(v8::Extension* extension); | 236 void RegisterExtension(v8::Extension* extension); |
243 | 237 |
244 private: | 238 private: |
245 virtual bool OnControlMessageReceived(const IPC::Message& msg); | 239 virtual bool OnControlMessageReceived(const IPC::Message& msg); |
246 | 240 |
247 void Init(); | 241 void Init(); |
248 | 242 |
249 void OnSetZoomLevelForCurrentURL(const GURL& url, double zoom_level); | 243 void OnSetZoomLevelForCurrentURL(const GURL& url, double zoom_level); |
250 void OnSetContentSettingsForCurrentURL( | |
251 const GURL& url, const ContentSettings& content_settings); | |
252 void OnDOMStorageEvent(const DOMStorageMsg_Event_Params& params); | 244 void OnDOMStorageEvent(const DOMStorageMsg_Event_Params& params); |
253 void OnSetNextPageID(int32 next_page_id); | 245 void OnSetNextPageID(int32 next_page_id); |
254 void OnSetIsIncognitoProcess(bool is_incognito_process); | |
255 void OnSetCSSColors(const std::vector<CSSColors::CSSColorMapping>& colors); | 246 void OnSetCSSColors(const std::vector<CSSColors::CSSColorMapping>& colors); |
256 void OnCreateNewView(const ViewMsg_New_Params& params); | 247 void OnCreateNewView(const ViewMsg_New_Params& params); |
257 void OnTransferBitmap(const SkBitmap& bitmap, int resource_id); | 248 void OnTransferBitmap(const SkBitmap& bitmap, int resource_id); |
258 void OnSetCacheCapacities(size_t min_dead_capacity, | |
259 size_t max_dead_capacity, | |
260 size_t capacity); | |
261 void OnClearCache(); | |
262 void OnGetCacheResourceStats(); | |
263 | |
264 // Send tcmalloc info to browser. | |
265 void OnGetRendererTcmalloc(); | |
266 void OnGetV8HeapStats(); | |
267 | |
268 void OnPurgeMemory(); | |
269 void OnPurgePluginListCache(bool reload_pages); | 249 void OnPurgePluginListCache(bool reload_pages); |
270 | |
271 void OnGpuChannelEstablished(const IPC::ChannelHandle& channel_handle, | 250 void OnGpuChannelEstablished(const IPC::ChannelHandle& channel_handle, |
272 base::ProcessHandle renderer_process_for_gpu, | 251 base::ProcessHandle renderer_process_for_gpu, |
273 const GPUInfo& gpu_info); | 252 const GPUInfo& gpu_info); |
274 | |
275 void OnGetAccessibilityTree(); | 253 void OnGetAccessibilityTree(); |
276 | 254 |
277 // We initialize WebKit as late as possible. | 255 // We initialize WebKit as late as possible. |
278 void EnsureWebKitInitialized(); | 256 void EnsureWebKitInitialized(); |
279 | 257 |
280 // These objects live solely on the render thread. | 258 // These objects live solely on the render thread. |
281 scoped_ptr<ScopedRunnableMethodFactory<RenderThread> > task_factory_; | 259 scoped_ptr<ScopedRunnableMethodFactory<RenderThread> > task_factory_; |
282 scoped_ptr<AppCacheDispatcher> appcache_dispatcher_; | 260 scoped_ptr<AppCacheDispatcher> appcache_dispatcher_; |
283 scoped_ptr<IndexedDBDispatcher> indexed_db_dispatcher_; | 261 scoped_ptr<IndexedDBDispatcher> indexed_db_dispatcher_; |
284 scoped_ptr<RendererWebKitClientImpl> webkit_client_; | 262 scoped_ptr<RendererWebKitClientImpl> webkit_client_; |
285 scoped_ptr<WebKit::WebStorageEventDispatcher> dom_storage_event_dispatcher_; | 263 scoped_ptr<WebKit::WebStorageEventDispatcher> dom_storage_event_dispatcher_; |
286 | 264 |
287 // Used on the renderer and IPC threads. | 265 // Used on the renderer and IPC threads. |
288 scoped_refptr<DBMessageFilter> db_message_filter_; | 266 scoped_refptr<DBMessageFilter> db_message_filter_; |
289 scoped_refptr<CookieMessageFilter> cookie_message_filter_; | |
290 | 267 |
291 // Used on multiple script execution context threads. | 268 // Used on multiple script execution context threads. |
292 scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_; | 269 scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_; |
293 | 270 |
294 // If true, then a GetPlugins call is allowed to rescan the disk. | 271 // If true, then a GetPlugins call is allowed to rescan the disk. |
295 bool plugin_refresh_allowed_; | 272 bool plugin_refresh_allowed_; |
296 | 273 |
297 // The count of RenderWidgets running through this thread. | 274 // The count of RenderWidgets running through this thread. |
298 int widget_count_; | 275 int widget_count_; |
299 | 276 |
300 // The count of hidden RenderWidgets running through this thread. | 277 // The count of hidden RenderWidgets running through this thread. |
301 int hidden_widget_count_; | 278 int hidden_widget_count_; |
302 | 279 |
303 // The current value of the idle notification timer delay. | 280 // The current value of the idle notification timer delay. |
304 double idle_notification_delay_in_s_; | 281 double idle_notification_delay_in_s_; |
305 | 282 |
306 // True if this renderer is incognito. | |
307 bool is_incognito_process_; | |
308 | |
309 bool suspend_webkit_shared_timer_; | 283 bool suspend_webkit_shared_timer_; |
310 bool notify_webkit_of_modal_loop_; | 284 bool notify_webkit_of_modal_loop_; |
311 | 285 |
312 // Timer that periodically calls IdleHandler. | 286 // Timer that periodically calls IdleHandler. |
313 base::RepeatingTimer<RenderThread> idle_timer_; | 287 base::RepeatingTimer<RenderThread> idle_timer_; |
314 | 288 |
315 // The channel from the renderer process to the GPU process. | 289 // The channel from the renderer process to the GPU process. |
316 scoped_refptr<GpuChannelHost> gpu_channel_; | 290 scoped_refptr<GpuChannelHost> gpu_channel_; |
317 | 291 |
318 // A lazily initiated thread on which file operations are run. | 292 // A lazily initiated thread on which file operations are run. |
319 scoped_ptr<base::Thread> file_thread_; | 293 scoped_ptr<base::Thread> file_thread_; |
320 | 294 |
321 // Map of registered v8 extensions. The key is the extension name. | 295 // Map of registered v8 extensions. The key is the extension name. |
322 std::set<std::string> v8_extensions_; | 296 std::set<std::string> v8_extensions_; |
323 | 297 |
324 ObserverList<RenderProcessObserver> observers_; | 298 ObserverList<RenderProcessObserver> observers_; |
325 | 299 |
326 DISALLOW_COPY_AND_ASSIGN(RenderThread); | 300 DISALLOW_COPY_AND_ASSIGN(RenderThread); |
327 }; | 301 }; |
328 | 302 |
329 #endif // CONTENT_RENDERER_RENDER_THREAD_H_ | 303 #endif // CONTENT_RENDERER_RENDER_THREAD_H_ |
OLD | NEW |