| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 // This function also returns false if TopSites isn't loaded yet. |
| 154 virtual bool IsKnownURL(const GURL& url); |
| 155 |
| 156 // Returns true if the top sites list is full (i.e. we already have the |
| 157 // maximum number of top sites). This function also returns false if |
| 158 // TopSites isn't loaded yet. |
| 159 virtual bool IsFull(); |
| 160 |
| 161 protected: |
| 162 // For allowing inheritance. |
| 163 virtual ~TopSites(); |
| 164 |
| 147 private: | 165 private: |
| 148 friend class base::RefCountedThreadSafe<TopSites>; | 166 friend class base::RefCountedThreadSafe<TopSites>; |
| 149 friend class TopSitesTest; | 167 friend class TopSitesTest; |
| 150 | 168 |
| 151 typedef std::pair<GURL, Images> TempImage; | 169 typedef std::pair<GURL, Images> TempImage; |
| 152 typedef std::list<TempImage> TempImages; | 170 typedef std::list<TempImage> TempImages; |
| 153 | 171 |
| 154 // Enumeration of the possible states history can be in. | 172 // Enumeration of the possible states history can be in. |
| 155 enum HistoryLoadState { | 173 enum HistoryLoadState { |
| 156 // We're waiting for history to finish loading. | 174 // We're waiting for history to finish loading. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 170 | 188 |
| 171 // The backend finished loading, but we may need to migrate. This is true if | 189 // 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 | 190 // the top sites db didn't exist, or if the db existed but is from an old |
| 173 // version. | 191 // version. |
| 174 TOP_SITES_LOADED_WAITING_FOR_HISTORY, | 192 TOP_SITES_LOADED_WAITING_FOR_HISTORY, |
| 175 | 193 |
| 176 // Top sites is loaded. | 194 // Top sites is loaded. |
| 177 TOP_SITES_LOADED | 195 TOP_SITES_LOADED |
| 178 }; | 196 }; |
| 179 | 197 |
| 180 ~TopSites(); | |
| 181 | |
| 182 // Sets the thumbnail without writing to the database. Useful when | 198 // Sets the thumbnail without writing to the database. Useful when |
| 183 // reading last known top sites from the DB. | 199 // reading last known top sites from the DB. |
| 184 // Returns true if the thumbnail was set, false if the existing one is better. | 200 // Returns true if the thumbnail was set, false if the existing one is better. |
| 185 bool SetPageThumbnailNoDB(const GURL& url, | 201 bool SetPageThumbnailNoDB(const GURL& url, |
| 186 const RefCountedBytes* thumbnail_data, | 202 const RefCountedBytes* thumbnail_data, |
| 187 const ThumbnailScore& score); | 203 const ThumbnailScore& score); |
| 188 | 204 |
| 189 // A version of SetPageThumbnail that takes RefCountedBytes as | 205 // A version of SetPageThumbnail that takes RefCountedBytes as |
| 190 // returned by HistoryService. | 206 // returned by HistoryService. |
| 191 bool SetPageThumbnailEncoded(const GURL& url, | 207 bool SetPageThumbnailEncoded(const GURL& url, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 362 |
| 347 // Are we loaded? | 363 // Are we loaded? |
| 348 bool loaded_; | 364 bool loaded_; |
| 349 | 365 |
| 350 DISALLOW_COPY_AND_ASSIGN(TopSites); | 366 DISALLOW_COPY_AND_ASSIGN(TopSites); |
| 351 }; | 367 }; |
| 352 | 368 |
| 353 } // namespace history | 369 } // namespace history |
| 354 | 370 |
| 355 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ | 371 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ |
| OLD | NEW |