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

Side by Side Diff: chrome/browser/android/thumbnail/thumbnail_store.cc

Issue 1005343004: Update visible ids if any of their thumbnails are invalid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/android/thumbnail/thumbnail_store.h" 5 #include "chrome/browser/android/thumbnail/thumbnail_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/big_endian.h" 10 #include "base/big_endian.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 void ThumbnailStore::UpdateVisibleIds(const TabIdList& priority) { 262 void ThumbnailStore::UpdateVisibleIds(const TabIdList& priority) {
263 if (priority.empty()) { 263 if (priority.empty()) {
264 visible_ids_.clear(); 264 visible_ids_.clear();
265 return; 265 return;
266 } 266 }
267 267
268 size_t ids_size = std::min(priority.size(), cache_.MaximumCacheSize()); 268 size_t ids_size = std::min(priority.size(), cache_.MaximumCacheSize());
269 if (visible_ids_.size() == ids_size) { 269 if (visible_ids_.size() == ids_size) {
270 // Early out if called with the same input as last time (We only care 270 // Early out if called with the same input as last time (We only care
271 // about the first mCache.MaximumCacheSize() entries). 271 // about the first mCache.MaximumCacheSize() entries).
272 bool lists_differ = false; 272 bool needs_update = false;
273 TabIdList::const_iterator visible_iter = visible_ids_.begin(); 273 TabIdList::const_iterator visible_iter = visible_ids_.begin();
274 TabIdList::const_iterator priority_iter = priority.begin(); 274 TabIdList::const_iterator priority_iter = priority.begin();
275 while (visible_iter != visible_ids_.end() && 275 while (visible_iter != visible_ids_.end() &&
276 priority_iter != priority.end()) { 276 priority_iter != priority.end()) {
277 if (*priority_iter != *visible_iter) { 277 if (*priority_iter != *visible_iter || !cache_.Get(*priority_iter)) {
278 lists_differ = true; 278 needs_update = true;
279 break; 279 break;
280 } 280 }
281 visible_iter++; 281 visible_iter++;
282 priority_iter++; 282 priority_iter++;
283 } 283 }
284 284
285 if (!lists_differ) 285 if (!needs_update)
286 return; 286 return;
287 } 287 }
288 288
289 read_queue_.clear(); 289 read_queue_.clear();
290 visible_ids_.clear(); 290 visible_ids_.clear();
291 size_t count = 0; 291 size_t count = 0;
292 TabIdList::const_iterator iter = priority.begin(); 292 TabIdList::const_iterator iter = priority.begin();
293 while (iter != priority.end() && count < ids_size) { 293 while (iter != priority.end() && count < ids_size) {
294 TabId tab_id = *iter; 294 TabId tab_id = *iter;
295 visible_ids_.push_back(tab_id); 295 visible_ids_.push_back(tab_id);
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 dst_bitmap.eraseColor(0); 921 dst_bitmap.eraseColor(0);
922 SkAutoLockPixels dst_bitmap_lock(dst_bitmap); 922 SkAutoLockPixels dst_bitmap_lock(dst_bitmap);
923 923
924 SkCanvas canvas(dst_bitmap); 924 SkCanvas canvas(dst_bitmap);
925 canvas.scale(new_scale, new_scale); 925 canvas.scale(new_scale, new_scale);
926 canvas.drawBitmap(bitmap, 0, 0, NULL); 926 canvas.drawBitmap(bitmap, 0, 0, NULL);
927 dst_bitmap.setImmutable(); 927 dst_bitmap.setImmutable();
928 928
929 return std::make_pair(dst_bitmap, new_scale * scale); 929 return std::make_pair(dst_bitmap, new_scale * scale);
930 } 930 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698