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 COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ |
6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 void RemoveObserver(HistoryServiceObserver* observer); | 451 void RemoveObserver(HistoryServiceObserver* observer); |
452 | 452 |
453 // Generic Stuff ------------------------------------------------------------- | 453 // Generic Stuff ------------------------------------------------------------- |
454 | 454 |
455 // Schedules a HistoryDBTask for running on the history backend thread. See | 455 // Schedules a HistoryDBTask for running on the history backend thread. See |
456 // HistoryDBTask for details on what this does. Takes ownership of |task|. | 456 // HistoryDBTask for details on what this does. Takes ownership of |task|. |
457 virtual base::CancelableTaskTracker::TaskId ScheduleDBTask( | 457 virtual base::CancelableTaskTracker::TaskId ScheduleDBTask( |
458 scoped_ptr<HistoryDBTask> task, | 458 scoped_ptr<HistoryDBTask> task, |
459 base::CancelableTaskTracker* tracker); | 459 base::CancelableTaskTracker* tracker); |
460 | 460 |
461 // This callback is invoked when favicon change for urls. | 461 // Callback for when favicon data changes. The first std::vector contains a |
sky
2015/06/19 16:38:02
Is there a reason why these are vectors and not se
pkotwicz
2015/06/21 22:16:09
I used std::vectors because we do not call std::se
| |
462 typedef base::Callback<void(const std::set<GURL>&)> OnFaviconChangedCallback; | 462 // list of page URLs for which the favicon data has changed. The second |
463 // std::vector contains a list of icon URLs for which the favicon data has | |
464 // changed. | |
465 typedef base::Callback<void(const std::vector<GURL>&, | |
466 const std::vector<GURL>&)> | |
467 OnFaviconsChangedCallback; | |
463 | 468 |
464 // Add a callback to the list. The callback will remain registered until the | 469 // Add a callback to the list. The callback will remain registered until the |
465 // returned Subscription is destroyed. This must occurs before HistoryService | 470 // returned Subscription is destroyed. The Subscription must be destroyed |
466 // is destroyed. | 471 // before HistoryService is destroyed. |
467 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription> | 472 scoped_ptr<base::CallbackList<void(const std::vector<GURL>&, |
468 AddFaviconChangedCallback(const OnFaviconChangedCallback& callback) | 473 const std::vector<GURL>&)>::Subscription> |
474 AddFaviconsChangedCallback(const OnFaviconsChangedCallback& callback) | |
469 WARN_UNUSED_RESULT; | 475 WARN_UNUSED_RESULT; |
470 | 476 |
471 // Testing ------------------------------------------------------------------- | 477 // Testing ------------------------------------------------------------------- |
472 | 478 |
473 // Runs |flushed| after bouncing off the history thread. | 479 // Runs |flushed| after bouncing off the history thread. |
474 void FlushForTest(const base::Closure& flushed); | 480 void FlushForTest(const base::Closure& flushed); |
475 | 481 |
476 // Designed for unit tests, this passes the given task on to the history | 482 // Designed for unit tests, this passes the given task on to the history |
477 // backend to be called once the history backend has terminated. This allows | 483 // backend to be called once the history backend has terminated. This allows |
478 // callers to know when the history thread is complete and the database files | 484 // callers to know when the history thread is complete and the database files |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
773 // database is loaded to make it available. | 779 // database is loaded to make it available. |
774 void SetInMemoryBackend(scoped_ptr<InMemoryHistoryBackend> mem_backend); | 780 void SetInMemoryBackend(scoped_ptr<InMemoryHistoryBackend> mem_backend); |
775 | 781 |
776 // Called by our BackendDelegate when there is a problem reading the database. | 782 // Called by our BackendDelegate when there is a problem reading the database. |
777 void NotifyProfileError(sql::InitStatus init_status); | 783 void NotifyProfileError(sql::InitStatus init_status); |
778 | 784 |
779 // Call to schedule a given task for running on the history thread with the | 785 // Call to schedule a given task for running on the history thread with the |
780 // specified priority. The task will have ownership taken. | 786 // specified priority. The task will have ownership taken. |
781 void ScheduleTask(SchedulePriority priority, const base::Closure& task); | 787 void ScheduleTask(SchedulePriority priority, const base::Closure& task); |
782 | 788 |
783 // Invokes all callback registered by AddFaviconChangedCallback. | 789 // Called when the favicons for the given page URLs (e.g. |
784 void NotifyFaviconChanged(const std::set<GURL>& changed_favicons); | 790 // http://www.google.com) and the given icon URLs (e.g. |
791 // http://www.google.com/favicon.ico) have changed. | |
792 void NotifyFaviconsChanged(const std::vector<GURL>& page_urls, | |
793 const std::vector<GURL>& icon_urls); | |
785 | 794 |
786 base::ThreadChecker thread_checker_; | 795 base::ThreadChecker thread_checker_; |
787 | 796 |
788 // The thread used by the history service to run complicated operations. | 797 // The thread used by the history service to run complicated operations. |
789 // |thread_| is null once Cleanup() is called. | 798 // |thread_| is null once Cleanup() is called. |
790 base::Thread* thread_; | 799 base::Thread* thread_; |
791 | 800 |
792 // This class has most of the implementation and runs on the 'thread_'. | 801 // This class has most of the implementation and runs on the 'thread_'. |
793 // You MUST communicate with this class ONLY through the thread_'s | 802 // You MUST communicate with this class ONLY through the thread_'s |
794 // message_loop(). | 803 // message_loop(). |
(...skipping 14 matching lines...) Expand all Loading... | |
809 | 818 |
810 // The history client, may be null when testing. The object should otherwise | 819 // The history client, may be null when testing. The object should otherwise |
811 // outlive |HistoryService|. | 820 // outlive |HistoryService|. |
812 HistoryClient* history_client_; | 821 HistoryClient* history_client_; |
813 | 822 |
814 // Has the backend finished loading? The backend is loaded once Init has | 823 // Has the backend finished loading? The backend is loaded once Init has |
815 // completed. | 824 // completed. |
816 bool backend_loaded_; | 825 bool backend_loaded_; |
817 | 826 |
818 base::ObserverList<HistoryServiceObserver> observers_; | 827 base::ObserverList<HistoryServiceObserver> observers_; |
819 base::CallbackList<void(const std::set<GURL>&)> | 828 base::CallbackList<void(const std::vector<GURL>&, const std::vector<GURL>&)> |
820 favicon_changed_callback_list_; | 829 favicon_changed_callback_list_; |
821 | 830 |
822 DeleteDirectiveHandler delete_directive_handler_; | 831 DeleteDirectiveHandler delete_directive_handler_; |
823 | 832 |
824 // All vended weak pointers are invalidated in Cleanup(). | 833 // All vended weak pointers are invalidated in Cleanup(). |
825 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; | 834 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; |
826 | 835 |
827 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 836 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
828 }; | 837 }; |
829 | 838 |
830 } // namespace history | 839 } // namespace history |
831 | 840 |
832 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ | 841 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ |
OLD | NEW |