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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.h

Issue 11066032: Browser Plugin: Update Guest WebContents Visibility on BrowserPlugin Visiblity Change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 8 years, 2 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // A BrowserPluginGuest represents the browser side of browser <--> renderer 5 // A BrowserPluginGuest represents the browser side of browser <--> renderer
6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of 6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of
7 // browser <--> guest renderer communication. The 'guest' renderer is a 7 // browser <--> guest renderer communication. The 'guest' renderer is a
8 // <browser> tag. 8 // <browser> tag.
9 // 9 //
10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a 10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 void set_guest_hang_timeout_for_testing(const base::TimeDelta& timeout) { 78 void set_guest_hang_timeout_for_testing(const base::TimeDelta& timeout) {
79 guest_hang_timeout_ = timeout; 79 guest_hang_timeout_ = timeout;
80 } 80 }
81 81
82 void set_embedder_render_process_host( 82 void set_embedder_render_process_host(
83 RenderProcessHost* render_process_host) { 83 RenderProcessHost* render_process_host) {
84 embedder_render_process_host_ = render_process_host; 84 embedder_render_process_host_ = render_process_host;
85 } 85 }
86 86
87 bool visible() const { return visible_; }
88
87 // NotificationObserver implementation. 89 // NotificationObserver implementation.
88 virtual void Observe(int type, 90 virtual void Observe(int type,
89 const NotificationSource& source, 91 const NotificationSource& source,
90 const NotificationDetails& details) OVERRIDE; 92 const NotificationDetails& details) OVERRIDE;
91 93
92 // WebContentsObserver implementation. 94 // WebContentsObserver implementation.
93 virtual void DidStartProvisionalLoadForFrame( 95 virtual void DidStartProvisionalLoadForFrame(
94 int64 frame_id, 96 int64 frame_id,
95 bool is_main_frame, 97 bool is_main_frame,
96 const GURL& validated_url, 98 const GURL& validated_url,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 const gfx::Rect& initial_pos); 136 const gfx::Rect& initial_pos);
135 void SetCursor(const WebCursor& cursor); 137 void SetCursor(const WebCursor& cursor);
136 // Handles input event acks so they are sent to browser plugin host (via 138 // Handles input event acks so they are sent to browser plugin host (via
137 // embedder) instead of default view/widget host. 139 // embedder) instead of default view/widget host.
138 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled); 140 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled);
139 141
140 // The guest needs to notify the plugin in the embedder to start (or stop) 142 // The guest needs to notify the plugin in the embedder to start (or stop)
141 // accepting touch events. 143 // accepting touch events.
142 void SetIsAcceptingTouchEvents(bool accept); 144 void SetIsAcceptingTouchEvents(bool accept);
143 145
146 // The guest WebContents is visible if both its embedder is visible and
147 // the browser plugin element is visible. If either one is not then the
148 // WebContents is marked as hidden. A hidden WebContents will consume
149 // fewer GPU and CPU resources.
150 //
151 // When the every WebContents in a RenderProcessHost is hidden, it will lower
152 // the priority of the process (see RenderProcessHostImpl::WidgetHidden).
153 //
154 // It will also send a message to the guest renderer process to cleanup
155 // resources such as dropping back buffers and adjusting memory limits (if in
156 // compositing mode, see CCLayerTreeHost::setVisible).
157 //
158 // Additionally it will slow down Javascript execution and garbage collection.
159 // See RenderThreadImpl::IdleHandler (executed when hidden) and
160 // RenderThreadImpl::IdleHandlerInForegroundTab (executed when visible).
161 void SetVisibility(bool embedder_visible, bool visible);
162
144 // Exposes the protected web_contents() from WebContentsObserver. 163 // Exposes the protected web_contents() from WebContentsObserver.
145 WebContents* GetWebContents(); 164 WebContents* GetWebContents();
146 165
147 // Kill the guest process. 166 // Kill the guest process.
148 void Terminate(); 167 void Terminate();
149 168
150 // Overridden in tests. 169 // Overridden in tests.
151 virtual bool ViewTakeFocus(bool reverse); 170 virtual bool ViewTakeFocus(bool reverse);
152 // If possible, navigate the guest to |relative_index| entries away from the 171 // If possible, navigate the guest to |relative_index| entries away from the
153 // current navigation entry. 172 // current navigation entry.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 size_t damage_buffer_size_; 226 size_t damage_buffer_size_;
208 #endif 227 #endif
209 gfx::Size damage_view_size_; 228 gfx::Size damage_view_size_;
210 float damage_buffer_scale_factor_; 229 float damage_buffer_scale_factor_;
211 scoped_ptr<IPC::Message> pending_input_event_reply_; 230 scoped_ptr<IPC::Message> pending_input_event_reply_;
212 gfx::Rect guest_rect_; 231 gfx::Rect guest_rect_;
213 WebCursor cursor_; 232 WebCursor cursor_;
214 IDMap<RenderViewHost> pending_updates_; 233 IDMap<RenderViewHost> pending_updates_;
215 int pending_update_counter_; 234 int pending_update_counter_;
216 base::TimeDelta guest_hang_timeout_; 235 base::TimeDelta guest_hang_timeout_;
236 bool visible_;
217 237
218 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 238 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
219 }; 239 };
220 240
221 } // namespace content 241 } // namespace content
222 242
223 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 243 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698