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

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: Added comments Created 10 years 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 80c609b066ac201307d7505805ee2be3f81f17bd..eeee1e7901d603ced01e5b06ec8e2a696500fde5 100644
--- a/chrome/browser/tab_contents/thumbnail_generator.cc
+++ b/chrome/browser/tab_contents/thumbnail_generator.cc
@@ -172,6 +172,46 @@ void ThumbnailGenerator::StartThumbnailing() {
}
}
+void ThumbnailGenerator::MonitorRenderer(
+ RenderWidgetHost* renderer,
brettw 2011/01/03 19:48:30 This should fit on the previous line, I think. (Th
DaveMoore 2011/01/07 19:04:05 Done.
+ 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) {
+ 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 +396,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 +411,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