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. Contains a std::set of page URLs |
462 typedef base::Callback<void(const std::set<GURL>&)> OnFaviconChangedCallback; | 462 // (e.g. http://www.google.com) for which the favicon data has changed and the |
| 463 // icon URL (e.g. http://www.google.com/favicon.ico) for which the favicon |
| 464 // data has changed. It is valid to call the callback with non-empty |
| 465 // "page URLs" and no "icon URL" and vice versa. |
| 466 typedef base::Callback<void(const std::set<GURL>&, const 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::set<GURL>&, |
468 AddFaviconChangedCallback(const OnFaviconChangedCallback& callback) | 473 const 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 URL (e.g. |
| 791 // http://www.google.com/favicon.ico) have changed. It is valid to call |
| 792 // NotifyFaviconsChanged() with non-empty |page_urls| and an empty |icon_url| |
| 793 // and vice versa. |
| 794 void NotifyFaviconsChanged(const std::set<GURL>& page_urls, |
| 795 const GURL& icon_url); |
785 | 796 |
786 base::ThreadChecker thread_checker_; | 797 base::ThreadChecker thread_checker_; |
787 | 798 |
788 // The thread used by the history service to run complicated operations. | 799 // The thread used by the history service to run complicated operations. |
789 // |thread_| is null once Cleanup() is called. | 800 // |thread_| is null once Cleanup() is called. |
790 base::Thread* thread_; | 801 base::Thread* thread_; |
791 | 802 |
792 // This class has most of the implementation and runs on the 'thread_'. | 803 // This class has most of the implementation and runs on the 'thread_'. |
793 // You MUST communicate with this class ONLY through the thread_'s | 804 // You MUST communicate with this class ONLY through the thread_'s |
794 // message_loop(). | 805 // message_loop(). |
(...skipping 13 matching lines...) Expand all Loading... |
808 | 819 |
809 // The history service will inform its VisitDelegate of URLs recorded and | 820 // The history service will inform its VisitDelegate of URLs recorded and |
810 // removed from the history database. This may be null during testing. | 821 // removed from the history database. This may be null during testing. |
811 scoped_ptr<VisitDelegate> visit_delegate_; | 822 scoped_ptr<VisitDelegate> visit_delegate_; |
812 | 823 |
813 // Has the backend finished loading? The backend is loaded once Init has | 824 // Has the backend finished loading? The backend is loaded once Init has |
814 // completed. | 825 // completed. |
815 bool backend_loaded_; | 826 bool backend_loaded_; |
816 | 827 |
817 base::ObserverList<HistoryServiceObserver> observers_; | 828 base::ObserverList<HistoryServiceObserver> observers_; |
818 base::CallbackList<void(const std::set<GURL>&)> | 829 base::CallbackList<void(const std::set<GURL>&, const GURL&)> |
819 favicon_changed_callback_list_; | 830 favicon_changed_callback_list_; |
820 | 831 |
821 DeleteDirectiveHandler delete_directive_handler_; | 832 DeleteDirectiveHandler delete_directive_handler_; |
822 | 833 |
823 // All vended weak pointers are invalidated in Cleanup(). | 834 // All vended weak pointers are invalidated in Cleanup(). |
824 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; | 835 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; |
825 | 836 |
826 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 837 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
827 }; | 838 }; |
828 | 839 |
829 } // namespace history | 840 } // namespace history |
830 | 841 |
831 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ | 842 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ |
OLD | NEW |