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

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

Issue 5088001: Add pyauto hook for getting and manipulating the data underneath the NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/functional
Patch Set: add forgotten py files Created 10 years, 1 month 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) 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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/lock.h" 15 #include "base/lock.h"
16 #include "base/ref_counted.h"
17 #include "base/ref_counted_memory.h"
18 #include "base/scoped_ptr.h"
16 #include "base/time.h" 19 #include "base/time.h"
17 #include "base/timer.h" 20 #include "base/timer.h"
18 #include "base/ref_counted.h"
19 #include "base/ref_counted_memory.h"
20 #include "chrome/browser/browser_thread.h" 21 #include "chrome/browser/browser_thread.h"
21 #include "chrome/browser/cancelable_request.h" 22 #include "chrome/browser/cancelable_request.h"
22 #include "chrome/browser/history/history_types.h" 23 #include "chrome/browser/history/history_types.h"
23 #include "chrome/browser/history/history.h" 24 #include "chrome/browser/history/history.h"
24 #include "chrome/browser/history/page_usage_data.h" 25 #include "chrome/browser/history/page_usage_data.h"
25 #include "chrome/common/notification_service.h" 26 #include "chrome/common/notification_service.h"
26 #include "chrome/common/thumbnail_score.h" 27 #include "chrome/common/thumbnail_score.h"
27 #include "googleurl/src/gurl.h" 28 #include "googleurl/src/gurl.h"
28 29
29 class DictionaryValue; 30 class DictionaryValue;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // The URLs that are in "new" but not "old" will be have their index into 135 // The URLs that are in "new" but not "old" will be have their index into
135 // "new" put in |added_urls|. The URLs that are in "old" but not "new" will 136 // "new" put in |added_urls|. The URLs that are in "old" but not "new" will
136 // have their index into "old" put into |deleted_urls|. 137 // have their index into "old" put into |deleted_urls|.
137 // 138 //
138 // URLs appearing in both old and new lists but having different indices will 139 // URLs appearing in both old and new lists but having different indices will
139 // have their index into "new" be put into |moved_urls|. 140 // have their index into "new" be put into |moved_urls|.
140 static void DiffMostVisited(const MostVisitedURLList& old_list, 141 static void DiffMostVisited(const MostVisitedURLList& old_list,
141 const MostVisitedURLList& new_list, 142 const MostVisitedURLList& new_list,
142 TopSitesDelta* delta); 143 TopSitesDelta* delta);
143 144
145 // For use only in testing. Refreshes the top sites list and invokes the
146 // callback on the UI thread when done. Should be called on the UI thread.
147 void RefreshAndCallback(Callback0::Type* callback);
148
144 private: 149 private:
145 friend class base::RefCountedThreadSafe<TopSites>; 150 friend class base::RefCountedThreadSafe<TopSites>;
146 friend class TopSitesTest; 151 friend class TopSitesTest;
147 152
148 typedef std::pair<GURL, Images> TempImage; 153 typedef std::pair<GURL, Images> TempImage;
149 typedef std::list<TempImage> TempImages; 154 typedef std::list<TempImage> TempImages;
150 155
151 // Enumeration of the possible states history can be in. 156 // Enumeration of the possible states history can be in.
152 enum HistoryLoadState { 157 enum HistoryLoadState {
153 // We're waiting for history to finish loading. 158 // We're waiting for history to finish loading.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 201
197 // Removes the cached thumbnail for url. Does nothing if |url| if not cached 202 // Removes the cached thumbnail for url. Does nothing if |url| if not cached
198 // in |temp_images_|. 203 // in |temp_images_|.
199 void RemoveTemporaryThumbnailByURL(const GURL& url); 204 void RemoveTemporaryThumbnailByURL(const GURL& url);
200 205
201 // Add a thumbnail for an unknown url. See temp_thumbnails_map_. 206 // Add a thumbnail for an unknown url. See temp_thumbnails_map_.
202 void AddTemporaryThumbnail(const GURL& url, 207 void AddTemporaryThumbnail(const GURL& url,
203 const RefCountedBytes* thumbnail, 208 const RefCountedBytes* thumbnail,
204 const ThumbnailScore& score); 209 const ThumbnailScore& score);
205 210
206 // Query history service for the list of available thumbnails. 211 // Query history service for the list of available thumbnails. Returns the
207 void StartQueryForMostVisited(); 212 // handle for the request, or NULL if a request could not be made.
213 CancelableRequestProvider::Handle StartQueryForMostVisited();
214
215 // Called by our timer. Starts the query for the most visited sites.
216 void TimerFired();
208 217
209 // Finds the given URL in the redirect chain for the given TopSite, and 218 // Finds the given URL in the redirect chain for the given TopSite, and
210 // returns the distance from the destination in hops that the given URL is. 219 // returns the distance from the destination in hops that the given URL is.
211 // The URL is assumed to be in the list. The destination is 0. 220 // The URL is assumed to be in the list. The destination is 0.
212 static int GetRedirectDistanceForURL(const MostVisitedURL& most_visited, 221 static int GetRedirectDistanceForURL(const MostVisitedURL& most_visited,
213 const GURL& url); 222 const GURL& url);
214 223
215 // Returns the set of prepopulate pages. 224 // Returns the set of prepopulate pages.
216 static MostVisitedURLList GetPrepopulatePages(); 225 static MostVisitedURLList GetPrepopulatePages();
217 226
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 scoped_refptr<TopSitesBackend> backend_; 293 scoped_refptr<TopSitesBackend> backend_;
285 294
286 // The top sites data. 295 // The top sites data.
287 scoped_ptr<TopSitesCache> cache_; 296 scoped_ptr<TopSitesCache> cache_;
288 297
289 // Copy of the top sites data that may be accessed on any thread (assuming 298 // Copy of the top sites data that may be accessed on any thread (assuming
290 // you hold |lock_|). The data in |thread_safe_cache_| has blacklisted and 299 // you hold |lock_|). The data in |thread_safe_cache_| has blacklisted and
291 // pinned urls applied (|cache_| does not). 300 // pinned urls applied (|cache_| does not).
292 scoped_ptr<TopSitesCache> thread_safe_cache_; 301 scoped_ptr<TopSitesCache> thread_safe_cache_;
293 302
303 // Invokes the callback signaling the cache has been completely refreshed.
304 // This is only used for testing.
305 void InvokeRefreshCallback(CancelableRequestProvider::Handle handle);
306
294 Profile* profile_; 307 Profile* profile_;
295 308
296 // Lock used to access |thread_safe_cache_|. 309 // Lock used to access |thread_safe_cache_|.
297 mutable Lock lock_; 310 mutable Lock lock_;
298 311
299 CancelableRequestConsumer cancelable_consumer_; 312 CancelableRequestConsumer cancelable_consumer_;
300 313
301 // Timer that asks history for the top sites. This is used to make sure our 314 // Timer that asks history for the top sites. This is used to make sure our
302 // data stays in sync with history. 315 // data stays in sync with history.
303 base::OneShotTimer<TopSites> timer_; 316 base::OneShotTimer<TopSites> timer_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 350
338 // See description above HistoryLoadState. 351 // See description above HistoryLoadState.
339 HistoryLoadState history_state_; 352 HistoryLoadState history_state_;
340 353
341 // See description above TopSitesLoadState. 354 // See description above TopSitesLoadState.
342 TopSitesLoadState top_sites_state_; 355 TopSitesLoadState top_sites_state_;
343 356
344 // Are we loaded? 357 // Are we loaded?
345 bool loaded_; 358 bool loaded_;
346 359
360 // For testing use only. The history request handle that is being waited upon.
361 // Should be accessed on the UI thread.
362 CancelableRequestProvider::Handle handle_to_wait_for_;
363
364 // For testing use only. The callback to invoke after a refresh has occurred.
365 // Should be accessed on the UI thread.
366 scoped_ptr<Callback0::Type> refresh_callback_;
367
347 DISALLOW_COPY_AND_ASSIGN(TopSites); 368 DISALLOW_COPY_AND_ASSIGN(TopSites);
348 }; 369 };
349 370
350 } // namespace history 371 } // namespace history
351 372
352 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ 373 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698