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

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

Issue 16296002: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/history/top_sites_impl.h" 5 #include "chrome/browser/history/top_sites_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return false; // It's not a real webpage. 219 return false; // It's not a real webpage.
220 220
221 scoped_refptr<base::RefCountedBytes> thumbnail_data; 221 scoped_refptr<base::RefCountedBytes> thumbnail_data;
222 if (!EncodeBitmap(thumbnail, &thumbnail_data)) 222 if (!EncodeBitmap(thumbnail, &thumbnail_data))
223 return false; 223 return false;
224 224
225 if (add_temp_thumbnail) { 225 if (add_temp_thumbnail) {
226 // Always remove the existing entry and then add it back. That way if we end 226 // Always remove the existing entry and then add it back. That way if we end
227 // up with too many temp thumbnails we'll prune the oldest first. 227 // up with too many temp thumbnails we'll prune the oldest first.
228 RemoveTemporaryThumbnailByURL(url); 228 RemoveTemporaryThumbnailByURL(url);
229 AddTemporaryThumbnail(url, thumbnail_data, score); 229 AddTemporaryThumbnail(url, thumbnail_data.get(), score);
230 return true; 230 return true;
231 } 231 }
232 232
233 return SetPageThumbnailEncoded(url, thumbnail_data, score); 233 return SetPageThumbnailEncoded(url, thumbnail_data.get(), score);
234 } 234 }
235 235
236 bool TopSitesImpl::SetPageThumbnailToJPEGBytes( 236 bool TopSitesImpl::SetPageThumbnailToJPEGBytes(
237 const GURL& url, 237 const GURL& url,
238 const base::RefCountedMemory* memory, 238 const base::RefCountedMemory* memory,
239 const ThumbnailScore& score) { 239 const ThumbnailScore& score) {
240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
241 241
242 if (!loaded_) { 242 if (!loaded_) {
243 // TODO(sky): I need to cache these and apply them after the load 243 // TODO(sky): I need to cache these and apply them after the load
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 DCHECK_EQ(history_state_, HISTORY_MIGRATING); 362 DCHECK_EQ(history_state_, HISTORY_MIGRATING);
363 363
364 history_state_ = HISTORY_LOADED; 364 history_state_ = HISTORY_LOADED;
365 365
366 SetTopSites(data.most_visited); 366 SetTopSites(data.most_visited);
367 367
368 for (size_t i = 0; i < data.most_visited.size(); ++i) { 368 for (size_t i = 0; i < data.most_visited.size(); ++i) {
369 URLToThumbnailMap::const_iterator image_i = 369 URLToThumbnailMap::const_iterator image_i =
370 data.url_to_thumbnail_map.find(data.most_visited[i].url); 370 data.url_to_thumbnail_map.find(data.most_visited[i].url);
371 if (image_i != data.url_to_thumbnail_map.end()) { 371 if (image_i != data.url_to_thumbnail_map.end()) {
372 SetPageThumbnailEncoded(data.most_visited[i].url, 372 SetPageThumbnailEncoded(
373 image_i->second, 373 data.most_visited[i].url, image_i->second.get(), ThumbnailScore());
374 ThumbnailScore());
375 } 374 }
376 } 375 }
377 376
378 MoveStateToLoaded(); 377 MoveStateToLoaded();
379 378
380 ResetThreadSafeImageCache(); 379 ResetThreadSafeImageCache();
381 380
382 // We've scheduled all the thumbnails and top sites to be written to the top 381 // We've scheduled all the thumbnails and top sites to be written to the top
383 // sites db, but it hasn't happened yet. Schedule a request on the db thread 382 // sites db, but it hasn't happened yet. Schedule a request on the db thread
384 // that notifies us when done. When done we'll know everything was written and 383 // that notifies us when done. When done we'll know everything was written and
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 // See if we have any tmp thumbnails for the new sites. 785 // See if we have any tmp thumbnails for the new sites.
787 if (!temp_images_.empty()) { 786 if (!temp_images_.empty()) {
788 for (size_t i = 0; i < top_sites.size(); ++i) { 787 for (size_t i = 0; i < top_sites.size(); ++i) {
789 const MostVisitedURL& mv = top_sites[i]; 788 const MostVisitedURL& mv = top_sites[i];
790 GURL canonical_url = cache_->GetCanonicalURL(mv.url); 789 GURL canonical_url = cache_->GetCanonicalURL(mv.url);
791 // At the time we get the thumbnail redirects aren't known, so we have to 790 // At the time we get the thumbnail redirects aren't known, so we have to
792 // iterate through all the images. 791 // iterate through all the images.
793 for (TempImages::iterator it = temp_images_.begin(); 792 for (TempImages::iterator it = temp_images_.begin();
794 it != temp_images_.end(); ++it) { 793 it != temp_images_.end(); ++it) {
795 if (canonical_url == cache_->GetCanonicalURL(it->first)) { 794 if (canonical_url == cache_->GetCanonicalURL(it->first)) {
796 SetPageThumbnailEncoded(mv.url, 795 SetPageThumbnailEncoded(
797 it->second.thumbnail, 796 mv.url, it->second.thumbnail.get(), it->second.thumbnail_score);
798 it->second.thumbnail_score);
799 temp_images_.erase(it); 797 temp_images_.erase(it);
800 break; 798 break;
801 } 799 }
802 } 800 }
803 } 801 }
804 } 802 }
805 803
806 if (top_sites.size() >= kTopSitesNumber) 804 if (top_sites.size() >= kTopSitesNumber)
807 temp_images_.clear(); 805 temp_images_.clear();
808 806
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 SetTopSites(pages); 936 SetTopSites(pages);
939 937
940 // Used only in testing. 938 // Used only in testing.
941 content::NotificationService::current()->Notify( 939 content::NotificationService::current()->Notify(
942 chrome::NOTIFICATION_TOP_SITES_UPDATED, 940 chrome::NOTIFICATION_TOP_SITES_UPDATED,
943 content::Source<TopSitesImpl>(this), 941 content::Source<TopSitesImpl>(this),
944 content::Details<CancelableRequestProvider::Handle>(&handle)); 942 content::Details<CancelableRequestProvider::Handle>(&handle));
945 } 943 }
946 944
947 } // namespace history 945 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/in_memory_url_index_unittest.cc ('k') | chrome/browser/history/top_sites_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698