OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_IMPL_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_TOP_SITES_IMPL_H_ |
6 #define CHROME_BROWSER_HISTORY_TOP_SITES_IMPL_H_ | 6 #define CHROME_BROWSER_HISTORY_TOP_SITES_IMPL_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // thread. All other methods must be invoked on the UI thread. All mutations | 46 // thread. All other methods must be invoked on the UI thread. All mutations |
47 // to internal state happen on the UI thread and are scheduled to update the | 47 // to internal state happen on the UI thread and are scheduled to update the |
48 // db using TopSitesBackend. | 48 // db using TopSitesBackend. |
49 class TopSitesImpl : public TopSites { | 49 class TopSitesImpl : public TopSites { |
50 public: | 50 public: |
51 explicit TopSitesImpl(Profile* profile); | 51 explicit TopSitesImpl(Profile* profile); |
52 | 52 |
53 // Initializes TopSitesImpl. | 53 // Initializes TopSitesImpl. |
54 void Init(const base::FilePath& db_name); | 54 void Init(const base::FilePath& db_name); |
55 | 55 |
56 virtual bool SetPageThumbnail(const GURL& url, | 56 bool SetPageThumbnail(const GURL& url, |
57 const gfx::Image& thumbnail, | 57 const gfx::Image& thumbnail, |
58 const ThumbnailScore& score) override; | 58 const ThumbnailScore& score) override; |
59 virtual bool SetPageThumbnailToJPEGBytes( | 59 bool SetPageThumbnailToJPEGBytes(const GURL& url, |
60 const GURL& url, | 60 const base::RefCountedMemory* memory, |
61 const base::RefCountedMemory* memory, | 61 const ThumbnailScore& score) override; |
62 const ThumbnailScore& score) override; | 62 void GetMostVisitedURLs(const GetMostVisitedURLsCallback& callback, |
63 virtual void GetMostVisitedURLs( | 63 bool include_forced_urls) override; |
64 const GetMostVisitedURLsCallback& callback, | 64 bool GetPageThumbnail(const GURL& url, |
65 bool include_forced_urls) override; | 65 bool prefix_match, |
66 virtual bool GetPageThumbnail( | 66 scoped_refptr<base::RefCountedMemory>* bytes) override; |
67 const GURL& url, | 67 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score) override; |
68 bool prefix_match, | 68 bool GetTemporaryPageThumbnailScore(const GURL& url, |
69 scoped_refptr<base::RefCountedMemory>* bytes) override; | 69 ThumbnailScore* score) override; |
70 virtual bool GetPageThumbnailScore(const GURL& url, | 70 void SyncWithHistory() override; |
71 ThumbnailScore* score) override; | 71 bool HasBlacklistedItems() const override; |
72 virtual bool GetTemporaryPageThumbnailScore(const GURL& url, | 72 void AddBlacklistedURL(const GURL& url) override; |
73 ThumbnailScore* score) override; | 73 void RemoveBlacklistedURL(const GURL& url) override; |
74 virtual void SyncWithHistory() override; | 74 bool IsBlacklisted(const GURL& url) override; |
75 virtual bool HasBlacklistedItems() const override; | 75 void ClearBlacklistedURLs() override; |
76 virtual void AddBlacklistedURL(const GURL& url) override; | 76 void Shutdown() override; |
77 virtual void RemoveBlacklistedURL(const GURL& url) override; | 77 base::CancelableTaskTracker::TaskId StartQueryForMostVisited() override; |
78 virtual bool IsBlacklisted(const GURL& url) override; | 78 bool IsKnownURL(const GURL& url) override; |
79 virtual void ClearBlacklistedURLs() override; | 79 const std::string& GetCanonicalURLString(const GURL& url) const override; |
80 virtual void Shutdown() override; | 80 bool IsNonForcedFull() override; |
81 virtual base::CancelableTaskTracker::TaskId StartQueryForMostVisited() | 81 bool IsForcedFull() override; |
82 override; | 82 MostVisitedURLList GetPrepopulatePages() override; |
83 virtual bool IsKnownURL(const GURL& url) override; | 83 bool loaded() const override; |
84 virtual const std::string& GetCanonicalURLString( | 84 bool AddForcedURL(const GURL& url, const base::Time& time) override; |
85 const GURL& url) const override; | |
86 virtual bool IsNonForcedFull() override; | |
87 virtual bool IsForcedFull() override; | |
88 virtual MostVisitedURLList GetPrepopulatePages() override; | |
89 virtual bool loaded() const override; | |
90 virtual bool AddForcedURL(const GURL& url, const base::Time& time) override; | |
91 | 85 |
92 protected: | 86 protected: |
93 virtual ~TopSitesImpl(); | 87 ~TopSitesImpl() override; |
94 | 88 |
95 private: | 89 private: |
96 friend class TopSitesImplTest; | 90 friend class TopSitesImplTest; |
97 FRIEND_TEST_ALL_PREFIXES(TopSitesImplTest, DiffMostVisited); | 91 FRIEND_TEST_ALL_PREFIXES(TopSitesImplTest, DiffMostVisited); |
98 FRIEND_TEST_ALL_PREFIXES(TopSitesImplTest, DiffMostVisitedWithForced); | 92 FRIEND_TEST_ALL_PREFIXES(TopSitesImplTest, DiffMostVisitedWithForced); |
99 | 93 |
100 typedef base::Callback<void(const MostVisitedURLList&, | 94 typedef base::Callback<void(const MostVisitedURLList&, |
101 const MostVisitedURLList&)> PendingCallback; | 95 const MostVisitedURLList&)> PendingCallback; |
102 | 96 |
103 typedef std::pair<GURL, Images> TempImage; | 97 typedef std::pair<GURL, Images> TempImage; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void ApplyBlacklist(const MostVisitedURLList& urls, MostVisitedURLList* out); | 167 void ApplyBlacklist(const MostVisitedURLList& urls, MostVisitedURLList* out); |
174 | 168 |
175 // Returns an MD5 hash of the URL. Hashing is required for blacklisted URLs. | 169 // Returns an MD5 hash of the URL. Hashing is required for blacklisted URLs. |
176 std::string GetURLHash(const GURL& url); | 170 std::string GetURLHash(const GURL& url); |
177 | 171 |
178 // Returns the delay until the next update of history is needed. | 172 // Returns the delay until the next update of history is needed. |
179 // Uses num_urls_changed | 173 // Uses num_urls_changed |
180 base::TimeDelta GetUpdateDelay(); | 174 base::TimeDelta GetUpdateDelay(); |
181 | 175 |
182 // Implementation of content::NotificationObserver. | 176 // Implementation of content::NotificationObserver. |
183 virtual void Observe(int type, | 177 void Observe(int type, |
184 const content::NotificationSource& source, | 178 const content::NotificationSource& source, |
185 const content::NotificationDetails& details) override; | 179 const content::NotificationDetails& details) override; |
186 | 180 |
187 // Updates URLs in |cache_| and the db (in the background). | 181 // Updates URLs in |cache_| and the db (in the background). |
188 // The non-forced URLs in |new_top_sites| replace those in |cache_|. | 182 // The non-forced URLs in |new_top_sites| replace those in |cache_|. |
189 // The forced URLs of |new_top_sites| are merged with those in |cache_|, | 183 // The forced URLs of |new_top_sites| are merged with those in |cache_|, |
190 // if the list of forced URLs overflows, the oldest ones are dropped. | 184 // if the list of forced URLs overflows, the oldest ones are dropped. |
191 // All mutations to cache_ *must* go through this. Should | 185 // All mutations to cache_ *must* go through this. Should |
192 // be called from the UI thread. | 186 // be called from the UI thread. |
193 void SetTopSites(const MostVisitedURLList& new_top_sites); | 187 void SetTopSites(const MostVisitedURLList& new_top_sites); |
194 | 188 |
195 // Returns the number of most visited results to request from history. This | 189 // Returns the number of most visited results to request from history. This |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 256 |
263 // Are we loaded? | 257 // Are we loaded? |
264 bool loaded_; | 258 bool loaded_; |
265 | 259 |
266 DISALLOW_COPY_AND_ASSIGN(TopSitesImpl); | 260 DISALLOW_COPY_AND_ASSIGN(TopSitesImpl); |
267 }; | 261 }; |
268 | 262 |
269 } // namespace history | 263 } // namespace history |
270 | 264 |
271 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_IMPL_H_ | 265 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_IMPL_H_ |
OLD | NEW |