| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_FRAME_HOST_WEB_CONTENTS_SCREENSHOT_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_ENTRY_SCREENSHOT_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_FRAME_HOST_WEB_CONTENTS_SCREENSHOT_MANAGER_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_ENTRY_SCREENSHOT_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 | 12 |
| 13 class SkBitmap; | 13 class SkBitmap; |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 class NavigationControllerImpl; | 17 class NavigationControllerImpl; |
| 18 class NavigationEntryImpl; | 18 class NavigationEntryImpl; |
| 19 class RenderViewHost; | 19 class RenderViewHost; |
| 20 class ScreenshotData; | 20 class ScreenshotData; |
| 21 | 21 |
| 22 // WebContentsScreenshotManager takes care of taking image-captures for the | 22 // NavigationEntryScreenshotManager takes care of taking image-captures for the |
| 23 // current navigation entry of a NavigationControllerImpl, and managing these | 23 // current navigation entry of a NavigationControllerImpl, and managing these |
| 24 // captured images. These image-captures are used for history navigation using | 24 // captured images. These image-captures are used for history navigation using |
| 25 // overscroll gestures. | 25 // overscroll gestures. |
| 26 // TODO(nasko): Rename this to better reflect that it is used for | 26 class CONTENT_EXPORT NavigationEntryScreenshotManager { |
| 27 // navigation entries and not WebContents. | |
| 28 class CONTENT_EXPORT WebContentsScreenshotManager { | |
| 29 public: | 27 public: |
| 30 explicit WebContentsScreenshotManager(NavigationControllerImpl* controller); | 28 explicit NavigationEntryScreenshotManager( |
| 31 virtual ~WebContentsScreenshotManager(); | 29 NavigationControllerImpl* controller); |
| 30 virtual ~NavigationEntryScreenshotManager(); |
| 32 | 31 |
| 33 // Takes a screenshot of the last-committed entry of the controller. | 32 // Takes a screenshot of the last-committed entry of the controller. |
| 34 void TakeScreenshot(); | 33 void TakeScreenshot(); |
| 35 | 34 |
| 36 // Clears screenshots of all navigation entries. | 35 // Clears screenshots of all navigation entries. |
| 37 void ClearAllScreenshots(); | 36 void ClearAllScreenshots(); |
| 38 | 37 |
| 39 protected: | 38 protected: |
| 40 virtual void TakeScreenshotImpl(RenderViewHost* host, | 39 virtual void TakeScreenshotImpl(RenderViewHost* host, |
| 41 NavigationEntryImpl* entry); | 40 NavigationEntryImpl* entry); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 70 // The screenshots in the NavigationEntryImpls can accumulate and consume a | 69 // The screenshots in the NavigationEntryImpls can accumulate and consume a |
| 71 // large amount of memory. This function makes sure that the memory | 70 // large amount of memory. This function makes sure that the memory |
| 72 // consumption is within a certain limit. | 71 // consumption is within a certain limit. |
| 73 void PurgeScreenshotsIfNecessary(); | 72 void PurgeScreenshotsIfNecessary(); |
| 74 | 73 |
| 75 // The navigation controller that owns this screenshot-manager. | 74 // The navigation controller that owns this screenshot-manager. |
| 76 NavigationControllerImpl* owner_; | 75 NavigationControllerImpl* owner_; |
| 77 | 76 |
| 78 // Taking a screenshot and encoding them can be async. So use a weakptr for | 77 // 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 | 78 // the callback to make sure that the screenshot/encoding completion callback |
| 80 // does not trigger on a destroyed WebContentsScreenshotManager. | 79 // does not trigger on a destroyed NavigationEntryScreenshotManager. |
| 81 base::WeakPtrFactory<WebContentsScreenshotManager> screenshot_factory_; | 80 base::WeakPtrFactory<NavigationEntryScreenshotManager> screenshot_factory_; |
| 82 | 81 |
| 83 base::Time last_screenshot_time_; | 82 base::Time last_screenshot_time_; |
| 84 int min_screenshot_interval_ms_; | 83 int min_screenshot_interval_ms_; |
| 85 | 84 |
| 86 DISALLOW_COPY_AND_ASSIGN(WebContentsScreenshotManager); | 85 DISALLOW_COPY_AND_ASSIGN(NavigationEntryScreenshotManager); |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace content | 88 } // namespace content |
| 90 | 89 |
| 91 #endif // CONTENT_BROWSER_FRAME_HOST_WEB_CONTENTS_SCREENSHOT_MANAGER_H_ | 90 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_ENTRY_SCREENSHOT_MANAGER_H_ |
| OLD | NEW |