OLD | NEW |
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 CHROME_BROWSER_HISTORY_TOP_SITES_BACKEND_H_ |
6 #define CHROME_BROWSER_HISTORY_TOP_SITES_BACKEND_H_ | 6 #define CHROME_BROWSER_HISTORY_TOP_SITES_BACKEND_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_path.h" | 9 #include "base/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 "chrome/browser/history/history_types.h" | 12 #include "chrome/browser/history/history_types.h" |
13 | 13 |
14 class CancelableTaskTracker; | 14 class CancelableTaskTracker; |
| 15 |
| 16 namespace base { |
15 class FilePath; | 17 class FilePath; |
| 18 } |
16 | 19 |
17 namespace history { | 20 namespace history { |
18 | 21 |
19 class TopSitesDatabase; | 22 class TopSitesDatabase; |
20 | 23 |
21 // 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 |
22 // 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 |
23 // thread. | 26 // thread. |
24 class TopSitesBackend : public base::RefCountedThreadSafe<TopSitesBackend> { | 27 class TopSitesBackend : public base::RefCountedThreadSafe<TopSitesBackend> { |
25 public: | 28 public: |
26 // 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 |
27 // migrated. | 30 // migrated. |
28 typedef base::Callback<void(const scoped_refptr<MostVisitedThumbnails>&, | 31 typedef base::Callback<void(const scoped_refptr<MostVisitedThumbnails>&, |
29 const bool*)> | 32 const bool*)> |
30 GetMostVisitedThumbnailsCallback; | 33 GetMostVisitedThumbnailsCallback; |
31 | 34 |
32 TopSitesBackend(); | 35 TopSitesBackend(); |
33 | 36 |
34 void Init(const FilePath& path); | 37 void Init(const base::FilePath& path); |
35 | 38 |
36 // Schedules the db to be shutdown. | 39 // Schedules the db to be shutdown. |
37 void Shutdown(); | 40 void Shutdown(); |
38 | 41 |
39 // Fetches MostVisitedThumbnails. | 42 // Fetches MostVisitedThumbnails. |
40 void GetMostVisitedThumbnails( | 43 void GetMostVisitedThumbnails( |
41 const GetMostVisitedThumbnailsCallback& callback, | 44 const GetMostVisitedThumbnailsCallback& callback, |
42 CancelableTaskTracker* tracker); | 45 CancelableTaskTracker* tracker); |
43 | 46 |
44 // Updates top sites database from the specified delta. | 47 // Updates top sites database from the specified delta. |
(...skipping 12 matching lines...) Expand all Loading... |
57 // finished processing a request. | 60 // finished processing a request. |
58 void DoEmptyRequest(const base::Closure& reply, | 61 void DoEmptyRequest(const base::Closure& reply, |
59 CancelableTaskTracker* tracker); | 62 CancelableTaskTracker* tracker); |
60 | 63 |
61 private: | 64 private: |
62 friend class base::RefCountedThreadSafe<TopSitesBackend>; | 65 friend class base::RefCountedThreadSafe<TopSitesBackend>; |
63 | 66 |
64 virtual ~TopSitesBackend(); | 67 virtual ~TopSitesBackend(); |
65 | 68 |
66 // Invokes Init on the db_. | 69 // Invokes Init on the db_. |
67 void InitDBOnDBThread(const FilePath& path); | 70 void InitDBOnDBThread(const base::FilePath& path); |
68 | 71 |
69 // Shuts down the db. | 72 // Shuts down the db. |
70 void ShutdownDBOnDBThread(); | 73 void ShutdownDBOnDBThread(); |
71 | 74 |
72 // Does the work of getting the most visted thumbnails. | 75 // Does the work of getting the most visted thumbnails. |
73 void GetMostVisitedThumbnailsOnDBThread( | 76 void GetMostVisitedThumbnailsOnDBThread( |
74 scoped_refptr<MostVisitedThumbnails> thumbnails, | 77 scoped_refptr<MostVisitedThumbnails> thumbnails, |
75 bool* need_history_migration); | 78 bool* need_history_migration); |
76 | 79 |
77 // Updates top sites. | 80 // Updates top sites. |
78 void UpdateTopSitesOnDBThread(const TopSitesDelta& delta); | 81 void UpdateTopSitesOnDBThread(const TopSitesDelta& delta); |
79 | 82 |
80 // Sets the thumbnail. | 83 // Sets the thumbnail. |
81 void SetPageThumbnailOnDBThread(const MostVisitedURL& url, | 84 void SetPageThumbnailOnDBThread(const MostVisitedURL& url, |
82 int url_rank, | 85 int url_rank, |
83 const Images& thumbnail); | 86 const Images& thumbnail); |
84 | 87 |
85 // Resets the database. | 88 // Resets the database. |
86 void ResetDatabaseOnDBThread(const FilePath& file_path); | 89 void ResetDatabaseOnDBThread(const base::FilePath& file_path); |
87 | 90 |
88 FilePath db_path_; | 91 base::FilePath db_path_; |
89 | 92 |
90 scoped_ptr<TopSitesDatabase> db_; | 93 scoped_ptr<TopSitesDatabase> db_; |
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 // CHROME_BROWSER_HISTORY_TOP_SITES_BACKEND_H_ |
OLD | NEW |