OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_HISTORY_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 struct DownloadRow; | 44 struct DownloadRow; |
45 | 45 |
46 // The maximum number of icons URLs per page which can be stored in the | 46 // The maximum number of icons URLs per page which can be stored in the |
47 // thumbnail database. | 47 // thumbnail database. |
48 static const size_t kMaxFaviconsPerPage = 8; | 48 static const size_t kMaxFaviconsPerPage = 8; |
49 | 49 |
50 // The maximum number of bitmaps for a single icon URL which can be stored in | 50 // The maximum number of bitmaps for a single icon URL which can be stored in |
51 // the thumbnail database. | 51 // the thumbnail database. |
52 static const size_t kMaxFaviconBitmapsPerIconURL = 8; | 52 static const size_t kMaxFaviconBitmapsPerIconURL = 8; |
53 | 53 |
| 54 // Keeps track of a queued HistoryDBTask. This class lives solely on the |
| 55 // DB thread. |
54 class QueuedHistoryDBTask { | 56 class QueuedHistoryDBTask { |
55 public: | 57 public: |
56 QueuedHistoryDBTask( | 58 QueuedHistoryDBTask( |
57 scoped_refptr<HistoryDBTask> task, | 59 scoped_ptr<HistoryDBTask> task, |
58 scoped_refptr<base::SingleThreadTaskRunner> origin_loop, | 60 scoped_refptr<base::SingleThreadTaskRunner> origin_loop, |
59 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled); | 61 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled); |
60 ~QueuedHistoryDBTask(); | 62 ~QueuedHistoryDBTask(); |
61 | 63 |
62 bool is_canceled(); | 64 bool is_canceled(); |
63 bool RunOnDBThread(HistoryBackend* backend, HistoryDatabase* db); | 65 bool Run(HistoryBackend* backend, HistoryDatabase* db); |
64 void DoneRunOnMainThread(); | 66 void DoneRun(); |
65 | 67 |
66 private: | 68 private: |
67 scoped_refptr<HistoryDBTask> task_; | 69 scoped_ptr<HistoryDBTask> task_; |
68 scoped_refptr<base::SingleThreadTaskRunner> origin_loop_; | 70 scoped_refptr<base::SingleThreadTaskRunner> origin_loop_; |
69 base::CancelableTaskTracker::IsCanceledCallback is_canceled_; | 71 base::CancelableTaskTracker::IsCanceledCallback is_canceled_; |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(QueuedHistoryDBTask); |
70 }; | 74 }; |
71 | 75 |
72 // *See the .cc file for more information on the design.* | 76 // *See the .cc file for more information on the design.* |
73 // | 77 // |
74 // Internal history implementation which does most of the work of the history | 78 // Internal history implementation which does most of the work of the history |
75 // system. This runs on a background thread (to not block the browser when we | 79 // system. This runs on a background thread (to not block the browser when we |
76 // do expensive operations) and is NOT threadsafe, so it must only be called | 80 // do expensive operations) and is NOT threadsafe, so it must only be called |
77 // from message handlers on the background thread. Invoking on another thread | 81 // from message handlers on the background thread. Invoking on another thread |
78 // requires threadsafe refcounting. | 82 // requires threadsafe refcounting. |
79 // | 83 // |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 const std::vector<SearchRow::ColumnID>& projections, | 370 const std::vector<SearchRow::ColumnID>& projections, |
367 const std::string& selection, | 371 const std::string& selection, |
368 const std::vector<base::string16>& selection_args, | 372 const std::vector<base::string16>& selection_args, |
369 const std::string& sort_order); | 373 const std::string& sort_order); |
370 | 374 |
371 #endif // defined(OS_ANDROID) | 375 #endif // defined(OS_ANDROID) |
372 | 376 |
373 // Generic operations -------------------------------------------------------- | 377 // Generic operations -------------------------------------------------------- |
374 | 378 |
375 void ProcessDBTask( | 379 void ProcessDBTask( |
376 scoped_refptr<HistoryDBTask> task, | 380 scoped_ptr<HistoryDBTask> task, |
377 scoped_refptr<base::SingleThreadTaskRunner> origin_loop, | 381 scoped_refptr<base::SingleThreadTaskRunner> origin_loop, |
378 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled); | 382 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled); |
379 | 383 |
380 virtual bool GetAllTypedURLs(URLRows* urls); | 384 virtual bool GetAllTypedURLs(URLRows* urls); |
381 | 385 |
382 virtual bool GetVisitsForURL(URLID id, VisitVector* visits); | 386 virtual bool GetVisitsForURL(URLID id, VisitVector* visits); |
383 | 387 |
384 // Fetches up to |max_visits| most recent visits for the passed URL. | 388 // Fetches up to |max_visits| most recent visits for the passed URL. |
385 virtual bool GetMostRecentVisitsForURL(URLID id, | 389 virtual bool GetMostRecentVisitsForURL(URLID id, |
386 int max_visits, | 390 int max_visits, |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 base::Closure backend_destroy_task_; | 858 base::Closure backend_destroy_task_; |
855 | 859 |
856 // Tracks page transition types. | 860 // Tracks page transition types. |
857 VisitTracker tracker_; | 861 VisitTracker tracker_; |
858 | 862 |
859 // A boolean variable to track whether we have already purged obsolete segment | 863 // A boolean variable to track whether we have already purged obsolete segment |
860 // data. | 864 // data. |
861 bool segment_queried_; | 865 bool segment_queried_; |
862 | 866 |
863 // List of QueuedHistoryDBTasks to run; | 867 // List of QueuedHistoryDBTasks to run; |
864 std::list<QueuedHistoryDBTask> queued_history_db_tasks_; | 868 std::list<QueuedHistoryDBTask*> queued_history_db_tasks_; |
865 | 869 |
866 // Used to determine if a URL is bookmarked; may be NULL. | 870 // Used to determine if a URL is bookmarked; may be NULL. |
867 // | 871 // |
868 // Use GetHistoryClient to access this, which makes sure the bookmarks are | 872 // Use GetHistoryClient to access this, which makes sure the bookmarks are |
869 // loaded before returning. | 873 // loaded before returning. |
870 HistoryClient* history_client_; | 874 HistoryClient* history_client_; |
871 | 875 |
872 #if defined(OS_ANDROID) | 876 #if defined(OS_ANDROID) |
873 // Used to provide the Android ContentProvider APIs. | 877 // Used to provide the Android ContentProvider APIs. |
874 scoped_ptr<AndroidProviderBackend> android_provider_backend_; | 878 scoped_ptr<AndroidProviderBackend> android_provider_backend_; |
(...skipping 11 matching lines...) Expand all Loading... |
886 | 890 |
887 // Listens for the system being under memory pressure. | 891 // Listens for the system being under memory pressure. |
888 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 892 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
889 | 893 |
890 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 894 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
891 }; | 895 }; |
892 | 896 |
893 } // namespace history | 897 } // namespace history |
894 | 898 |
895 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 899 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
OLD | NEW |