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

Side by Side Diff: components/history/core/browser/top_sites_backend.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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_BACKEND_H_ 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_BACKEND_H_
6 #define CHROME_BROWSER_HISTORY_TOP_SITES_BACKEND_H_ 6 #define COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_BACKEND_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "components/history/core/browser/history_types.h" 12 #include "components/history/core/browser/history_types.h"
13 13
14 namespace base { 14 namespace base {
15 class CancelableTaskTracker; 15 class CancelableTaskTracker;
16 class FilePath; 16 class FilePath;
17 class SingleThreadTaskRunner;
17 } 18 }
18 19
19 namespace history { 20 namespace history {
20 21
21 class TopSitesDatabase; 22 class TopSitesDatabase;
22 23
23 // Service used by TopSites to have db interaction happen on the DB thread. All 24 // Service used by TopSites to have db interaction happen on the DB thread. All
24 // public methods are invoked on the ui thread and get funneled to the DB 25 // public methods are invoked on the ui thread and get funneled to the DB
25 // thread. 26 // thread.
26 class TopSitesBackend : public base::RefCountedThreadSafe<TopSitesBackend> { 27 class TopSitesBackend : public base::RefCountedThreadSafe<TopSitesBackend> {
27 public: 28 public:
28 // The boolean parameter indicates if the DB existed on disk or needs to be 29 // The boolean parameter indicates if the DB existed on disk or needs to be
29 // migrated. 30 // migrated.
30 typedef base::Callback<void(const scoped_refptr<MostVisitedThumbnails>&)> 31 typedef base::Callback<void(const scoped_refptr<MostVisitedThumbnails>&)>
31 GetMostVisitedThumbnailsCallback; 32 GetMostVisitedThumbnailsCallback;
32 33
33 TopSitesBackend(); 34 explicit TopSitesBackend(
35 const scoped_refptr<base::SingleThreadTaskRunner>& db_task_runner);
34 36
35 void Init(const base::FilePath& path); 37 void Init(const base::FilePath& path);
36 38
37 // Schedules the db to be shutdown. 39 // Schedules the db to be shutdown.
38 void Shutdown(); 40 void Shutdown();
39 41
40 // Fetches MostVisitedThumbnails. 42 // Fetches MostVisitedThumbnails.
41 void GetMostVisitedThumbnails( 43 void GetMostVisitedThumbnails(
42 const GetMostVisitedThumbnailsCallback& callback, 44 const GetMostVisitedThumbnailsCallback& callback,
43 base::CancelableTaskTracker* tracker); 45 base::CancelableTaskTracker* tracker);
(...skipping 11 matching lines...) Expand all
55 57
56 // Schedules a request that does nothing on the DB thread, but then notifies 58 // Schedules a request that does nothing on the DB thread, but then notifies
57 // the the calling thread with a reply. This is used to make sure the db has 59 // the the calling thread with a reply. This is used to make sure the db has
58 // finished processing a request. 60 // finished processing a request.
59 void DoEmptyRequest(const base::Closure& reply, 61 void DoEmptyRequest(const base::Closure& reply,
60 base::CancelableTaskTracker* tracker); 62 base::CancelableTaskTracker* tracker);
61 63
62 private: 64 private:
63 friend class base::RefCountedThreadSafe<TopSitesBackend>; 65 friend class base::RefCountedThreadSafe<TopSitesBackend>;
64 66
65 virtual ~TopSitesBackend(); 67 ~TopSitesBackend();
66 68
67 // Invokes Init on the db_. 69 // Invokes Init on the db_.
68 void InitDBOnDBThread(const base::FilePath& path); 70 void InitDBOnDBThread(const base::FilePath& path);
69 71
70 // Shuts down the db. 72 // Shuts down the db.
71 void ShutdownDBOnDBThread(); 73 void ShutdownDBOnDBThread();
72 74
73 // Does the work of getting the most visted thumbnails. 75 // Does the work of getting the most visted thumbnails.
74 void GetMostVisitedThumbnailsOnDBThread( 76 void GetMostVisitedThumbnailsOnDBThread(
75 scoped_refptr<MostVisitedThumbnails> thumbnails); 77 scoped_refptr<MostVisitedThumbnails> thumbnails);
76 78
77 // Updates top sites. 79 // Updates top sites.
78 void UpdateTopSitesOnDBThread(const TopSitesDelta& delta); 80 void UpdateTopSitesOnDBThread(const TopSitesDelta& delta);
79 81
80 // Sets the thumbnail. 82 // Sets the thumbnail.
81 void SetPageThumbnailOnDBThread(const MostVisitedURL& url, 83 void SetPageThumbnailOnDBThread(const MostVisitedURL& url,
82 int url_rank, 84 int url_rank,
83 const Images& thumbnail); 85 const Images& thumbnail);
84 86
85 // Resets the database. 87 // Resets the database.
86 void ResetDatabaseOnDBThread(const base::FilePath& file_path); 88 void ResetDatabaseOnDBThread(const base::FilePath& file_path);
87 89
88 base::FilePath db_path_; 90 base::FilePath db_path_;
89 91
90 scoped_ptr<TopSitesDatabase> db_; 92 scoped_ptr<TopSitesDatabase> db_;
93 scoped_refptr<base::SingleThreadTaskRunner> db_task_runner_;
91 94
92 DISALLOW_COPY_AND_ASSIGN(TopSitesBackend); 95 DISALLOW_COPY_AND_ASSIGN(TopSitesBackend);
93 }; 96 };
94 97
95 } // namespace history 98 } // namespace history
96 99
97 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_BACKEND_H_ 100 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_BACKEND_H_
OLDNEW
« no previous file with comments | « components/history/core/browser/top_sites.cc ('k') | components/history/core/browser/top_sites_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698