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

Unified Diff: chrome/browser/tab_contents/thumbnail_generator.cc

Issue 6010004: Refactor RenderWidgetHost::set_paint_observer() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove helper classes per review Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/thumbnail_generator.cc
diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc
index 1844f67a700c9bd7599a3d9cd7334ba75b71ddfa..a26bca08c39766143ca231983fa211eaaa5bd4ae 100644
--- a/chrome/browser/tab_contents/thumbnail_generator.cc
+++ b/chrome/browser/tab_contents/thumbnail_generator.cc
@@ -172,6 +172,45 @@ void ThumbnailGenerator::StartThumbnailing() {
}
}
+void ThumbnailGenerator::MonitorRenderer(RenderWidgetHost* renderer,
+ bool monitor) {
+ Source<RenderWidgetHost> renderer_source = Source<RenderWidgetHost>(renderer);
+ bool currently_monitored =
+ registrar_.IsRegistered(
+ this,
+ NotificationType::RENDER_WIDGET_HOST_WILL_DESTROY_BACKING_STORE,
+ renderer_source);
+ if (monitor |= currently_monitored) {
Nico 2011/01/18 00:39:52 Is this supposed to be != (it's currently |=)? Th
+ if (monitor) {
+ registrar_.Add(
+ this,
+ NotificationType::RENDER_WIDGET_HOST_WILL_DESTROY_BACKING_STORE,
+ renderer_source);
+ registrar_.Add(
+ this,
+ NotificationType::RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE,
+ renderer_source);
+ registrar_.Add(
+ this,
+ NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK,
+ renderer_source);
+ } else {
+ registrar_.Remove(
+ this,
+ NotificationType::RENDER_WIDGET_HOST_WILL_DESTROY_BACKING_STORE,
+ renderer_source);
+ registrar_.Remove(
+ this,
+ NotificationType::RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE,
+ renderer_source);
+ registrar_.Remove(
+ this,
+ NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK,
+ renderer_source);
+ }
+ }
+}
+
void ThumbnailGenerator::AskForSnapshot(RenderWidgetHost* renderer,
bool prefer_backing_store,
ThumbnailReadyCallback* callback,
@@ -356,7 +395,7 @@ void ThumbnailGenerator::Observe(NotificationType type,
case NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB: {
// Install our observer for all new RVHs.
RenderViewHost* renderer = Details<RenderViewHost>(details).ptr();
- renderer->set_painting_observer(this);
+ MonitorRenderer(renderer, true);
break;
}
@@ -371,6 +410,26 @@ void ThumbnailGenerator::Observe(NotificationType type,
WidgetDestroyed(Source<RenderWidgetHost>(source).ptr());
break;
+ case NotificationType::RENDER_WIDGET_HOST_WILL_DESTROY_BACKING_STORE:
+ WidgetWillDestroyBackingStore(
+ Source<RenderWidgetHost>(source).ptr(),
+ Details<BackingStore>(details).ptr());
+ break;
+
+ case NotificationType::RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE:
+ WidgetDidUpdateBackingStore(Source<RenderWidgetHost>(source).ptr());
+ break;
+
+ case NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK: {
+ RenderWidgetHost::PaintAtSizeAckDetails* size_ack_details =
+ Details<RenderWidgetHost::PaintAtSizeAckDetails>(details).ptr();
+ WidgetDidReceivePaintAtSizeAck(
+ Source<RenderWidgetHost>(source).ptr(),
+ size_ack_details->tag,
+ size_ack_details->size);
+ break;
+ }
+
case NotificationType::TAB_CONTENTS_DISCONNECTED:
TabContentsDisconnected(Source<TabContents>(source).ptr());
break;

Powered by Google App Engine
This is Rietveld 408576698