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

Side by Side Diff: chrome/browser/tab_contents/thumbnail_generator.h

Issue 118420: Adds kind-of-live thumbnail generation for a potential tab switcher. This... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_TAB_CONTENTS_THUMBNAIL_GENERATOR_H_
6 #define CHROME_BROWSER_TAB_CONTENTS_THUMBNAIL_GENERATOR_H_
7
8 #include "base/basictypes.h"
9 #include "base/timer.h"
10 #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h"
11 #include "chrome/common/notification_observer.h"
12 #include "chrome/common/notification_registrar.h"
13
14 class RenderWidgetHost;
15 class SkBitmap;
16
17 // This class MUST be destroyed after the RenderWidgetHosts, since it installs
18 // a painting observer that is not removed.
19 class ThumbnailGenerator : public RenderWidgetHostPaintingObserver,
20 public NotificationObserver {
21 public:
22 ThumbnailGenerator();
23 ~ThumbnailGenerator();
24
25 SkBitmap GetThumbnailForRenderer(RenderWidgetHost* renderer) const;
26
27 #ifdef UNIT_TEST
28 // When true, the class will not use a timeout to do the expiration. This
29 // will cause expiration to happen on the next run of the message loop.
30 // Unit tests case use this to test expiration by choosing when the message
31 // loop runs.
32 void set_no_timeout(bool no_timeout) { no_timeout_ = no_timeout; }
33 #endif
34
35 private:
36 // RenderWidgetHostPaintingObserver implementation.
37 virtual void WidgetWillDestroyBackingStore(RenderWidgetHost* widget,
38 BackingStore* backing_store);
39 virtual void WidgetDidUpdateBackingStore(RenderWidgetHost* widget);
40
41 // NotificationObserver interface.
42 virtual void Observe(NotificationType type,
43 const NotificationSource& source,
44 const NotificationDetails& details);
45
46 // Indicates that the given widget has changed is visibility.
47 void WidgetShown(RenderWidgetHost* widget);
48 void WidgetHidden(RenderWidgetHost* widget);
49
50 // Called when the given widget is destroyed.
51 void WidgetDestroyed(RenderWidgetHost* widget);
52
53 // Timer function called on a delay after a tab has been shown. It will
54 // invalidate the thumbnail for hosts with expired thumbnails in shown_hosts_.
55 void ShownDelayHandler();
56
57 // Removes the given host from the shown_hosts_ list, if it is there.
58 void EraseHostFromShownList(RenderWidgetHost* host);
59
60 NotificationRegistrar registrar_;
61
62 base::OneShotTimer<ThumbnailGenerator> timer_;
63
64 // A list of all RWHs that have been shown and need to have their thumbnail
65 // expired at some time in the future with the "slop" time has elapsed. This
66 // list will normally have 0 or 1 items in it.
67 std::vector<RenderWidgetHost*> shown_hosts_;
68
69 // See the setter above.
70 bool no_timeout_;
71
72 DISALLOW_COPY_AND_ASSIGN(ThumbnailGenerator);
73 };
74
75 #endif // CHROME_BROWSER_TAB_CONTENTS_THUMBNAIL_GENERATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_host_manager.cc ('k') | chrome/browser/tab_contents/thumbnail_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698