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::set contains a |
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::set contains a list of icon URLs for which the favicon data has |
| 464 // changed. |
| 465 typedef base::Callback<void(const std::set<GURL>&, const std::set<GURL>&)> |
| 466 OnFaviconsChangedCallback; |
463 | 467 |
464 // Add a callback to the list. The callback will remain registered until the | 468 // Add a callback to the list. The callback will remain registered until the |
465 // returned Subscription is destroyed. This must occurs before HistoryService | 469 // returned Subscription is destroyed. The Subscription must be destroyed |
466 // is destroyed. | 470 // before HistoryService is destroyed. |
467 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription> | 471 scoped_ptr<base::CallbackList<void(const std::set<GURL>&, |
468 AddFaviconChangedCallback(const OnFaviconChangedCallback& callback) | 472 const std::set<GURL>&)>::Subscription> |
| 473 AddFaviconsChangedCallback(const OnFaviconsChangedCallback& callback) |
469 WARN_UNUSED_RESULT; | 474 WARN_UNUSED_RESULT; |
470 | 475 |
471 // Testing ------------------------------------------------------------------- | 476 // Testing ------------------------------------------------------------------- |
472 | 477 |
473 // Runs |flushed| after bouncing off the history thread. | 478 // Runs |flushed| after bouncing off the history thread. |
474 void FlushForTest(const base::Closure& flushed); | 479 void FlushForTest(const base::Closure& flushed); |
475 | 480 |
476 // Designed for unit tests, this passes the given task on to the history | 481 // 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 | 482 // 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 | 483 // 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. | 778 // database is loaded to make it available. |
774 void SetInMemoryBackend(scoped_ptr<InMemoryHistoryBackend> mem_backend); | 779 void SetInMemoryBackend(scoped_ptr<InMemoryHistoryBackend> mem_backend); |
775 | 780 |
776 // Called by our BackendDelegate when there is a problem reading the database. | 781 // Called by our BackendDelegate when there is a problem reading the database. |
777 void NotifyProfileError(sql::InitStatus init_status); | 782 void NotifyProfileError(sql::InitStatus init_status); |
778 | 783 |
779 // Call to schedule a given task for running on the history thread with the | 784 // Call to schedule a given task for running on the history thread with the |
780 // specified priority. The task will have ownership taken. | 785 // specified priority. The task will have ownership taken. |
781 void ScheduleTask(SchedulePriority priority, const base::Closure& task); | 786 void ScheduleTask(SchedulePriority priority, const base::Closure& task); |
782 | 787 |
783 // Invokes all callback registered by AddFaviconChangedCallback. | 788 // Called when the favicons for the given page URLs (e.g. |
784 void NotifyFaviconChanged(const std::set<GURL>& changed_favicons); | 789 // http://www.google.com) and the given icon URLs (e.g. |
| 790 // http://www.google.com/favicon.ico) have changed. |
| 791 void NotifyFaviconsChanged(const std::set<GURL>& page_urls, |
| 792 const std::set<GURL>& icon_urls); |
785 | 793 |
786 base::ThreadChecker thread_checker_; | 794 base::ThreadChecker thread_checker_; |
787 | 795 |
788 // The thread used by the history service to run complicated operations. | 796 // The thread used by the history service to run complicated operations. |
789 // |thread_| is null once Cleanup() is called. | 797 // |thread_| is null once Cleanup() is called. |
790 base::Thread* thread_; | 798 base::Thread* thread_; |
791 | 799 |
792 // This class has most of the implementation and runs on the 'thread_'. | 800 // This class has most of the implementation and runs on the 'thread_'. |
793 // You MUST communicate with this class ONLY through the thread_'s | 801 // You MUST communicate with this class ONLY through the thread_'s |
794 // message_loop(). | 802 // message_loop(). |
(...skipping 14 matching lines...) Expand all Loading... |
809 | 817 |
810 // The history client, may be null when testing. The object should otherwise | 818 // The history client, may be null when testing. The object should otherwise |
811 // outlive |HistoryService|. | 819 // outlive |HistoryService|. |
812 HistoryClient* history_client_; | 820 HistoryClient* history_client_; |
813 | 821 |
814 // Has the backend finished loading? The backend is loaded once Init has | 822 // Has the backend finished loading? The backend is loaded once Init has |
815 // completed. | 823 // completed. |
816 bool backend_loaded_; | 824 bool backend_loaded_; |
817 | 825 |
818 base::ObserverList<HistoryServiceObserver> observers_; | 826 base::ObserverList<HistoryServiceObserver> observers_; |
819 base::CallbackList<void(const std::set<GURL>&)> | 827 base::CallbackList<void(const std::set<GURL>&, const std::set<GURL>&)> |
820 favicon_changed_callback_list_; | 828 favicon_changed_callback_list_; |
821 | 829 |
822 DeleteDirectiveHandler delete_directive_handler_; | 830 DeleteDirectiveHandler delete_directive_handler_; |
823 | 831 |
824 // All vended weak pointers are invalidated in Cleanup(). | 832 // All vended weak pointers are invalidated in Cleanup(). |
825 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; | 833 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; |
826 | 834 |
827 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 835 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
828 }; | 836 }; |
829 | 837 |
830 } // namespace history | 838 } // namespace history |
831 | 839 |
832 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ | 840 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ |
OLD | NEW |