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

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: ... 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
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.cc ('k') | chrome/browser/history/top_sites.cc » ('j') | no next file with comments »
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>
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"
16 #include "base/time.h" 18 #include "base/time.h"
17 #include "base/timer.h" 19 #include "base/timer.h"
18 #include "base/ref_counted.h"
19 #include "base/ref_counted_memory.h"
20 #include "chrome/browser/browser_thread.h" 20 #include "chrome/browser/browser_thread.h"
21 #include "chrome/browser/cancelable_request.h" 21 #include "chrome/browser/cancelable_request.h"
22 #include "chrome/browser/history/history_types.h" 22 #include "chrome/browser/history/history_types.h"
23 #include "chrome/browser/history/history.h" 23 #include "chrome/browser/history/history.h"
24 #include "chrome/browser/history/page_usage_data.h" 24 #include "chrome/browser/history/page_usage_data.h"
25 #include "chrome/common/notification_service.h" 25 #include "chrome/common/notification_service.h"
26 #include "chrome/common/thumbnail_score.h" 26 #include "chrome/common/thumbnail_score.h"
27 #include "googleurl/src/gurl.h" 27 #include "googleurl/src/gurl.h"
28 28
29 class DictionaryValue; 29 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 134 // 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 135 // "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|. 136 // have their index into "old" put into |deleted_urls|.
137 // 137 //
138 // URLs appearing in both old and new lists but having different indices will 138 // URLs appearing in both old and new lists but having different indices will
139 // have their index into "new" be put into |moved_urls|. 139 // have their index into "new" be put into |moved_urls|.
140 static void DiffMostVisited(const MostVisitedURLList& old_list, 140 static void DiffMostVisited(const MostVisitedURLList& old_list,
141 const MostVisitedURLList& new_list, 141 const MostVisitedURLList& new_list,
142 TopSitesDelta* delta); 142 TopSitesDelta* delta);
143 143
144 // Query history service for the list of available thumbnails. Returns the
145 // handle for the request, or NULL if a request could not be made.
146 // Public only for testing purposes.
147 CancelableRequestProvider::Handle StartQueryForMostVisited();
148
149 bool loaded() { return loaded_; }
sky 2010/11/17 22:36:01 const
150
144 private: 151 private:
145 friend class base::RefCountedThreadSafe<TopSites>; 152 friend class base::RefCountedThreadSafe<TopSites>;
146 friend class TopSitesTest; 153 friend class TopSitesTest;
147 154
148 typedef std::pair<GURL, Images> TempImage; 155 typedef std::pair<GURL, Images> TempImage;
149 typedef std::list<TempImage> TempImages; 156 typedef std::list<TempImage> TempImages;
150 157
151 // Enumeration of the possible states history can be in. 158 // Enumeration of the possible states history can be in.
152 enum HistoryLoadState { 159 enum HistoryLoadState {
153 // We're waiting for history to finish loading. 160 // We're waiting for history to finish loading.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 203
197 // Removes the cached thumbnail for url. Does nothing if |url| if not cached 204 // Removes the cached thumbnail for url. Does nothing if |url| if not cached
198 // in |temp_images_|. 205 // in |temp_images_|.
199 void RemoveTemporaryThumbnailByURL(const GURL& url); 206 void RemoveTemporaryThumbnailByURL(const GURL& url);
200 207
201 // Add a thumbnail for an unknown url. See temp_thumbnails_map_. 208 // Add a thumbnail for an unknown url. See temp_thumbnails_map_.
202 void AddTemporaryThumbnail(const GURL& url, 209 void AddTemporaryThumbnail(const GURL& url,
203 const RefCountedBytes* thumbnail, 210 const RefCountedBytes* thumbnail,
204 const ThumbnailScore& score); 211 const ThumbnailScore& score);
205 212
206 // Query history service for the list of available thumbnails. 213 // Called by our timer. Starts the query for the most visited sites.
207 void StartQueryForMostVisited(); 214 void TimerFired();
208 215
209 // Finds the given URL in the redirect chain for the given TopSite, and 216 // 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. 217 // 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. 218 // The URL is assumed to be in the list. The destination is 0.
212 static int GetRedirectDistanceForURL(const MostVisitedURL& most_visited, 219 static int GetRedirectDistanceForURL(const MostVisitedURL& most_visited,
213 const GURL& url); 220 const GURL& url);
214 221
215 // Returns the set of prepopulate pages. 222 // Returns the set of prepopulate pages.
216 static MostVisitedURLList GetPrepopulatePages(); 223 static MostVisitedURLList GetPrepopulatePages();
217 224
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 scoped_refptr<TopSitesBackend> backend_; 291 scoped_refptr<TopSitesBackend> backend_;
285 292
286 // The top sites data. 293 // The top sites data.
287 scoped_ptr<TopSitesCache> cache_; 294 scoped_ptr<TopSitesCache> cache_;
288 295
289 // Copy of the top sites data that may be accessed on any thread (assuming 296 // 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 297 // you hold |lock_|). The data in |thread_safe_cache_| has blacklisted and
291 // pinned urls applied (|cache_| does not). 298 // pinned urls applied (|cache_| does not).
292 scoped_ptr<TopSitesCache> thread_safe_cache_; 299 scoped_ptr<TopSitesCache> thread_safe_cache_;
293 300
301 // Invokes the callback signaling the cache has been completely refreshed.
302 // This is only used for testing.
303 void InvokeRefreshCallback(CancelableRequestProvider::Handle handle);
sky 2010/11/17 22:36:01 This isn't needed anymore, right?
304
294 Profile* profile_; 305 Profile* profile_;
295 306
296 // Lock used to access |thread_safe_cache_|. 307 // Lock used to access |thread_safe_cache_|.
297 mutable Lock lock_; 308 mutable Lock lock_;
298 309
299 CancelableRequestConsumer cancelable_consumer_; 310 CancelableRequestConsumer cancelable_consumer_;
300 311
301 // Timer that asks history for the top sites. This is used to make sure our 312 // Timer that asks history for the top sites. This is used to make sure our
302 // data stays in sync with history. 313 // data stays in sync with history.
303 base::OneShotTimer<TopSites> timer_; 314 base::OneShotTimer<TopSites> timer_;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 354
344 // Are we loaded? 355 // Are we loaded?
345 bool loaded_; 356 bool loaded_;
346 357
347 DISALLOW_COPY_AND_ASSIGN(TopSites); 358 DISALLOW_COPY_AND_ASSIGN(TopSites);
348 }; 359 };
349 360
350 } // namespace history 361 } // namespace history
351 362
352 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ 363 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.cc ('k') | chrome/browser/history/top_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698