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

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

Issue 387923002: Make HistoryDBTask not refcounted, and ensure it's destroyed on its origin thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix 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>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // thumbnail database. 43 // thumbnail database.
44 static const size_t kMaxFaviconsPerPage = 8; 44 static const size_t kMaxFaviconsPerPage = 8;
45 45
46 // 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
47 // the thumbnail database. 47 // the thumbnail database.
48 static const size_t kMaxFaviconBitmapsPerIconURL = 8; 48 static const size_t kMaxFaviconBitmapsPerIconURL = 8;
49 49
50 class QueuedHistoryDBTask { 50 class QueuedHistoryDBTask {
51 public: 51 public:
52 QueuedHistoryDBTask( 52 QueuedHistoryDBTask(
53 scoped_refptr<HistoryDBTask> task, 53 scoped_ptr<HistoryDBTask> task,
54 scoped_refptr<base::SingleThreadTaskRunner> origin_loop, 54 scoped_refptr<base::SingleThreadTaskRunner> origin_loop,
55 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled); 55 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled);
56 ~QueuedHistoryDBTask(); 56 ~QueuedHistoryDBTask();
57 57
58 bool is_canceled(); 58 bool is_canceled();
59 bool RunOnDBThread(HistoryBackend* backend, HistoryDatabase* db); 59 bool Run(HistoryBackend* backend, HistoryDatabase* db);
60 void DoneRunOnMainThread(); 60 void DoneRun();
61 61
62 private: 62 private:
63 scoped_refptr<HistoryDBTask> task_; 63 scoped_ptr<HistoryDBTask> task_;
64 scoped_refptr<base::SingleThreadTaskRunner> origin_loop_; 64 scoped_refptr<base::SingleThreadTaskRunner> origin_loop_;
65 base::CancelableTaskTracker::IsCanceledCallback is_canceled_; 65 base::CancelableTaskTracker::IsCanceledCallback is_canceled_;
66
67 DISALLOW_COPY_AND_ASSIGN(QueuedHistoryDBTask);
66 }; 68 };
67 69
68 // *See the .cc file for more information on the design.* 70 // *See the .cc file for more information on the design.*
69 // 71 //
70 // Internal history implementation which does most of the work of the history 72 // Internal history implementation which does most of the work of the history
71 // system. This runs on a background thread (to not block the browser when we 73 // system. This runs on a background thread (to not block the browser when we
72 // do expensive operations) and is NOT threadsafe, so it must only be called 74 // do expensive operations) and is NOT threadsafe, so it must only be called
73 // from message handlers on the background thread. Invoking on another thread 75 // from message handlers on the background thread. Invoking on another thread
74 // requires threadsafe refcounting. 76 // requires threadsafe refcounting.
75 // 77 //
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 const std::vector<SearchRow::ColumnID>& projections, 336 const std::vector<SearchRow::ColumnID>& projections,
335 const std::string& selection, 337 const std::string& selection,
336 const std::vector<base::string16>& selection_args, 338 const std::vector<base::string16>& selection_args,
337 const std::string& sort_order); 339 const std::string& sort_order);
338 340
339 #endif // defined(OS_ANDROID) 341 #endif // defined(OS_ANDROID)
340 342
341 // Generic operations -------------------------------------------------------- 343 // Generic operations --------------------------------------------------------
342 344
343 void ProcessDBTask( 345 void ProcessDBTask(
344 scoped_refptr<HistoryDBTask> task, 346 scoped_ptr<HistoryDBTask> task,
345 scoped_refptr<base::SingleThreadTaskRunner> origin_loop, 347 scoped_refptr<base::SingleThreadTaskRunner> origin_loop,
346 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled); 348 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled);
347 349
348 virtual bool GetAllTypedURLs(URLRows* urls); 350 virtual bool GetAllTypedURLs(URLRows* urls);
349 351
350 virtual bool GetVisitsForURL(URLID id, VisitVector* visits); 352 virtual bool GetVisitsForURL(URLID id, VisitVector* visits);
351 353
352 // Fetches up to |max_visits| most recent visits for the passed URL. 354 // Fetches up to |max_visits| most recent visits for the passed URL.
353 virtual bool GetMostRecentVisitsForURL(URLID id, 355 virtual bool GetMostRecentVisitsForURL(URLID id,
354 int max_visits, 356 int max_visits,
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 base::Closure backend_destroy_task_; 824 base::Closure backend_destroy_task_;
823 825
824 // Tracks page transition types. 826 // Tracks page transition types.
825 VisitTracker tracker_; 827 VisitTracker tracker_;
826 828
827 // A boolean variable to track whether we have already purged obsolete segment 829 // A boolean variable to track whether we have already purged obsolete segment
828 // data. 830 // data.
829 bool segment_queried_; 831 bool segment_queried_;
830 832
831 // List of QueuedHistoryDBTasks to run; 833 // List of QueuedHistoryDBTasks to run;
832 std::list<QueuedHistoryDBTask> queued_history_db_tasks_; 834 std::list<QueuedHistoryDBTask*> queued_history_db_tasks_;
833 835
834 // Used to determine if a URL is bookmarked; may be NULL. 836 // Used to determine if a URL is bookmarked; may be NULL.
835 // 837 //
836 // Use GetHistoryClient to access this, which makes sure the bookmarks are 838 // Use GetHistoryClient to access this, which makes sure the bookmarks are
837 // loaded before returning. 839 // loaded before returning.
838 HistoryClient* history_client_; 840 HistoryClient* history_client_;
839 841
840 #if defined(OS_ANDROID) 842 #if defined(OS_ANDROID)
841 // Used to provide the Android ContentProvider APIs. 843 // Used to provide the Android ContentProvider APIs.
842 scoped_ptr<AndroidProviderBackend> android_provider_backend_; 844 scoped_ptr<AndroidProviderBackend> android_provider_backend_;
(...skipping 11 matching lines...) Expand all
854 856
855 // Listens for the system being under memory pressure. 857 // Listens for the system being under memory pressure.
856 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; 858 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
857 859
858 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 860 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
859 }; 861 };
860 862
861 } // namespace history 863 } // namespace history
862 864
863 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 865 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/history_backend.cc » ('j') | chrome/browser/history/history_backend.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698