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

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

Issue 815983002: Topsites become keyedService based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review comments Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/history/history_service.h" 11 #include "chrome/browser/history/history_service.h"
13 #include "components/history/core/browser/history_types.h" 12 #include "components/history/core/browser/history_types.h"
14 #include "components/history/core/browser/top_sites_observer.h" 13 #include "components/history/core/browser/top_sites_observer.h"
15 #include "components/history/core/common/thumbnail_score.h" 14 #include "components/history/core/common/thumbnail_score.h"
15 #include "components/keyed_service/core/refcounted_keyed_service.h"
16 #include "third_party/skia/include/core/SkColor.h" 16 #include "third_party/skia/include/core/SkColor.h"
17 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
18 18
19 class GURL; 19 class GURL;
20 class Profile; 20 class Profile;
21 21
22 namespace base { 22 namespace base {
23 class FilePath; 23 class FilePath;
24 class RefCountedBytes; 24 class RefCountedBytes;
25 class RefCountedMemory; 25 class RefCountedMemory;
26 } 26 }
27 27
28 namespace history { 28 namespace history {
29 29
30 class TopSitesCache; 30 class TopSitesCache;
31 31
32 // Interface for TopSites, which stores the data for the top "most visited" 32 // Interface for TopSites, which stores the data for the top "most visited"
33 // sites. This includes a cache of the most visited data from history, as well 33 // sites. This includes a cache of the most visited data from history, as well
34 // as the corresponding thumbnails of those sites. 34 // as the corresponding thumbnails of those sites.
35 // 35 //
36 // Some methods should only be called from the UI thread (see method 36 // Some methods should only be called from the UI thread (see method
37 // descriptions below). All others are assumed to be threadsafe. 37 // descriptions below). All others are assumed to be threadsafe.
38 class TopSites 38 class TopSites : public RefcountedKeyedService,
39 : public base::RefCountedThreadSafe<TopSites>, 39 public content::NotificationObserver {
40 public content::NotificationObserver {
41 public: 40 public:
42 TopSites(); 41 TopSites();
43 42
44 // Initializes TopSites. 43 // Initializes TopSites.
45 static TopSites* Create(Profile* profile, const base::FilePath& db_name); 44 static TopSites* Create(Profile* profile, const base::FilePath& db_name);
46 45
47 // Sets the given thumbnail for the given URL. Returns true if the thumbnail 46 // Sets the given thumbnail for the given URL. Returns true if the thumbnail
48 // was updated. False means either the URL wasn't known to us, or we felt 47 // was updated. False means either the URL wasn't known to us, or we felt
49 // that our current thumbnail was superior to the given one. Should be called 48 // that our current thumbnail was superior to the given one. Should be called
50 // from the UI thread. 49 // from the UI thread.
51 virtual bool SetPageThumbnail(const GURL& url, 50 virtual bool SetPageThumbnail(const GURL& url,
52 const gfx::Image& thumbnail, 51 const gfx::Image& thumbnail,
53 const ThumbnailScore& score) = 0; 52 const ThumbnailScore& score) = 0;
54 53
55 // While testing the history system, we want to set the thumbnail to a piece 54 // While testing the history system, we want to set the thumbnail to a piece
56 // of static memory. 55 // of static memory.
57 virtual bool SetPageThumbnailToJPEGBytes( 56 virtual bool SetPageThumbnailToJPEGBytes(const GURL& url,
58 const GURL& url, 57 const base::RefCountedMemory* memory,
59 const base::RefCountedMemory* memory, 58 const ThumbnailScore& score) = 0;
60 const ThumbnailScore& score) = 0;
61 59
62 typedef base::Callback<void(const MostVisitedURLList&)> 60 typedef base::Callback<void(const MostVisitedURLList&)>
63 GetMostVisitedURLsCallback; 61 GetMostVisitedURLsCallback;
64 62
65 // Returns a list of most visited URLs via a callback, if 63 // Returns a list of most visited URLs via a callback, if
66 // |include_forced_urls| is false includes only non-forced URLs. This may be 64 // |include_forced_urls| is false includes only non-forced URLs. This may be
67 // invoked on any thread. NOTE: the callback is called immediately if we have 65 // invoked on any thread. NOTE: the callback is called immediately if we have
68 // the data cached. If data is not available yet, callback will later be 66 // the data cached. If data is not available yet, callback will later be
69 // posted to the thread called this function. 67 // posted to the thread called this function.
70 virtual void GetMostVisitedURLs( 68 virtual void GetMostVisitedURLs(const GetMostVisitedURLsCallback& callback,
71 const GetMostVisitedURLsCallback& callback, 69 bool include_forced_urls) = 0;
72 bool include_forced_urls) = 0;
73 70
74 // Gets a thumbnail for a given page. Returns true iff we have the thumbnail. 71 // Gets a thumbnail for a given page. Returns true iff we have the thumbnail.
75 // This may be invoked on any thread. 72 // This may be invoked on any thread.
76 // If an exact thumbnail URL match fails, |prefix_match| specifies whether or 73 // If an exact thumbnail URL match fails, |prefix_match| specifies whether or
77 // not to try harder by matching the query thumbnail URL as URL prefix (as 74 // not to try harder by matching the query thumbnail URL as URL prefix (as
78 // defined by UrlIsPrefix()). 75 // defined by UrlIsPrefix()).
79 // As this method may be invoked on any thread the ref count needs to be 76 // As this method may be invoked on any thread the ref count needs to be
80 // incremented before this method returns, so this takes a scoped_refptr*. 77 // incremented before this method returns, so this takes a scoped_refptr*.
81 virtual bool GetPageThumbnail( 78 virtual bool GetPageThumbnail(
82 const GURL& url, 79 const GURL& url,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 const int kPrepopulatedPagesCount = 0; 186 const int kPrepopulatedPagesCount = 0;
190 #else 187 #else
191 const int kPrepopulatedPagesCount = 2; 188 const int kPrepopulatedPagesCount = 2;
192 #endif 189 #endif
193 extern const TopSites::PrepopulatedPage 190 extern const TopSites::PrepopulatedPage
194 kPrepopulatedPages[kPrepopulatedPagesCount]; 191 kPrepopulatedPages[kPrepopulatedPagesCount];
195 192
196 } // namespace history 193 } // namespace history
197 194
198 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ 195 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698