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

Side by Side Diff: chrome/browser/history/top_sites.cc

Issue 6813040: Add TopSites::GetTemporaryThumbnailScore(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/history/top_sites_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/history/top_sites.h" 5 #include "chrome/browser/history/top_sites.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 239 }
240 240
241 filtered_urls = thread_safe_cache_->top_sites(); 241 filtered_urls = thread_safe_cache_->top_sites();
242 } 242 }
243 request->ForwardResult(GetTopSitesCallback::TupleType(filtered_urls)); 243 request->ForwardResult(GetTopSitesCallback::TupleType(filtered_urls));
244 } 244 }
245 245
246 bool TopSites::GetPageThumbnail(const GURL& url, 246 bool TopSites::GetPageThumbnail(const GURL& url,
247 scoped_refptr<RefCountedBytes>* bytes) { 247 scoped_refptr<RefCountedBytes>* bytes) {
248 // WARNING: this may be invoked on any thread. 248 // WARNING: this may be invoked on any thread.
249 base::AutoLock lock(lock_); 249 base::AutoLock lock(lock_);
sky 2011/04/11 14:31:09 The rest of the class doesn't lock around lock_ wh
satorux1 2011/04/11 15:19:09 That makes a lot of sense. I've updated the patch
250
251 // The thumbnail may be found in the temporary images.
252 for (TempImages::iterator i = temp_images_.begin(); i != temp_images_.end();
253 ++i) {
254 if (i->first == url) {
255 *bytes = i->second.thumbnail;
256 return true;
257 }
258 }
250 return thread_safe_cache_->GetPageThumbnail(url, bytes); 259 return thread_safe_cache_->GetPageThumbnail(url, bytes);
251 } 260 }
252 261
253 bool TopSites::GetPageThumbnailScore(const GURL& url, 262 bool TopSites::GetPageThumbnailScore(const GURL& url,
254 ThumbnailScore* score) { 263 ThumbnailScore* score) {
255 // WARNING: this may be invoked on any thread. 264 // WARNING: this may be invoked on any thread.
256 base::AutoLock lock(lock_); 265 base::AutoLock lock(lock_);
266
267 // The thumbnail score may be found in the temporary images.
268 for (TempImages::iterator i = temp_images_.begin(); i != temp_images_.end();
269 ++i) {
270 if (i->first == url) {
271 *score = i->second.thumbnail_score;
272 return true;
273 }
274 }
257 return thread_safe_cache_->GetPageThumbnailScore(url, score); 275 return thread_safe_cache_->GetPageThumbnailScore(url, score);
258 } 276 }
259 277
260 // Returns the index of |url| in |urls|, or -1 if not found. 278 // Returns the index of |url| in |urls|, or -1 if not found.
261 static int IndexOf(const MostVisitedURLList& urls, const GURL& url) { 279 static int IndexOf(const MostVisitedURLList& urls, const GURL& url) {
262 for (size_t i = 0; i < urls.size(); i++) { 280 for (size_t i = 0; i < urls.size(); i++) {
263 if (urls[i].url == url) 281 if (urls[i].url == url)
264 return i; 282 return i;
265 } 283 }
266 return -1; 284 return -1;
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 SetTopSites(pages); 981 SetTopSites(pages);
964 982
965 // Used only in testing. 983 // Used only in testing.
966 NotificationService::current()->Notify( 984 NotificationService::current()->Notify(
967 NotificationType::TOP_SITES_UPDATED, 985 NotificationType::TOP_SITES_UPDATED,
968 Source<TopSites>(this), 986 Source<TopSites>(this),
969 Details<CancelableRequestProvider::Handle>(&handle)); 987 Details<CancelableRequestProvider::Handle>(&handle));
970 } 988 }
971 989
972 } // namespace history 990 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/top_sites_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698