summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser_process.h5
-rw-r--r--chrome/browser/browser_process_impl.h22
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc10
-rwxr-xr-xchrome/browser/tab_contents/thumbnail_generator.cc32
-rwxr-xr-xchrome/browser/tab_contents/thumbnail_generator.h5
-rwxr-xr-xchrome/browser/tab_contents/thumbnail_generator_unittest.cc1
-rwxr-xr-xchrome/common/transport_dib_mac.cc1
-rw-r--r--chrome/test/testing_browser_process.h4
8 files changed, 55 insertions, 25 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index 86cee4e..656b1ff 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -26,8 +26,9 @@ class PrefService;
class ProfileManager;
class DebuggerWrapper;
class ResourceDispatcherHost;
-class WebAppInstallerService;
class SuspendController;
+class ThumbnailGenerator;
+class WebAppInstallerService;
namespace base {
class Thread;
@@ -109,6 +110,8 @@ class BrowserProcess {
virtual IconManager* icon_manager() = 0;
+ virtual ThumbnailGenerator* GetThumbnailGenerator() = 0;
+
virtual void InitBrokerServices(sandbox::BrokerServices*) = 0;
virtual AutomationProviderList* InitAutomationProviderList() = 0;
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 27ce62acd..671f6b7 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -7,8 +7,8 @@
// if we tried to create a service, and not try creating it over and over if
// the creation failed.
-#ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H__
-#define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H__
+#ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
+#define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
#include <string>
@@ -130,6 +130,10 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
return icon_manager_.get();
}
+ virtual ThumbnailGenerator* GetThumbnailGenerator() {
+ return &thumbnail_generator_;
+ }
+
virtual AutomationProviderList* InitAutomationProviderList() {
DCHECK(CalledOnValidThread());
if (automation_provider_list_.get() == NULL) {
@@ -271,20 +275,14 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
bool checked_for_new_frames_;
bool using_new_frames_;
-#if defined(LINUX2)
- // TODO(brettw) enable this for all builds when we have a need for it. This
- // component has some overhead, so we don't want to have it running without
- // any consumers. Since it integrates by listening to notifications, it's
- // sufficient to just not instatiate it to make it disabled.
-
- // This service just sits around and makes thumanails for tabs.
+ // This service just sits around and makes thumanails for tabs. It does
+ // nothing in the cosntructor so we don't have to worry about lazy init.
ThumbnailGenerator thumbnail_generator_;
-#endif
// An event that notifies when we are shutting-down.
scoped_ptr<base::WaitableEvent> shutdown_event_;
- DISALLOW_EVIL_CONSTRUCTORS(BrowserProcessImpl);
+ DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
};
-#endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H__
+#endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 2d6d997..bd4e803 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -38,6 +38,7 @@
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
+#include "chrome/browser/tab_contents/thumbnail_generator.h"
#include "chrome/browser/thumbnail_store.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/search_engines/template_url_model.h"
@@ -244,6 +245,15 @@ TabContents::TabContents(Profile* profile,
pending_install_.page_id = 0;
pending_install_.callback_functor = NULL;
+#if defined(LINUX2)
+ // Make sure the thumbnailer is started before starting the render manager.
+ // The thumbnailer will want to listen for RVH creations, one of which will
+ // happen in RVHManager::Init.
+ ThumbnailGenerator* generator = g_browser_process->GetThumbnailGenerator();
+ if (generator)
+ generator->StartThumbnailing();
+#endif
+
render_manager_.Init(profile, site_instance, routing_id, modal_dialog_event);
view_->CreateView();
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
diff --git a/chrome/browser/tab_contents/thumbnail_generator.h b/chrome/browser/tab_contents/thumbnail_generator.h
index 76afb3c..d3d3d15 100755
--- a/chrome/browser/tab_contents/thumbnail_generator.h
+++ b/chrome/browser/tab_contents/thumbnail_generator.h
@@ -19,9 +19,14 @@ class SkBitmap;
class ThumbnailGenerator : public RenderWidgetHostPaintingObserver,
public NotificationObserver {
public:
+ // This class will do nothing until you call StartThumbnailing.
ThumbnailGenerator();
~ThumbnailGenerator();
+ // Ensures that we're properly hooked in to generated thumbnails. This can
+ // be called repeatedly and with wild abandon to no ill effect.
+ void StartThumbnailing();
+
SkBitmap GetThumbnailForRenderer(RenderWidgetHost* renderer) const;
#ifdef UNIT_TEST
diff --git a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc
index 53a17fc..591fdd0 100755
--- a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc
+++ b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc
@@ -47,6 +47,7 @@ class ThumbnailGeneratorTest : public testing::Test {
1));
// We don't want to be sensitive to timing.
+ generator_.StartThumbnailing();
generator_.set_no_timeout(true);
}
diff --git a/chrome/common/transport_dib_mac.cc b/chrome/common/transport_dib_mac.cc
index 6eb6c11..9ce5e4f 100755
--- a/chrome/common/transport_dib_mac.cc
+++ b/chrome/common/transport_dib_mac.cc
@@ -56,7 +56,6 @@ TransportDIB* TransportDIB::Map(TransportDIB::Handle handle) {
skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
return new skia::PlatformCanvas(w, h, true,
reinterpret_cast<uint8_t*>(memory()));
-
}
void* TransportDIB::memory() const {
diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h
index c42eb61..7e97e73 100644
--- a/chrome/test/testing_browser_process.h
+++ b/chrome/test/testing_browser_process.h
@@ -74,6 +74,10 @@ class TestingBrowserProcess : public BrowserProcess {
return NULL;
}
+ virtual ThumbnailGenerator* GetThumbnailGenerator() {
+ return NULL;
+ }
+
virtual sandbox::BrokerServices* broker_services() {
return NULL;
}