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

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

Issue 6389001: Add heuristics to skip thumbnail generation when it's unnecessary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor cleanup Created 9 years, 11 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.cc » ('j') | chrome/common/thumbnail_score.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_HISTORY_TOP_SITES_H_ 5 #ifndef CHROME_BROWSER_HISTORY_TOP_SITES_H_
6 #define CHROME_BROWSER_HISTORY_TOP_SITES_H_ 6 #define CHROME_BROWSER_HISTORY_TOP_SITES_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <set> 10 #include <set>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 void GetMostVisitedURLs(CancelableRequestConsumer* consumer, 72 void GetMostVisitedURLs(CancelableRequestConsumer* consumer,
73 GetTopSitesCallback* callback); 73 GetTopSitesCallback* callback);
74 74
75 // Get a thumbnail for a given page. Returns true iff we have the thumbnail. 75 // Get a thumbnail for a given page. Returns true iff we have the thumbnail.
76 // This may be invoked on any thread. 76 // This may be invoked on any thread.
77 // As this method may be invoked on any thread the ref count needs to be 77 // As this method may be invoked on any thread the ref count needs to be
78 // upped before this method returns, so this takes a scoped_refptr*. 78 // upped before this method returns, so this takes a scoped_refptr*.
79 bool GetPageThumbnail(const GURL& url, 79 bool GetPageThumbnail(const GURL& url,
80 scoped_refptr<RefCountedBytes>* bytes); 80 scoped_refptr<RefCountedBytes>* bytes);
81 81
82 // Get a thumbnail score for a given page. Returns true iff we have the
83 // thumbnail score. This may be invoked on any thread. The score will
84 // be copied to |score|.
85 virtual bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score);
86
82 // Invoked from History if migration is needed. If this is invoked it will 87 // Invoked from History if migration is needed. If this is invoked it will
83 // be before HistoryLoaded is invoked. 88 // be before HistoryLoaded is invoked.
84 void MigrateFromHistory(); 89 void MigrateFromHistory();
85 90
86 // Invoked with data from migrating thumbnails out of history. 91 // Invoked with data from migrating thumbnails out of history.
87 void FinishHistoryMigration(const ThumbnailMigration& data); 92 void FinishHistoryMigration(const ThumbnailMigration& data);
88 93
89 // Invoked from history when it finishes loading. If MigrateFromHistory was 94 // Invoked from history when it finishes loading. If MigrateFromHistory was
90 // not invoked at this point then we load from the top sites service. 95 // not invoked at this point then we load from the top sites service.
91 void HistoryLoaded(); 96 void HistoryLoaded();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 const MostVisitedURLList& new_list, 142 const MostVisitedURLList& new_list,
138 TopSitesDelta* delta); 143 TopSitesDelta* delta);
139 144
140 // Query history service for the list of available thumbnails. Returns the 145 // Query history service for the list of available thumbnails. Returns the
141 // handle for the request, or NULL if a request could not be made. 146 // handle for the request, or NULL if a request could not be made.
142 // Public only for testing purposes. 147 // Public only for testing purposes.
143 CancelableRequestProvider::Handle StartQueryForMostVisited(); 148 CancelableRequestProvider::Handle StartQueryForMostVisited();
144 149
145 bool loaded() const { return loaded_; } 150 bool loaded() const { return loaded_; }
146 151
152 // Returns true if the given URL is known to the top sites service.
153 virtual bool IsKnownURL(const GURL& url);
brettw 2011/01/26 05:55:20 Both IsKnownURL and IsFull return false if TopSite
satorux1 2011/01/26 08:14:46 Good idea. Done.
154
155 // Returns true if the top sites list is full (i.e. we already have the
156 // maximu number of top sites).
brettw 2011/01/26 05:55:20 spelling: maximum
satorux1 2011/01/26 08:14:46 Done.
157 virtual bool IsFull();
158
159 protected:
160 // For allowing inheritance.
161 virtual ~TopSites();
162
147 private: 163 private:
148 friend class base::RefCountedThreadSafe<TopSites>; 164 friend class base::RefCountedThreadSafe<TopSites>;
149 friend class TopSitesTest; 165 friend class TopSitesTest;
150 166
151 typedef std::pair<GURL, Images> TempImage; 167 typedef std::pair<GURL, Images> TempImage;
152 typedef std::list<TempImage> TempImages; 168 typedef std::list<TempImage> TempImages;
153 169
154 // Enumeration of the possible states history can be in. 170 // Enumeration of the possible states history can be in.
155 enum HistoryLoadState { 171 enum HistoryLoadState {
156 // We're waiting for history to finish loading. 172 // We're waiting for history to finish loading.
(...skipping 13 matching lines...) Expand all
170 186
171 // The backend finished loading, but we may need to migrate. This is true if 187 // The backend finished loading, but we may need to migrate. This is true if
172 // the top sites db didn't exist, or if the db existed but is from an old 188 // the top sites db didn't exist, or if the db existed but is from an old
173 // version. 189 // version.
174 TOP_SITES_LOADED_WAITING_FOR_HISTORY, 190 TOP_SITES_LOADED_WAITING_FOR_HISTORY,
175 191
176 // Top sites is loaded. 192 // Top sites is loaded.
177 TOP_SITES_LOADED 193 TOP_SITES_LOADED
178 }; 194 };
179 195
180 ~TopSites();
181
182 // Sets the thumbnail without writing to the database. Useful when 196 // Sets the thumbnail without writing to the database. Useful when
183 // reading last known top sites from the DB. 197 // reading last known top sites from the DB.
184 // Returns true if the thumbnail was set, false if the existing one is better. 198 // Returns true if the thumbnail was set, false if the existing one is better.
185 bool SetPageThumbnailNoDB(const GURL& url, 199 bool SetPageThumbnailNoDB(const GURL& url,
186 const RefCountedBytes* thumbnail_data, 200 const RefCountedBytes* thumbnail_data,
187 const ThumbnailScore& score); 201 const ThumbnailScore& score);
188 202
189 // A version of SetPageThumbnail that takes RefCountedBytes as 203 // A version of SetPageThumbnail that takes RefCountedBytes as
190 // returned by HistoryService. 204 // returned by HistoryService.
191 bool SetPageThumbnailEncoded(const GURL& url, 205 bool SetPageThumbnailEncoded(const GURL& url,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 360
347 // Are we loaded? 361 // Are we loaded?
348 bool loaded_; 362 bool loaded_;
349 363
350 DISALLOW_COPY_AND_ASSIGN(TopSites); 364 DISALLOW_COPY_AND_ASSIGN(TopSites);
351 }; 365 };
352 366
353 } // namespace history 367 } // namespace history
354 368
355 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ 369 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/top_sites.cc » ('j') | chrome/common/thumbnail_score.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698