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

Side by Side Diff: content/browser/frame_host/web_contents_screenshot_manager.h

Issue 58343006: Rename WebContentsScreenshotManager to NavigationEntryScreenshotManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove TODO. Created 7 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2013 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 CONTENT_BROWSER_FRAME_HOST_WEB_CONTENTS_SCREENSHOT_MANAGER_H_
6 #define CONTENT_BROWSER_FRAME_HOST_WEB_CONTENTS_SCREENSHOT_MANAGER_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h"
11 #include "content/common/content_export.h"
12
13 class SkBitmap;
14
15 namespace content {
16
17 class NavigationControllerImpl;
18 class NavigationEntryImpl;
19 class RenderViewHost;
20 class ScreenshotData;
21
22 // WebContentsScreenshotManager takes care of taking image-captures for the
23 // current navigation entry of a NavigationControllerImpl, and managing these
24 // captured images. These image-captures are used for history navigation using
25 // overscroll gestures.
26 // TODO(nasko): Rename this to better reflect that it is used for
27 // navigation entries and not WebContents.
28 class CONTENT_EXPORT WebContentsScreenshotManager {
29 public:
30 explicit WebContentsScreenshotManager(NavigationControllerImpl* controller);
31 virtual ~WebContentsScreenshotManager();
32
33 // Takes a screenshot of the last-committed entry of the controller.
34 void TakeScreenshot();
35
36 // Clears screenshots of all navigation entries.
37 void ClearAllScreenshots();
38
39 protected:
40 virtual void TakeScreenshotImpl(RenderViewHost* host,
41 NavigationEntryImpl* entry);
42
43 // Called after a screenshot has been set on an NavigationEntryImpl.
44 // Overridden in tests to get notified of when a screenshot is set.
45 virtual void OnScreenshotSet(NavigationEntryImpl* entry);
46
47 NavigationControllerImpl* owner() { return owner_; }
48
49 void SetMinScreenshotIntervalMS(int interval_ms);
50
51 // The callback invoked when taking the screenshot of the page is complete.
52 // This sets the screenshot on the navigation entry.
53 void OnScreenshotTaken(int unique_id,
54 bool success,
55 const SkBitmap& bitmap);
56
57 // Returns the number of entries with screenshots.
58 int GetScreenshotCount() const;
59
60 private:
61 // This is called when the screenshot data has beene encoded to PNG in a
62 // worker thread.
63 void OnScreenshotEncodeComplete(int unique_id,
64 scoped_refptr<ScreenshotData> data);
65
66 // Removes the screenshot for the entry, returning true if the entry had a
67 // screenshot.
68 bool ClearScreenshot(NavigationEntryImpl* entry);
69
70 // The screenshots in the NavigationEntryImpls can accumulate and consume a
71 // large amount of memory. This function makes sure that the memory
72 // consumption is within a certain limit.
73 void PurgeScreenshotsIfNecessary();
74
75 // The navigation controller that owns this screenshot-manager.
76 NavigationControllerImpl* owner_;
77
78 // Taking a screenshot and encoding them can be async. So use a weakptr for
79 // the callback to make sure that the screenshot/encoding completion callback
80 // does not trigger on a destroyed WebContentsScreenshotManager.
81 base::WeakPtrFactory<WebContentsScreenshotManager> screenshot_factory_;
82
83 base::Time last_screenshot_time_;
84 int min_screenshot_interval_ms_;
85
86 DISALLOW_COPY_AND_ASSIGN(WebContentsScreenshotManager);
87 };
88
89 } // namespace content
90
91 #endif // CONTENT_BROWSER_FRAME_HOST_WEB_CONTENTS_SCREENSHOT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698