Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Side by Side Diff: content/renderer/render_thread_impl.h

Issue 8574012: Schedule idle handler based on CPU usage. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_IMPL_H_ 5 #ifndef CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
6 #define CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ 6 #define CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 25 matching lines...) Expand all
36 class SkBitmap; 36 class SkBitmap;
37 class VideoCaptureImplManager; 37 class VideoCaptureImplManager;
38 struct ViewMsg_New_Params; 38 struct ViewMsg_New_Params;
39 class WebDatabaseObserverImpl; 39 class WebDatabaseObserverImpl;
40 40
41 namespace WebKit { 41 namespace WebKit {
42 class WebStorageEventDispatcher; 42 class WebStorageEventDispatcher;
43 } 43 }
44 44
45 namespace base { 45 namespace base {
46 class ProcessMetrics;
46 class MessageLoopProxy; 47 class MessageLoopProxy;
47 class Thread; 48 class Thread;
48 namespace win { 49 namespace win {
49 class ScopedCOMInitializer; 50 class ScopedCOMInitializer;
50 } 51 }
51 } 52 }
52 53
53 namespace content { 54 namespace content {
54 class RenderProcessObserver; 55 class RenderProcessObserver;
55 } 56 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 content::ResourceDispatcherDelegate* delegate) OVERRIDE; 102 content::ResourceDispatcherDelegate* delegate) OVERRIDE;
102 virtual void WidgetHidden() OVERRIDE; 103 virtual void WidgetHidden() OVERRIDE;
103 virtual void WidgetRestored() OVERRIDE; 104 virtual void WidgetRestored() OVERRIDE;
104 virtual void EnsureWebKitInitialized() OVERRIDE; 105 virtual void EnsureWebKitInitialized() OVERRIDE;
105 virtual void RecordUserMetrics(const std::string& action) OVERRIDE; 106 virtual void RecordUserMetrics(const std::string& action) OVERRIDE;
106 virtual base::SharedMemoryHandle HostAllocateSharedMemoryBuffer( 107 virtual base::SharedMemoryHandle HostAllocateSharedMemoryBuffer(
107 uint32 buffer_size) OVERRIDE; 108 uint32 buffer_size) OVERRIDE;
108 virtual void RegisterExtension(v8::Extension* extension) OVERRIDE; 109 virtual void RegisterExtension(v8::Extension* extension) OVERRIDE;
109 virtual bool IsRegisteredExtension( 110 virtual bool IsRegisteredExtension(
110 const std::string& v8_extension_name) const OVERRIDE; 111 const std::string& v8_extension_name) const OVERRIDE;
111 virtual void ScheduleIdleHandler(int64 initial_delay_ms) OVERRIDE; 112 virtual void ResetIdleTimer() OVERRIDE;
112 virtual void IdleHandler() OVERRIDE;
113 virtual int64 GetIdleNotificationDelayInMs() const OVERRIDE;
114 virtual void SetIdleNotificationDelayInMs(
115 int64 idle_notification_delay_in_ms) OVERRIDE;
116 #if defined(OS_WIN) 113 #if defined(OS_WIN)
117 virtual void PreCacheFont(const LOGFONT& log_font) OVERRIDE; 114 virtual void PreCacheFont(const LOGFONT& log_font) OVERRIDE;
118 virtual void ReleaseCachedFonts() OVERRIDE; 115 virtual void ReleaseCachedFonts() OVERRIDE;
119 #endif 116 #endif
120 117
121 // These methods modify how the next message is sent. Normally, when sending 118 // These methods modify how the next message is sent. Normally, when sending
122 // a synchronous message that runs a nested message loop, we need to suspend 119 // a synchronous message that runs a nested message loop, we need to suspend
123 // callbacks into WebKit. This involves disabling timers and deferring 120 // callbacks into WebKit. This involves disabling timers and deferring
124 // resource loads. However, there are exceptions when we need to customize 121 // resource loads. However, there are exceptions when we need to customize
125 // the behavior. 122 // the behavior.
126 void DoNotSuspendWebKitSharedTimer(); 123 void DoNotSuspendWebKitSharedTimer();
127 void DoNotNotifyWebKitOfModalLoop(); 124 void DoNotNotifyWebKitOfModalLoop();
128 125
126 void IdleHandler();
127
129 // Will be NULL if threaded compositing has not been enabled. 128 // Will be NULL if threaded compositing has not been enabled.
130 CompositorThread* compositor_thread() const { 129 CompositorThread* compositor_thread() const {
131 return compositor_thread_.get(); 130 return compositor_thread_.get();
132 } 131 }
133 132
134 AppCacheDispatcher* appcache_dispatcher() const { 133 AppCacheDispatcher* appcache_dispatcher() const {
135 return appcache_dispatcher_.get(); 134 return appcache_dispatcher_.get();
136 } 135 }
137 136
138 IndexedDBDispatcher* indexed_db_dispatcher() const { 137 IndexedDBDispatcher* indexed_db_dispatcher() const {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void OnDOMStorageEvent(const DOMStorageMsg_Event_Params& params); 176 void OnDOMStorageEvent(const DOMStorageMsg_Event_Params& params);
178 void OnSetNextPageID(int32 next_page_id); 177 void OnSetNextPageID(int32 next_page_id);
179 void OnSetCSSColors(const std::vector<CSSColors::CSSColorMapping>& colors); 178 void OnSetCSSColors(const std::vector<CSSColors::CSSColorMapping>& colors);
180 void OnCreateNewView(const ViewMsg_New_Params& params); 179 void OnCreateNewView(const ViewMsg_New_Params& params);
181 void OnTransferBitmap(const SkBitmap& bitmap, int resource_id); 180 void OnTransferBitmap(const SkBitmap& bitmap, int resource_id);
182 void OnPurgePluginListCache(bool reload_pages); 181 void OnPurgePluginListCache(bool reload_pages);
183 void OnNetworkStateChanged(bool online); 182 void OnNetworkStateChanged(bool online);
184 void OnGetAccessibilityTree(); 183 void OnGetAccessibilityTree();
185 void OnTempCrashWithData(const GURL& data); 184 void OnTempCrashWithData(const GURL& data);
186 185
186 void ScheduleIdleHandler(int64 delay_ms);
187
187 // These objects live solely on the render thread. 188 // These objects live solely on the render thread.
188 scoped_ptr<ScopedRunnableMethodFactory<RenderThreadImpl> > task_factory_; 189 scoped_ptr<ScopedRunnableMethodFactory<RenderThreadImpl> > task_factory_;
189 scoped_ptr<AppCacheDispatcher> appcache_dispatcher_; 190 scoped_ptr<AppCacheDispatcher> appcache_dispatcher_;
190 scoped_ptr<IndexedDBDispatcher> indexed_db_dispatcher_; 191 scoped_ptr<IndexedDBDispatcher> indexed_db_dispatcher_;
191 scoped_ptr<RendererWebKitPlatformSupportImpl> webkit_platform_support_; 192 scoped_ptr<RendererWebKitPlatformSupportImpl> webkit_platform_support_;
192 scoped_ptr<WebKit::WebStorageEventDispatcher> dom_storage_event_dispatcher_; 193 scoped_ptr<WebKit::WebStorageEventDispatcher> dom_storage_event_dispatcher_;
193 194
194 // Used on the renderer and IPC threads. 195 // Used on the renderer and IPC threads.
195 scoped_refptr<DBMessageFilter> db_message_filter_; 196 scoped_refptr<DBMessageFilter> db_message_filter_;
196 scoped_refptr<AudioInputMessageFilter> audio_input_message_filter_; 197 scoped_refptr<AudioInputMessageFilter> audio_input_message_filter_;
(...skipping 12 matching lines...) Expand all
209 // If true, then a GetPlugins call is allowed to rescan the disk. 210 // If true, then a GetPlugins call is allowed to rescan the disk.
210 bool plugin_refresh_allowed_; 211 bool plugin_refresh_allowed_;
211 212
212 // The count of RenderWidgets running through this thread. 213 // The count of RenderWidgets running through this thread.
213 int widget_count_; 214 int widget_count_;
214 215
215 // The count of hidden RenderWidgets running through this thread. 216 // The count of hidden RenderWidgets running through this thread.
216 int hidden_widget_count_; 217 int hidden_widget_count_;
217 218
218 // The current value of the idle notification timer delay. 219 // The current value of the idle notification timer delay.
219 int64 idle_notification_delay_in_ms_; 220 int64 idle_delay_ms_;
221
222 // Timer that checks CPU usage and calls IdleHandler.
223 base::OneShotTimer<RenderThreadImpl> idle_timer_;
224
225 scoped_ptr<base::ProcessMetrics> process_metrics_;
220 226
221 bool suspend_webkit_shared_timer_; 227 bool suspend_webkit_shared_timer_;
222 bool notify_webkit_of_modal_loop_; 228 bool notify_webkit_of_modal_loop_;
223 229
224 // Timer that periodically calls IdleHandler.
225 base::RepeatingTimer<RenderThreadImpl> idle_timer_;
226
227 // The channel from the renderer process to the GPU process. 230 // The channel from the renderer process to the GPU process.
228 scoped_refptr<GpuChannelHost> gpu_channel_; 231 scoped_refptr<GpuChannelHost> gpu_channel_;
229 232
230 // A lazily initiated thread on which file operations are run. 233 // A lazily initiated thread on which file operations are run.
231 scoped_ptr<base::Thread> file_thread_; 234 scoped_ptr<base::Thread> file_thread_;
232 235
233 // Map of registered v8 extensions. The key is the extension name. 236 // Map of registered v8 extensions. The key is the extension name.
234 std::set<std::string> v8_extensions_; 237 std::set<std::string> v8_extensions_;
235 238
236 scoped_ptr<CompositorThread> compositor_thread_; 239 scoped_ptr<CompositorThread> compositor_thread_;
237 240
238 ObserverList<content::RenderProcessObserver> observers_; 241 ObserverList<content::RenderProcessObserver> observers_;
239 242
240 DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); 243 DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl);
241 }; 244 };
242 245
243 #endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ 246 #endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698