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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 // Called by our BackendDelegate when there is a problem reading the database. | 779 // Called by our BackendDelegate when there is a problem reading the database. |
780 void NotifyProfileError(sql::InitStatus init_status); | 780 void NotifyProfileError(sql::InitStatus init_status); |
781 | 781 |
782 // Call to schedule a given task for running on the history thread with the | 782 // Call to schedule a given task for running on the history thread with the |
783 // specified priority. The task will have ownership taken. | 783 // specified priority. The task will have ownership taken. |
784 void ScheduleTask(SchedulePriority priority, const base::Closure& task); | 784 void ScheduleTask(SchedulePriority priority, const base::Closure& task); |
785 | 785 |
786 // Invokes all callback registered by AddFaviconChangedCallback. | 786 // Invokes all callback registered by AddFaviconChangedCallback. |
787 void NotifyFaviconChanged(const std::set<GURL>& changed_favicons); | 787 void NotifyFaviconChanged(const std::set<GURL>& changed_favicons); |
788 | 788 |
789 // ScheduleAndForget --------------------------------------------------------- | |
790 // | |
791 // Functions for scheduling operations on the history thread that do not need | |
792 // any callbacks and are not cancelable. | |
793 | |
794 template<typename BackendFunc> | |
795 void ScheduleAndForget(SchedulePriority priority, | |
796 BackendFunc func) { // Function to call on backend. | |
797 DCHECK(thread_) << "History service being called after cleanup"; | |
798 DCHECK(thread_checker_.CalledOnValidThread()); | |
799 ScheduleTask(priority, base::Bind(func, history_backend_.get())); | |
800 } | |
801 | |
802 template<typename BackendFunc, typename ArgA> | |
803 void ScheduleAndForget(SchedulePriority priority, | |
804 BackendFunc func, // Function to call on backend. | |
805 const ArgA& a) { | |
806 DCHECK(thread_) << "History service being called after cleanup"; | |
807 DCHECK(thread_checker_.CalledOnValidThread()); | |
808 ScheduleTask(priority, base::Bind(func, history_backend_.get(), a)); | |
809 } | |
810 | |
811 template<typename BackendFunc, typename ArgA, typename ArgB> | |
812 void ScheduleAndForget(SchedulePriority priority, | |
813 BackendFunc func, // Function to call on backend. | |
814 const ArgA& a, | |
815 const ArgB& b) { | |
816 DCHECK(thread_) << "History service being called after cleanup"; | |
817 DCHECK(thread_checker_.CalledOnValidThread()); | |
818 ScheduleTask(priority, base::Bind(func, history_backend_.get(), a, b)); | |
819 } | |
820 | |
821 template<typename BackendFunc, typename ArgA, typename ArgB, typename ArgC> | |
822 void ScheduleAndForget(SchedulePriority priority, | |
823 BackendFunc func, // Function to call on backend. | |
824 const ArgA& a, | |
825 const ArgB& b, | |
826 const ArgC& c) { | |
827 DCHECK(thread_) << "History service being called after cleanup"; | |
828 DCHECK(thread_checker_.CalledOnValidThread()); | |
829 ScheduleTask(priority, base::Bind(func, history_backend_.get(), a, b, c)); | |
830 } | |
831 | |
832 template<typename BackendFunc, | |
833 typename ArgA, | |
834 typename ArgB, | |
835 typename ArgC, | |
836 typename ArgD> | |
837 void ScheduleAndForget(SchedulePriority priority, | |
838 BackendFunc func, // Function to call on backend. | |
839 const ArgA& a, | |
840 const ArgB& b, | |
841 const ArgC& c, | |
842 const ArgD& d) { | |
843 DCHECK(thread_) << "History service being called after cleanup"; | |
844 DCHECK(thread_checker_.CalledOnValidThread()); | |
845 ScheduleTask(priority, base::Bind(func, history_backend_.get(), | |
846 a, b, c, d)); | |
847 } | |
848 | |
849 template<typename BackendFunc, | |
850 typename ArgA, | |
851 typename ArgB, | |
852 typename ArgC, | |
853 typename ArgD, | |
854 typename ArgE> | |
855 void ScheduleAndForget(SchedulePriority priority, | |
856 BackendFunc func, // Function to call on backend. | |
857 const ArgA& a, | |
858 const ArgB& b, | |
859 const ArgC& c, | |
860 const ArgD& d, | |
861 const ArgE& e) { | |
862 DCHECK(thread_) << "History service being called after cleanup"; | |
863 DCHECK(thread_checker_.CalledOnValidThread()); | |
864 ScheduleTask(priority, base::Bind(func, history_backend_.get(), | |
865 a, b, c, d, e)); | |
866 } | |
867 | |
868 base::ThreadChecker thread_checker_; | 789 base::ThreadChecker thread_checker_; |
869 | 790 |
870 // The thread used by the history service to run complicated operations. | 791 // The thread used by the history service to run complicated operations. |
871 // |thread_| is NULL once |Cleanup| is NULL. | 792 // |thread_| is NULL once |Cleanup| is NULL. |
872 base::Thread* thread_; | 793 base::Thread* thread_; |
873 | 794 |
874 // This class has most of the implementation and runs on the 'thread_'. | 795 // This class has most of the implementation and runs on the 'thread_'. |
875 // You MUST communicate with this class ONLY through the thread_'s | 796 // You MUST communicate with this class ONLY through the thread_'s |
876 // message_loop(). | 797 // message_loop(). |
877 // | 798 // |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 | 836 |
916 history::DeleteDirectiveHandler delete_directive_handler_; | 837 history::DeleteDirectiveHandler delete_directive_handler_; |
917 | 838 |
918 // All vended weak pointers are invalidated in Cleanup(). | 839 // All vended weak pointers are invalidated in Cleanup(). |
919 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; | 840 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; |
920 | 841 |
921 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 842 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
922 }; | 843 }; |
923 | 844 |
924 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 845 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
OLD | NEW |