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

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

Issue 870063002: Componentize TopSites, TopSitesBackend, TopSitesDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@815983002
Patch Set: Fix typo Created 5 years, 10 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
« no previous file with comments | « chrome/browser/history/top_sites_factory.cc ('k') | chrome/browser/history/top_sites_impl.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) 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>
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"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/scoped_observer.h" 18 #include "base/scoped_observer.h"
19 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
20 #include "base/task/cancelable_task_tracker.h" 20 #include "base/task/cancelable_task_tracker.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "base/timer/timer.h" 22 #include "base/timer/timer.h"
23 #include "chrome/browser/history/history_service.h" 23 #include "chrome/browser/history/history_service.h"
24 #include "chrome/browser/history/top_sites.h"
25 #include "chrome/browser/history/top_sites_backend.h"
26 #include "components/history/core/browser/history_service_observer.h" 24 #include "components/history/core/browser/history_service_observer.h"
27 #include "components/history/core/browser/history_types.h" 25 #include "components/history/core/browser/history_types.h"
28 #include "components/history/core/browser/page_usage_data.h" 26 #include "components/history/core/browser/page_usage_data.h"
27 #include "components/history/core/browser/top_sites.h"
28 #include "components/history/core/browser/top_sites_backend.h"
29 #include "components/history/core/common/thumbnail_score.h" 29 #include "components/history/core/common/thumbnail_score.h"
30 #include "content/public/browser/notification_observer.h"
31 #include "content/public/browser/notification_registrar.h"
30 #include "third_party/skia/include/core/SkColor.h" 32 #include "third_party/skia/include/core/SkColor.h"
31 #include "ui/gfx/image/image.h" 33 #include "ui/gfx/image/image.h"
32 #include "url/gurl.h" 34 #include "url/gurl.h"
33 35
34 class Profile; 36 class Profile;
35 37
36 namespace base { 38 namespace base {
37 class FilePath; 39 class FilePath;
38 class RefCountedBytes; 40 class RefCountedBytes;
39 class RefCountedMemory; 41 class RefCountedMemory;
42 class SingleThreadTaskRunner;
40 } 43 }
41 44
42 namespace history { 45 namespace history {
43 46
44 class TopSitesCache; 47 class TopSitesCache;
45 class TopSitesImplTest; 48 class TopSitesImplTest;
46 49
47 // 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
48 // 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
49 // 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
50 // db using TopSitesBackend. 53 // db using TopSitesBackend.
51 class TopSitesImpl : public TopSites, public HistoryServiceObserver { 54 class TopSitesImpl : public TopSites,
55 public HistoryServiceObserver,
56 public content::NotificationObserver {
52 public: 57 public:
53 explicit TopSitesImpl(Profile* profile); 58 TopSitesImpl(Profile* profile,
59 const PrepopulatedPageList& prepopulated_pages);
54 60
55 // Initializes TopSitesImpl. 61 // Initializes TopSitesImpl.
56 void Init(const base::FilePath& db_name); 62 void Init(const base::FilePath& db_name,
63 const scoped_refptr<base::SingleThreadTaskRunner>& db_task_runner);
57 64
58 bool SetPageThumbnail(const GURL& url, 65 bool SetPageThumbnail(const GURL& url,
59 const gfx::Image& thumbnail, 66 const gfx::Image& thumbnail,
60 const ThumbnailScore& score) override; 67 const ThumbnailScore& score) override;
61 bool SetPageThumbnailToJPEGBytes(const GURL& url, 68 bool SetPageThumbnailToJPEGBytes(const GURL& url,
62 const base::RefCountedMemory* memory, 69 const base::RefCountedMemory* memory,
63 const ThumbnailScore& score) override; 70 const ThumbnailScore& score) override;
64 void GetMostVisitedURLs(const GetMostVisitedURLsCallback& callback, 71 void GetMostVisitedURLs(const GetMostVisitedURLsCallback& callback,
65 bool include_forced_urls) override; 72 bool include_forced_urls) override;
66 bool GetPageThumbnail(const GURL& url, 73 bool GetPageThumbnail(const GURL& url,
67 bool prefix_match, 74 bool prefix_match,
68 scoped_refptr<base::RefCountedMemory>* bytes) override; 75 scoped_refptr<base::RefCountedMemory>* bytes) override;
69 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score) override; 76 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score) override;
70 bool GetTemporaryPageThumbnailScore(const GURL& url, 77 bool GetTemporaryPageThumbnailScore(const GURL& url,
71 ThumbnailScore* score) override; 78 ThumbnailScore* score) override;
72 void SyncWithHistory() override; 79 void SyncWithHistory() override;
73 bool HasBlacklistedItems() const override; 80 bool HasBlacklistedItems() const override;
74 void AddBlacklistedURL(const GURL& url) override; 81 void AddBlacklistedURL(const GURL& url) override;
75 void RemoveBlacklistedURL(const GURL& url) override; 82 void RemoveBlacklistedURL(const GURL& url) override;
76 bool IsBlacklisted(const GURL& url) override; 83 bool IsBlacklisted(const GURL& url) override;
77 void ClearBlacklistedURLs() override; 84 void ClearBlacklistedURLs() override;
78 base::CancelableTaskTracker::TaskId StartQueryForMostVisited() override; 85 base::CancelableTaskTracker::TaskId StartQueryForMostVisited() override;
79 bool IsKnownURL(const GURL& url) override; 86 bool IsKnownURL(const GURL& url) override;
80 const std::string& GetCanonicalURLString(const GURL& url) const override; 87 const std::string& GetCanonicalURLString(const GURL& url) const override;
81 bool IsNonForcedFull() override; 88 bool IsNonForcedFull() override;
82 bool IsForcedFull() override; 89 bool IsForcedFull() override;
83 MostVisitedURLList GetPrepopulatePages() override; 90 PrepopulatedPageList GetPrepopulatedPages() override;
84 bool loaded() const override; 91 bool loaded() const override;
85 bool AddForcedURL(const GURL& url, const base::Time& time) override; 92 bool AddForcedURL(const GURL& url, const base::Time& time) override;
86 93
87 // RefcountedKeyedService: 94 // RefcountedKeyedService:
88 void ShutdownOnUIThread() override; 95 void ShutdownOnUIThread() override;
89 96
90 protected: 97 protected:
91 ~TopSitesImpl() override; 98 ~TopSitesImpl() override;
92 99
93 private: 100 private:
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // cached list and be able to run callbacks immediately. 264 // cached list and be able to run callbacks immediately.
258 PendingCallbacks pending_callbacks_; 265 PendingCallbacks pending_callbacks_;
259 266
260 // Stores thumbnails for unknown pages. When SetPageThumbnail is 267 // Stores thumbnails for unknown pages. When SetPageThumbnail is
261 // called, if we don't know about that URL yet and we don't have 268 // called, if we don't know about that URL yet and we don't have
262 // enough Top Sites (new profile), we store it until the next 269 // enough Top Sites (new profile), we store it until the next
263 // SetNonForcedTopSites call. 270 // SetNonForcedTopSites call.
264 TempImages temp_images_; 271 TempImages temp_images_;
265 272
266 // URL List of prepopulated page. 273 // URL List of prepopulated page.
267 std::vector<GURL> prepopulated_page_urls_; 274 PrepopulatedPageList prepopulated_pages_;
268 275
269 // Are we loaded? 276 // Are we loaded?
270 bool loaded_; 277 bool loaded_;
271 278
272 ScopedObserver<HistoryService, HistoryServiceObserver> 279 ScopedObserver<HistoryService, HistoryServiceObserver>
273 history_service_observer_; 280 history_service_observer_;
274 281
275 DISALLOW_COPY_AND_ASSIGN(TopSitesImpl); 282 DISALLOW_COPY_AND_ASSIGN(TopSitesImpl);
276 }; 283 };
277 284
278 } // namespace history 285 } // namespace history
279 286
280 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_IMPL_H_ 287 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/top_sites_factory.cc ('k') | chrome/browser/history/top_sites_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698