diff options
author | avi <avi@chromium.org> | 2015-07-27 11:25:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-27 18:26:17 +0000 |
commit | 67081d0ae8833a0f36203f2437b0abdcc4c5e197 (patch) | |
tree | 1a7d69033f39e199116618eb2a2bf7ad82b3db31 | |
parent | 324ef06639ffc5e5c6f43e079a03341a37b75b88 (diff) | |
download | chromium_src-67081d0ae8833a0f36203f2437b0abdcc4c5e197.zip chromium_src-67081d0ae8833a0f36203f2437b0abdcc4c5e197.tar.gz chromium_src-67081d0ae8833a0f36203f2437b0abdcc4c5e197.tar.bz2 |
Clean up around NavigationEntryScreenshotManager a bit.
BUG=none
TEST=none
Review URL: https://codereview.chromium.org/1254993003
Cr-Commit-Position: refs/heads/master@{#340508}
5 files changed, 14 insertions, 32 deletions
diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc index df3413c..59a07a2 100644 --- a/content/browser/frame_host/navigation_controller_impl.cc +++ b/content/browser/frame_host/navigation_controller_impl.cc @@ -529,9 +529,11 @@ void NavigationControllerImpl::TakeScreenshot() { } void NavigationControllerImpl::SetScreenshotManager( - NavigationEntryScreenshotManager* manager) { - screenshot_manager_.reset(manager ? manager : - new NavigationEntryScreenshotManager(this)); + scoped_ptr<NavigationEntryScreenshotManager> manager) { + if (manager.get()) + screenshot_manager_ = manager.Pass(); + else + screenshot_manager_.reset(new NavigationEntryScreenshotManager(this)); } bool NavigationControllerImpl::CanGoBack() const { diff --git a/content/browser/frame_host/navigation_controller_impl.h b/content/browser/frame_host/navigation_controller_impl.h index e867d7f..a5136d9 100644 --- a/content/browser/frame_host/navigation_controller_impl.h +++ b/content/browser/frame_host/navigation_controller_impl.h @@ -198,12 +198,10 @@ class CONTENT_EXPORT NavigationControllerImpl // Takes a screenshot of the page at the current state. void TakeScreenshot(); - // Sets the screenshot manager for this NavigationControllerImpl. The - // controller takes ownership of the screenshot manager and destroys it when - // a new screenshot-manager is set, or when the controller is destroyed. - // Setting a NULL manager recreates the default screenshot manager and uses - // that. - void SetScreenshotManager(NavigationEntryScreenshotManager* manager); + // Sets the screenshot manager for this NavigationControllerImpl. Setting a + // NULL manager recreates the default screenshot manager and uses that. + void SetScreenshotManager( + scoped_ptr<NavigationEntryScreenshotManager> manager); // Discards only the pending entry. |was_failure| should be set if the pending // entry is being discarded because it failed to load. diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc index 7c54aad..5989bb4 100644 --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc @@ -4688,7 +4688,7 @@ TEST_F(NavigationControllerTest, MAYBE_PurgeScreenshot) { MockScreenshotManager* screenshot_manager = new MockScreenshotManager(&controller); - controller.SetScreenshotManager(screenshot_manager); + controller.SetScreenshotManager(make_scoped_ptr(screenshot_manager)); for (int i = 0; i < controller.GetEntryCount(); ++i) { entry = controller.GetEntryAtIndex(i); screenshot_manager->TakeScreenshotFor(entry); diff --git a/content/browser/frame_host/navigation_entry_screenshot_manager.cc b/content/browser/frame_host/navigation_entry_screenshot_manager.cc index 121898b..8ad5080 100644 --- a/content/browser/frame_host/navigation_entry_screenshot_manager.cc +++ b/content/browser/frame_host/navigation_entry_screenshot_manager.cc @@ -85,8 +85,7 @@ void NavigationEntryScreenshotManager::TakeScreenshot() { if (!owner_->delegate()->CanOverscrollContent()) return; - RenderViewHost* render_view_host = - owner_->delegate()->GetRenderViewHost(); + RenderViewHost* render_view_host = owner_->delegate()->GetRenderViewHost(); content::RenderWidgetHostView* view = render_view_host->GetView(); if (!view) return; @@ -137,16 +136,7 @@ void NavigationEntryScreenshotManager::OnScreenshotTaken( int unique_id, const SkBitmap& bitmap, ReadbackResponse response) { - NavigationEntryImpl* entry = NULL; - int entry_count = owner_->GetEntryCount(); - for (int i = 0; i < entry_count; ++i) { - NavigationEntryImpl* iter = owner_->GetEntryAtIndex(i); - if (iter->GetUniqueID() == unique_id) { - entry = iter; - break; - } - } - + NavigationEntryImpl* entry = owner_->GetEntryWithUniqueID(unique_id); if (!entry) { LOG(ERROR) << "Invalid entry with unique id: " << unique_id; return; @@ -181,15 +171,7 @@ int NavigationEntryScreenshotManager::GetScreenshotCount() const { void NavigationEntryScreenshotManager::OnScreenshotEncodeComplete( int unique_id, scoped_refptr<ScreenshotData> screenshot) { - NavigationEntryImpl* entry = NULL; - int entry_count = owner_->GetEntryCount(); - for (int i = 0; i < entry_count; ++i) { - NavigationEntryImpl* iter = owner_->GetEntryAtIndex(i); - if (iter->GetUniqueID() == unique_id) { - entry = iter; - break; - } - } + NavigationEntryImpl* entry = owner_->GetEntryWithUniqueID(unique_id); if (!entry) return; entry->SetScreenshotPNGData(screenshot->data()); diff --git a/content/browser/web_contents/web_contents_view_aura_browsertest.cc b/content/browser/web_contents/web_contents_view_aura_browsertest.cc index e8e1678..fbaa6f4 100644 --- a/content/browser/web_contents/web_contents_view_aura_browsertest.cc +++ b/content/browser/web_contents/web_contents_view_aura_browsertest.cc @@ -258,7 +258,7 @@ class WebContentsViewAuraTest : public ContentBrowserTest { NavigationControllerImpl* controller = &web_contents->GetController(); screenshot_manager_ = new ScreenshotTracker(controller); - controller->SetScreenshotManager(screenshot_manager_); + controller->SetScreenshotManager(make_scoped_ptr(screenshot_manager_)); frame_watcher_ = new FrameWatcher(); GetRenderWidgetHost()->GetProcess()->AddFilter(frame_watcher_.get()); |