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

Side by Side Diff: components/history/core/browser/history_backend.h

Issue 2599803002: Revert of Document that HistoryBackend is sequence-affine, not thread-affine. (Closed)
Patch Set: Created 4 years 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
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 COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_
6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 std::unique_ptr<HistoryDBTask> task_; 82 std::unique_ptr<HistoryDBTask> task_;
83 scoped_refptr<base::SingleThreadTaskRunner> origin_loop_; 83 scoped_refptr<base::SingleThreadTaskRunner> origin_loop_;
84 base::CancelableTaskTracker::IsCanceledCallback is_canceled_; 84 base::CancelableTaskTracker::IsCanceledCallback is_canceled_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(QueuedHistoryDBTask); 86 DISALLOW_COPY_AND_ASSIGN(QueuedHistoryDBTask);
87 }; 87 };
88 88
89 // *See the .cc file for more information on the design.* 89 // *See the .cc file for more information on the design.*
90 // 90 //
91 // Internal history implementation which does most of the work of the history 91 // Internal history implementation which does most of the work of the history
92 // system. This runs on a dedicated sequence (to not block the browser when we 92 // system. This runs on a background thread (to not block the browser when we
93 // do expensive operations). It is NOT threadsafe: unless otherwise noted, all 93 // do expensive operations) and is NOT threadsafe, so it must only be called
94 // methods must be called from the same sequence. 94 // from message handlers on the background thread. Invoking on another thread
95 // requires threadsafe refcounting.
95 // 96 //
96 // Most functions here are just the implementations of the corresponding 97 // Most functions here are just the implementations of the corresponding
97 // functions in the history service. These functions are not documented 98 // functions in the history service. These functions are not documented
98 // here, see the history service for behavior. 99 // here, see the history service for behavior.
99 class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, 100 class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
100 public HistoryBackendNotifier { 101 public HistoryBackendNotifier {
101 public: 102 public:
102 // Interface implemented by the owner of the HistoryBackend object. Normally, 103 // Interface implemented by the owner of the HistoryBackend object. Normally,
103 // the history service implements this to send stuff back to the main thread. 104 // the history service implements this to send stuff back to the main thread.
104 // The unit tests can provide a different implementation if they don't have 105 // The unit tests can provide a different implementation if they don't have
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 160
160 // Notify HistoryService that keyword search term has been deleted. 161 // Notify HistoryService that keyword search term has been deleted.
161 // The event will be forwarded to the HistoryServiceObservers in the correct 162 // The event will be forwarded to the HistoryServiceObservers in the correct
162 // thread. 163 // thread.
163 virtual void NotifyKeywordSearchTermDeleted(URLID url_id) = 0; 164 virtual void NotifyKeywordSearchTermDeleted(URLID url_id) = 0;
164 165
165 // Invoked when the backend has finished loading the db. 166 // Invoked when the backend has finished loading the db.
166 virtual void DBLoaded() = 0; 167 virtual void DBLoaded() = 0;
167 }; 168 };
168 169
169 // This constructor can be invoked on any sequence. Init() must then be called 170 // Init must be called to complete object creation. This object can be
170 // on |task_runner|'s sequence to complete object creation. Unless otherwise 171 // constructed on any thread, but all other functions including Init() must
171 // noted, all methods must be called on |task_runner|'s sequence. 172 // be called on the history thread.
172 // 173 //
173 // |history_dir| is the directory where the history files will be placed. 174 // |history_dir| is the directory where the history files will be placed.
174 // See the definition of BroadcastNotificationsCallback above. This function 175 // See the definition of BroadcastNotificationsCallback above. This function
175 // takes ownership of the callback pointer. 176 // takes ownership of the callback pointer.
176 // 177 //
177 // |history_client| is used to determine bookmarked URLs when deleting and 178 // |history_client| is used to determine bookmarked URLs when deleting and
178 // may be null. 179 // may be null.
179 // 180 //
180 // This constructor is fast and does no I/O, so can be called at any time. 181 // This constructor is fast and does no I/O, so can be called at any time.
181 HistoryBackend(Delegate* delegate, 182 HistoryBackend(Delegate* delegate,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 void DeleteMatchingURLsForKeyword(KeywordID keyword_id, 351 void DeleteMatchingURLsForKeyword(KeywordID keyword_id,
351 const base::string16& term); 352 const base::string16& term);
352 353
353 // Observers ----------------------------------------------------------------- 354 // Observers -----------------------------------------------------------------
354 355
355 void AddObserver(HistoryBackendObserver* observer); 356 void AddObserver(HistoryBackendObserver* observer);
356 void RemoveObserver(HistoryBackendObserver* observer); 357 void RemoveObserver(HistoryBackendObserver* observer);
357 358
358 // Generic operations -------------------------------------------------------- 359 // Generic operations --------------------------------------------------------
359 360
360 // This method can be called from any sequence.
361 void ProcessDBTask( 361 void ProcessDBTask(
362 std::unique_ptr<HistoryDBTask> task, 362 std::unique_ptr<HistoryDBTask> task,
363 scoped_refptr<base::SingleThreadTaskRunner> origin_loop, 363 scoped_refptr<base::SingleThreadTaskRunner> origin_loop,
364 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled); 364 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled);
365 365
366 virtual bool GetAllTypedURLs(URLRows* urls); 366 virtual bool GetAllTypedURLs(URLRows* urls);
367 367
368 virtual bool GetVisitsForURL(URLID id, VisitVector* visits); 368 virtual bool GetVisitsForURL(URLID id, VisitVector* visits);
369 369
370 // Fetches up to |max_visits| most recent visits for the passed URL. 370 // Fetches up to |max_visits| most recent visits for the passed URL.
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 // http://www.google.com/favicon.ico) has changed. 755 // http://www.google.com/favicon.ico) has changed.
756 void SendFaviconChangedNotificationForPageAndRedirects(const GURL& page_url); 756 void SendFaviconChangedNotificationForPageAndRedirects(const GURL& page_url);
757 757
758 // Send notification that the bitmap data for the favicon at |icon_url| has 758 // Send notification that the bitmap data for the favicon at |icon_url| has
759 // changed. Sending this notification is important because the favicon at 759 // changed. Sending this notification is important because the favicon at
760 // |icon_url| may be mapped to hundreds of page URLs. 760 // |icon_url| may be mapped to hundreds of page URLs.
761 void SendFaviconChangedNotificationForIconURL(const GURL& icon_url); 761 void SendFaviconChangedNotificationForIconURL(const GURL& icon_url);
762 762
763 // Generic stuff ------------------------------------------------------------- 763 // Generic stuff -------------------------------------------------------------
764 764
765 // Processes the next scheduled HistoryDBTask, scheduling this method to be 765 // Processes the next scheduled HistoryDBTask, scheduling this method
766 // invoked again if there are more tasks that need to run. This method can be 766 // to be invoked again if there are more tasks that need to run.
767 // called from any sequence.
768 void ProcessDBTaskImpl(); 767 void ProcessDBTaskImpl();
769 768
770 // HistoryBackendNotifier: 769 // HistoryBackendNotifier:
771 void NotifyFaviconsChanged(const std::set<GURL>& page_urls, 770 void NotifyFaviconsChanged(const std::set<GURL>& page_urls,
772 const GURL& icon_url) override; 771 const GURL& icon_url) override;
773 void NotifyURLVisited(ui::PageTransition transition, 772 void NotifyURLVisited(ui::PageTransition transition,
774 const URLRow& row, 773 const URLRow& row,
775 const RedirectList& redirects, 774 const RedirectList& redirects,
776 base::Time visit_time) override; 775 base::Time visit_time) override;
777 void NotifyURLsModified(const URLRows& rows) override; 776 void NotifyURLsModified(const URLRows& rows) override;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 889
891 // List of observers 890 // List of observers
892 base::ObserverList<HistoryBackendObserver> observers_; 891 base::ObserverList<HistoryBackendObserver> observers_;
893 892
894 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 893 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
895 }; 894 };
896 895
897 } // namespace history 896 } // namespace history
898 897
899 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ 898 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_
OLDNEW
« no previous file with comments | « components/browser_sync/profile_sync_service_typed_url_unittest.cc ('k') | components/history/core/browser/history_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698