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

Side by Side Diff: content/browser/frame_host/navigation_entry_screenshot_manager.cc

Issue 593503003: Support error handling for Surface readbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatted code and fixed build issue in test. Created 6 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
OLDNEW
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 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" 5 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/threading/worker_pool.h" 8 #include "base/threading/worker_pool.h"
9 #include "content/browser/frame_host/navigation_controller_impl.h" 9 #include "content/browser/frame_host/navigation_controller_impl.h"
10 #include "content/browser/frame_host/navigation_entry_impl.h" 10 #include "content/browser/frame_host/navigation_entry_impl.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 entry->GetUniqueID()), 128 entry->GetUniqueID()),
129 kAlpha_8_SkColorType); 129 kAlpha_8_SkColorType);
130 } 130 }
131 131
132 void NavigationEntryScreenshotManager::SetMinScreenshotIntervalMS( 132 void NavigationEntryScreenshotManager::SetMinScreenshotIntervalMS(
133 int interval_ms) { 133 int interval_ms) {
134 DCHECK_GE(interval_ms, 0); 134 DCHECK_GE(interval_ms, 0);
135 min_screenshot_interval_ms_ = interval_ms; 135 min_screenshot_interval_ms_ = interval_ms;
136 } 136 }
137 137
138 void NavigationEntryScreenshotManager::OnScreenshotTaken(int unique_id, 138 void NavigationEntryScreenshotManager::OnScreenshotTaken(
139 bool success, 139 int unique_id,
140 const SkBitmap& bitmap) { 140 const SkBitmap& bitmap,
141 ReadbackResponse response) {
141 NavigationEntryImpl* entry = NULL; 142 NavigationEntryImpl* entry = NULL;
142 int entry_count = owner_->GetEntryCount(); 143 int entry_count = owner_->GetEntryCount();
143 for (int i = 0; i < entry_count; ++i) { 144 for (int i = 0; i < entry_count; ++i) {
144 NavigationEntry* iter = owner_->GetEntryAtIndex(i); 145 NavigationEntry* iter = owner_->GetEntryAtIndex(i);
145 if (iter->GetUniqueID() == unique_id) { 146 if (iter->GetUniqueID() == unique_id) {
146 entry = NavigationEntryImpl::FromNavigationEntry(iter); 147 entry = NavigationEntryImpl::FromNavigationEntry(iter);
147 break; 148 break;
148 } 149 }
149 } 150 }
150 151
151 if (!entry) { 152 if (!entry) {
152 LOG(ERROR) << "Invalid entry with unique id: " << unique_id; 153 LOG(ERROR) << "Invalid entry with unique id: " << unique_id;
153 return; 154 return;
154 } 155 }
155 156
156 if (!success || bitmap.empty() || bitmap.isNull()) { 157 if ((response != READBACK_SUCCESS) || bitmap.empty() || bitmap.isNull()) {
157 if (!ClearScreenshot(entry)) 158 if (!ClearScreenshot(entry))
158 OnScreenshotSet(entry); 159 OnScreenshotSet(entry);
159 return; 160 return;
160 } 161 }
161 162
162 scoped_refptr<ScreenshotData> screenshot = new ScreenshotData(); 163 scoped_refptr<ScreenshotData> screenshot = new ScreenshotData();
163 screenshot->EncodeScreenshot( 164 screenshot->EncodeScreenshot(
164 bitmap, 165 bitmap,
165 base::Bind(&NavigationEntryScreenshotManager::OnScreenshotEncodeComplete, 166 base::Bind(&NavigationEntryScreenshotManager::OnScreenshotEncodeComplete,
166 screenshot_factory_.GetWeakPtr(), 167 screenshot_factory_.GetWeakPtr(),
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 owner_->GetEntryAtIndex(forward)); 273 owner_->GetEntryAtIndex(forward));
273 if (ClearScreenshot(entry)) 274 if (ClearScreenshot(entry))
274 --screenshot_count; 275 --screenshot_count;
275 ++forward; 276 ++forward;
276 } 277 }
277 CHECK_GE(screenshot_count, 0); 278 CHECK_GE(screenshot_count, 0);
278 CHECK_LE(screenshot_count, kMaxScreenshots); 279 CHECK_LE(screenshot_count, kMaxScreenshots);
279 } 280 }
280 281
281 } // namespace content 282 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698