| 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 COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_IMPL_H_ |
| 6 #define CHROME_BROWSER_HISTORY_TOP_SITES_IMPL_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_IMPL_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 46 class HistoryService; | 46 class HistoryService; |
| 47 class TopSitesCache; | 47 class TopSitesCache; |
| 48 class TopSitesImplTest; | 48 class TopSitesImplTest; |
| 49 | 49 |
| 50 // This class allows requests for most visited urls and thumbnails on any | 50 // This class allows requests for most visited urls and thumbnails on any |
| 51 // thread. All other methods must be invoked on the UI thread. All mutations | 51 // thread. All other methods must be invoked on the UI thread. All mutations |
| 52 // to internal state happen on the UI thread and are scheduled to update the | 52 // to internal state happen on the UI thread and are scheduled to update the |
| 53 // db using TopSitesBackend. | 53 // db using TopSitesBackend. |
| 54 class TopSitesImpl : public TopSites, public HistoryServiceObserver { | 54 class TopSitesImpl : public TopSites, public HistoryServiceObserver { |
| 55 public: | 55 public: |
| 56 // Called to check whether an URL can be added to the history. Must be |
| 57 // callable multiple time and during the whole lifetime of TopSitesImpl. |
| 58 using CanAddURLToHistoryFn = base::Callback<bool(const GURL&)>; |
| 59 |
| 56 TopSitesImpl(PrefService* pref_service, | 60 TopSitesImpl(PrefService* pref_service, |
| 57 HistoryService* history_service, | 61 HistoryService* history_service, |
| 58 const char* blacklist_pref_name, | 62 const char* blacklist_pref_name, |
| 59 const PrepopulatedPageList& prepopulated_pages); | 63 const PrepopulatedPageList& prepopulated_pages, |
| 64 const CanAddURLToHistoryFn& can_add_url_to_history); |
| 60 | 65 |
| 61 // Initializes TopSitesImpl. | 66 // Initializes TopSitesImpl. |
| 62 void Init(const base::FilePath& db_name, | 67 void Init(const base::FilePath& db_name, |
| 63 const scoped_refptr<base::SingleThreadTaskRunner>& db_task_runner); | 68 const scoped_refptr<base::SingleThreadTaskRunner>& db_task_runner); |
| 64 | 69 |
| 65 // TopSites implementation. | 70 // TopSites implementation. |
| 66 bool SetPageThumbnail(const GURL& url, | 71 bool SetPageThumbnail(const GURL& url, |
| 67 const gfx::Image& thumbnail, | 72 const gfx::Image& thumbnail, |
| 68 const ThumbnailScore& score) override; | 73 const ThumbnailScore& score) override; |
| 69 bool SetPageThumbnailToJPEGBytes(const GURL& url, | 74 bool SetPageThumbnailToJPEGBytes(const GURL& url, |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // TopSitesImpl. | 292 // TopSitesImpl. |
| 288 PrefService* pref_service_; | 293 PrefService* pref_service_; |
| 289 | 294 |
| 290 // Key for the NTP URL blacklist dictionary in PrefService. | 295 // Key for the NTP URL blacklist dictionary in PrefService. |
| 291 const char* blacklist_pref_name_; | 296 const char* blacklist_pref_name_; |
| 292 | 297 |
| 293 // HistoryService that TopSitesImpl can query. May be null, but if defined it | 298 // HistoryService that TopSitesImpl can query. May be null, but if defined it |
| 294 // must outlive TopSitesImpl. | 299 // must outlive TopSitesImpl. |
| 295 HistoryService* history_service_; | 300 HistoryService* history_service_; |
| 296 | 301 |
| 302 // Can URL be added to the history? |
| 303 CanAddURLToHistoryFn can_add_url_to_history_; |
| 304 |
| 297 // Are we loaded? | 305 // Are we loaded? |
| 298 bool loaded_; | 306 bool loaded_; |
| 299 | 307 |
| 300 // Have the SetTopSites execution time related histograms been recorded? | 308 // Have the SetTopSites execution time related histograms been recorded? |
| 301 // The histogram should only be recorded once for each Chrome execution. | 309 // The histogram should only be recorded once for each Chrome execution. |
| 302 static bool histogram_recorded_; | 310 static bool histogram_recorded_; |
| 303 | 311 |
| 304 ScopedObserver<HistoryService, HistoryServiceObserver> | 312 ScopedObserver<HistoryService, HistoryServiceObserver> |
| 305 history_service_observer_; | 313 history_service_observer_; |
| 306 | 314 |
| 307 DISALLOW_COPY_AND_ASSIGN(TopSitesImpl); | 315 DISALLOW_COPY_AND_ASSIGN(TopSitesImpl); |
| 308 }; | 316 }; |
| 309 | 317 |
| 310 } // namespace history | 318 } // namespace history |
| 311 | 319 |
| 312 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_IMPL_H_ | 320 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_IMPL_H_ |
| OLD | NEW |