summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents/thumbnail_generator.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 00:35:02 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 00:35:02 +0000
commit58dca55cff5214cc413bd9acc0a78bdd3c14e0a7 (patch)
treed59b91ed98a1d19cda81480b97090070c505821a /chrome/browser/tab_contents/thumbnail_generator.cc
parenta7c9a1aa1e81d8fb3634ca9f88d25e142b1d1d43 (diff)
downloadchromium_src-58dca55cff5214cc413bd9acc0a78bdd3c14e0a7.zip
chromium_src-58dca55cff5214cc413bd9acc0a78bdd3c14e0a7.tar.gz
chromium_src-58dca55cff5214cc413bd9acc0a78bdd3c14e0a7.tar.bz2
Fix a crash when the ThumbnailGenerator.
This happens when the ThumbnailGenerator is initialized because the NotificationService doesn't exist yet. This patch adds a function that TabContentscalls to make sure it is registered to avoid this problem. Review URL: http://codereview.chromium.org/126239 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents/thumbnail_generator.cc')
-rwxr-xr-xchrome/browser/tab_contents/thumbnail_generator.cc32
1 files changed, 21 insertions, 11 deletions
diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc
index 4654b14..681c0c8 100755
--- a/chrome/browser/tab_contents/thumbnail_generator.cc
+++ b/chrome/browser/tab_contents/thumbnail_generator.cc
@@ -135,22 +135,32 @@ SkBitmap GetThumbnailForBackingStore(BackingStore* backing_store) {
ThumbnailGenerator::ThumbnailGenerator()
: no_timeout_(false) {
- // Even though we deal in RenderWidgetHosts, we only care about its subclass,
- // RenderViewHost when it is in a tab. We don't make thumbnails for
- // RenderViewHosts that aren't in tabs, or RenderWidgetHosts that aren't
- // views like select popups.
- registrar_.Add(this, NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB,
- NotificationService::AllSources());
-
- registrar_.Add(this, NotificationType::RENDER_WIDGET_VISIBILITY_CHANGED,
- NotificationService::AllSources());
- registrar_.Add(this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
- NotificationService::AllSources());
+ // The BrowserProcessImpl creates this non-lazily. If you add nontrivial
+ // stuff here, be sure to convert it to being lazily created.
+ //
+ // We don't register for notifications here since BrowserProcessImpl creates
+ // us before the NotificationService is.
}
ThumbnailGenerator::~ThumbnailGenerator() {
}
+void ThumbnailGenerator::StartThumbnailing() {
+ if (registrar_.IsEmpty()) {
+ // Even though we deal in RenderWidgetHosts, we only care about its
+ // subclass, RenderViewHost when it is in a tab. We don't make thumbnails
+ // for RenderViewHosts that aren't in tabs, or RenderWidgetHosts that
+ // aren't views like select popups.
+ registrar_.Add(this, NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB,
+ NotificationService::AllSources());
+
+ registrar_.Add(this, NotificationType::RENDER_WIDGET_VISIBILITY_CHANGED,
+ NotificationService::AllSources());
+ registrar_.Add(this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
+ NotificationService::AllSources());
+ }
+}
+
SkBitmap ThumbnailGenerator::GetThumbnailForRenderer(
RenderWidgetHost* renderer) const {
// Return a cached one if we have it and it's still valid. This will only be