| Index: chrome/browser/history/top_sites.h
|
| ===================================================================
|
| --- chrome/browser/history/top_sites.h (revision 61074)
|
| +++ chrome/browser/history/top_sites.h (working copy)
|
| @@ -48,8 +48,8 @@
|
| // new tab page requests on the I/O thread without proxying to the UI thread is
|
| // a nontrivial performance win, especially when the browser is starting and
|
| // the UI thread is busy.
|
| -class TopSites :
|
| - public base::RefCountedThreadSafe<TopSites,
|
| +class TopSites
|
| + : public base::RefCountedThreadSafe<TopSites,
|
| ChromeThread::DeleteOnUIThread>,
|
| public NotificationObserver,
|
| public CancelableRequestProvider {
|
| @@ -137,6 +137,11 @@
|
| // a real UI thread. Use this function to delete a TopSites object.
|
| static void DeleteTopSites(scoped_refptr<TopSites>& ptr);
|
|
|
| + // For use only in testing. Refreshes the top sites list and invokes the
|
| + // callback on the UI thread when done. Should be called on the UI thread.
|
| + void RefreshAndCallback(CancelableRequestConsumer* consumer,
|
| + Callback0::Type* callback);
|
| +
|
| // Sets the profile pointer to NULL. This is for the case where
|
| // TopSites outlives the profile, since TopSites is refcounted.
|
| void ClearProfile();
|
| @@ -160,6 +165,7 @@
|
| FRIEND_TEST_ALL_PREFIXES(TopSitesTest, BlacklistingAndPinnedURLs);
|
| FRIEND_TEST_ALL_PREFIXES(TopSitesTest, AddPrepopulatedPages);
|
| FRIEND_TEST_ALL_PREFIXES(TopSitesTest, GetPageThumbnail);
|
| + FRIEND_TEST_ALL_PREFIXES(TopSitesTest, RefreshCallback);
|
|
|
| ~TopSites();
|
|
|
| @@ -176,9 +182,13 @@
|
| const RefCountedBytes* thumbnail,
|
| const ThumbnailScore& score);
|
|
|
| - // Query history service for the list of available thumbnails.
|
| - void StartQueryForMostVisited();
|
| + // Query history service for the list of available thumbnails. Returns the
|
| + // handle for the request, or NULL if a request could not be made.
|
| + CancelableRequestProvider::Handle StartQueryForMostVisited();
|
|
|
| + // Called by our timer. Starts the query for the most visited sites.
|
| + void TimerFired();
|
| +
|
| // Query history service for the thumbnail for a given url. |index|
|
| // is the index into top_sites_.
|
| void StartQueryForThumbnail(size_t index);
|
| @@ -295,6 +305,11 @@
|
| // Returns an MD5 hash of the URL. Hashing is required for blacklisted URLs.
|
| std::string GetURLHash(const GURL& url);
|
|
|
| + // Invokes the callback signaling the cache has been completely refreshed.
|
| + // This is only used for testing.
|
| + void InvokeRefreshCallback();
|
| + void InvokeRefreshCallbackOnUIThread();
|
| +
|
| Profile* profile_;
|
| // A mockup to use for testing. If NULL, use the real HistoryService
|
| // from the profile_. See SetMockHistoryService.
|
| @@ -362,6 +377,14 @@
|
| // owned by the PrefService.
|
| DictionaryValue* pinned_urls_;
|
|
|
| + // For testing use only. The callback to invoke after a refresh has occurred.
|
| + // Should be accessed on the UI thread.
|
| + scoped_refptr<CancelableRequest<Callback0::Type> > refresh_callback_;
|
| +
|
| + // For testing use only. The history request handle that is being waited upon.
|
| + // Should be accessed on the UI thread.
|
| + CancelableRequestProvider::Handle handle_to_wait_for_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(TopSites);
|
| };
|
|
|
|
|