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