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

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

Issue 2591123004: Document that HistoryBackend is sequence-affine, not thread-affine. (Closed)
Patch Set: self-review Created 3 years, 12 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
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 background thread (to not block the browser when we 92 // system. This runs on a dedicated sequence (to not block the browser when we
93 // do expensive operations) and is NOT threadsafe, so it must only be called 93 // do expensive operations). It is NOT threadsafe: unless otherwise noted, all
94 // from message handlers on the background thread. Invoking on another thread 94 // methods must be called from the same sequence.
95 // requires threadsafe refcounting.
96 // 95 //
97 // Most functions here are just the implementations of the corresponding 96 // Most functions here are just the implementations of the corresponding
98 // functions in the history service. These functions are not documented 97 // functions in the history service. These functions are not documented
99 // here, see the history service for behavior. 98 // here, see the history service for behavior.
100 class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, 99 class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
101 public HistoryBackendNotifier { 100 public HistoryBackendNotifier {
102 public: 101 public:
103 // Interface implemented by the owner of the HistoryBackend object. Normally, 102 // Interface implemented by the owner of the HistoryBackend object. Normally,
104 // the history service implements this to send stuff back to the main thread. 103 // the history service implements this to send stuff back to the main thread.
105 // The unit tests can provide a different implementation if they don't have 104 // 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
160 159
161 // Notify HistoryService that keyword search term has been deleted. 160 // Notify HistoryService that keyword search term has been deleted.
162 // The event will be forwarded to the HistoryServiceObservers in the correct 161 // The event will be forwarded to the HistoryServiceObservers in the correct
163 // thread. 162 // thread.
164 virtual void NotifyKeywordSearchTermDeleted(URLID url_id) = 0; 163 virtual void NotifyKeywordSearchTermDeleted(URLID url_id) = 0;
165 164
166 // Invoked when the backend has finished loading the db. 165 // Invoked when the backend has finished loading the db.
167 virtual void DBLoaded() = 0; 166 virtual void DBLoaded() = 0;
168 }; 167 };
169 168
170 // Init must be called to complete object creation. This object can be 169 // This constructor can be invoked on any sequence. Init() must then be called
171 // constructed on any thread, but all other functions including Init() must 170 // on |task_runner|'s sequence to complete object creation. Unless otherwise
172 // be called on the history thread. 171 // noted, all methods must be called on |task_runner|'s sequence.
173 // 172 //
174 // |history_dir| is the directory where the history files will be placed. 173 // |history_dir| is the directory where the history files will be placed.
175 // See the definition of BroadcastNotificationsCallback above. This function 174 // See the definition of BroadcastNotificationsCallback above. This function
176 // takes ownership of the callback pointer. 175 // takes ownership of the callback pointer.
177 // 176 //
178 // |history_client| is used to determine bookmarked URLs when deleting and 177 // |history_client| is used to determine bookmarked URLs when deleting and
179 // may be null. 178 // may be null.
180 // 179 //
181 // This constructor is fast and does no I/O, so can be called at any time. 180 // This constructor is fast and does no I/O, so can be called at any time.
182 HistoryBackend(Delegate* delegate, 181 HistoryBackend(Delegate* delegate,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 void DeleteMatchingURLsForKeyword(KeywordID keyword_id, 350 void DeleteMatchingURLsForKeyword(KeywordID keyword_id,
352 const base::string16& term); 351 const base::string16& term);
353 352
354 // Observers ----------------------------------------------------------------- 353 // Observers -----------------------------------------------------------------
355 354
356 void AddObserver(HistoryBackendObserver* observer); 355 void AddObserver(HistoryBackendObserver* observer);
357 void RemoveObserver(HistoryBackendObserver* observer); 356 void RemoveObserver(HistoryBackendObserver* observer);
358 357
359 // Generic operations -------------------------------------------------------- 358 // Generic operations --------------------------------------------------------
360 359
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 765 // Processes the next scheduled HistoryDBTask, scheduling this method to be
766 // to be invoked again if there are more tasks that need to run. 766 // invoked again if there are more tasks that need to run. This method can be
767 // called from any sequence.
767 void ProcessDBTaskImpl(); 768 void ProcessDBTaskImpl();
768 769
769 // HistoryBackendNotifier: 770 // HistoryBackendNotifier:
770 void NotifyFaviconsChanged(const std::set<GURL>& page_urls, 771 void NotifyFaviconsChanged(const std::set<GURL>& page_urls,
771 const GURL& icon_url) override; 772 const GURL& icon_url) override;
772 void NotifyURLVisited(ui::PageTransition transition, 773 void NotifyURLVisited(ui::PageTransition transition,
773 const URLRow& row, 774 const URLRow& row,
774 const RedirectList& redirects, 775 const RedirectList& redirects,
775 base::Time visit_time) override; 776 base::Time visit_time) override;
776 void NotifyURLsModified(const URLRows& rows) override; 777 void NotifyURLsModified(const URLRows& rows) override;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 890
890 // List of observers 891 // List of observers
891 base::ObserverList<HistoryBackendObserver> observers_; 892 base::ObserverList<HistoryBackendObserver> observers_;
892 893
893 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 894 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
894 }; 895 };
895 896
896 } // namespace history 897 } // namespace history
897 898
898 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ 899 #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