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

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

Issue 352913002: Port HistoryService::ScheduleDBTask to CancelableTaskTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix lifetime of base::CancelableTaskTracker for HistoryModelWorker Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/containers/mru_cache.h" 13 #include "base/containers/mru_cache.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/memory_pressure_listener.h" 16 #include "base/memory/memory_pressure_listener.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/task/cancelable_task_tracker.h"
18 #include "chrome/browser/history/expire_history_backend.h" 19 #include "chrome/browser/history/expire_history_backend.h"
19 #include "chrome/browser/history/history_database.h" 20 #include "chrome/browser/history/history_database.h"
20 #include "chrome/browser/history/history_marshaling.h" 21 #include "chrome/browser/history/history_marshaling.h"
21 #include "chrome/browser/history/history_types.h" 22 #include "chrome/browser/history/history_types.h"
22 #include "chrome/browser/history/thumbnail_database.h" 23 #include "chrome/browser/history/thumbnail_database.h"
23 #include "chrome/browser/history/visit_tracker.h" 24 #include "chrome/browser/history/visit_tracker.h"
24 #include "components/history/core/browser/keyword_id.h" 25 #include "components/history/core/browser/keyword_id.h"
25 #include "sql/init_status.h" 26 #include "sql/init_status.h"
26 27
27 class TestingProfile; 28 class TestingProfile;
(...skipping 11 matching lines...) Expand all
39 struct DownloadRow; 40 struct DownloadRow;
40 41
41 // The maximum number of icons URLs per page which can be stored in the 42 // The maximum number of icons URLs per page which can be stored in the
42 // thumbnail database. 43 // thumbnail database.
43 static const size_t kMaxFaviconsPerPage = 8; 44 static const size_t kMaxFaviconsPerPage = 8;
44 45
45 // The maximum number of bitmaps for a single icon URL which can be stored in 46 // The maximum number of bitmaps for a single icon URL which can be stored in
46 // the thumbnail database. 47 // the thumbnail database.
47 static const size_t kMaxFaviconBitmapsPerIconURL = 8; 48 static const size_t kMaxFaviconBitmapsPerIconURL = 8;
48 49
50 class QueuedHistoryDBTask {
51 public:
52 QueuedHistoryDBTask(
53 scoped_refptr<HistoryDBTask> task,
54 scoped_refptr<base::SingleThreadTaskRunner> origin_loop,
55 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled);
56 ~QueuedHistoryDBTask();
57
58 bool is_canceled();
59 bool RunOnDBThread(HistoryBackend* backend, HistoryDatabase* db);
60 void DoneRunOnMainThread();
61
62 private:
63 scoped_refptr<HistoryDBTask> task_;
64 scoped_refptr<base::SingleThreadTaskRunner> origin_loop_;
65 base::CancelableTaskTracker::IsCanceledCallback is_canceled_;
66 };
67
49 // *See the .cc file for more information on the design.* 68 // *See the .cc file for more information on the design.*
50 // 69 //
51 // Internal history implementation which does most of the work of the history 70 // Internal history implementation which does most of the work of the history
52 // system. This runs on a background thread (to not block the browser when we 71 // system. This runs on a background thread (to not block the browser when we
53 // do expensive operations) and is NOT threadsafe, so it must only be called 72 // do expensive operations) and is NOT threadsafe, so it must only be called
54 // from message handlers on the background thread. Invoking on another thread 73 // from message handlers on the background thread. Invoking on another thread
55 // requires threadsafe refcounting. 74 // requires threadsafe refcounting.
56 // 75 //
57 // Most functions here are just the implementations of the corresponding 76 // Most functions here are just the implementations of the corresponding
58 // functions in the history service. These functions are not documented 77 // functions in the history service. These functions are not documented
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 void QuerySearchTerms(scoped_refptr<QueryRequest> request, 332 void QuerySearchTerms(scoped_refptr<QueryRequest> request,
314 const std::vector<SearchRow::ColumnID>& projections, 333 const std::vector<SearchRow::ColumnID>& projections,
315 const std::string& selection, 334 const std::string& selection,
316 const std::vector<base::string16>& selection_args, 335 const std::vector<base::string16>& selection_args,
317 const std::string& sort_order); 336 const std::string& sort_order);
318 337
319 #endif // defined(OS_ANDROID) 338 #endif // defined(OS_ANDROID)
320 339
321 // Generic operations -------------------------------------------------------- 340 // Generic operations --------------------------------------------------------
322 341
323 void ProcessDBTask(scoped_refptr<HistoryDBTaskRequest> request); 342 void ProcessDBTask(
343 scoped_refptr<HistoryDBTask> task,
344 scoped_refptr<base::SingleThreadTaskRunner> origin_loop,
345 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled);
324 346
325 virtual bool GetAllTypedURLs(URLRows* urls); 347 virtual bool GetAllTypedURLs(URLRows* urls);
326 348
327 virtual bool GetVisitsForURL(URLID id, VisitVector* visits); 349 virtual bool GetVisitsForURL(URLID id, VisitVector* visits);
328 350
329 // Fetches up to |max_visits| most recent visits for the passed URL. 351 // Fetches up to |max_visits| most recent visits for the passed URL.
330 virtual bool GetMostRecentVisitsForURL(URLID id, 352 virtual bool GetMostRecentVisitsForURL(URLID id,
331 int max_visits, 353 int max_visits,
332 VisitVector* visits); 354 VisitVector* visits);
333 355
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 // redirects. 727 // redirects.
706 void SendFaviconChangedNotificationForPageAndRedirects( 728 void SendFaviconChangedNotificationForPageAndRedirects(
707 const GURL& page_url); 729 const GURL& page_url);
708 730
709 // Generic stuff ------------------------------------------------------------- 731 // Generic stuff -------------------------------------------------------------
710 732
711 // Processes the next scheduled HistoryDBTask, scheduling this method 733 // Processes the next scheduled HistoryDBTask, scheduling this method
712 // to be invoked again if there are more tasks that need to run. 734 // to be invoked again if there are more tasks that need to run.
713 void ProcessDBTaskImpl(); 735 void ProcessDBTaskImpl();
714 736
715 // Release all tasks in history_db_tasks_ and clears it.
716 void ReleaseDBTasks();
717
718 virtual void BroadcastNotifications( 737 virtual void BroadcastNotifications(
719 int type, 738 int type,
720 scoped_ptr<HistoryDetails> details) OVERRIDE; 739 scoped_ptr<HistoryDetails> details) OVERRIDE;
721 virtual void NotifySyncURLsModified(URLRows* rows) OVERRIDE; 740 virtual void NotifySyncURLsModified(URLRows* rows) OVERRIDE;
722 virtual void NotifySyncURLsDeleted(bool all_history, 741 virtual void NotifySyncURLsDeleted(bool all_history,
723 bool expired, 742 bool expired,
724 URLRows* rows) OVERRIDE; 743 URLRows* rows) OVERRIDE;
725 744
726 // Deleting all history ------------------------------------------------------ 745 // Deleting all history ------------------------------------------------------
727 746
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 base::MessageLoop* backend_destroy_message_loop_; 820 base::MessageLoop* backend_destroy_message_loop_;
802 base::Closure backend_destroy_task_; 821 base::Closure backend_destroy_task_;
803 822
804 // Tracks page transition types. 823 // Tracks page transition types.
805 VisitTracker tracker_; 824 VisitTracker tracker_;
806 825
807 // A boolean variable to track whether we have already purged obsolete segment 826 // A boolean variable to track whether we have already purged obsolete segment
808 // data. 827 // data.
809 bool segment_queried_; 828 bool segment_queried_;
810 829
811 // HistoryDBTasks to run. Be sure to AddRef when adding, and Release when 830 // List of QueuedHistoryDBTasks to run;
812 // done. 831 std::list<QueuedHistoryDBTask> queued_history_db_tasks_;
813 std::list<HistoryDBTaskRequest*> db_task_requests_;
814 832
815 // Used to determine if a URL is bookmarked; may be NULL. 833 // Used to determine if a URL is bookmarked; may be NULL.
816 // 834 //
817 // Use GetHistoryClient to access this, which makes sure the bookmarks are 835 // Use GetHistoryClient to access this, which makes sure the bookmarks are
818 // loaded before returning. 836 // loaded before returning.
819 HistoryClient* history_client_; 837 HistoryClient* history_client_;
820 838
821 #if defined(OS_ANDROID) 839 #if defined(OS_ANDROID)
822 // Used to provide the Android ContentProvider APIs. 840 // Used to provide the Android ContentProvider APIs.
823 scoped_ptr<AndroidProviderBackend> android_provider_backend_; 841 scoped_ptr<AndroidProviderBackend> android_provider_backend_;
(...skipping 11 matching lines...) Expand all
835 853
836 // Listens for the system being under memory pressure. 854 // Listens for the system being under memory pressure.
837 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; 855 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
838 856
839 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 857 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
840 }; 858 };
841 859
842 } // namespace history 860 } // namespace history
843 861
844 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 862 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/delete_directive_handler.cc ('k') | chrome/browser/history/history_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698