| 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_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_H_ |
| 6 #define CHROME_BROWSER_HISTORY_HISTORY_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/observer_list_threadsafe.h" | 17 #include "base/observer_list_threadsafe.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h" |
| 19 #include "chrome/browser/cancelable_request.h" | 19 #include "chrome/browser/cancelable_request.h" |
| 20 #include "chrome/browser/favicon/favicon_service.h" | 20 #include "chrome/browser/favicon/favicon_service.h" |
| 21 #include "chrome/browser/history/history_types.h" | 21 #include "chrome/browser/history/history_types.h" |
| 22 #include "chrome/browser/search_engines/template_url_id.h" | 22 #include "chrome/browser/search_engines/template_url_id.h" |
| 23 #include "chrome/common/ref_counted_util.h" | 23 #include "chrome/common/ref_counted_util.h" |
| 24 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
| 25 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
| 26 #include "content/public/common/page_transition_types.h" | 26 #include "content/public/common/page_transition_types.h" |
| 27 #include "sql/init_status.h" | 27 #include "sql/init_status.h" |
| 28 | 28 |
| 29 #if defined(OS_ANDROID) |
| 30 #include "chrome/browser/history/android/android_history_provider_service.h" |
| 31 #endif |
| 32 |
| 29 class BookmarkService; | 33 class BookmarkService; |
| 30 class FilePath; | 34 class FilePath; |
| 31 class GURL; | 35 class GURL; |
| 32 class HistoryURLProvider; | 36 class HistoryURLProvider; |
| 33 struct HistoryURLProviderParams; | 37 struct HistoryURLProviderParams; |
| 34 class PageUsageData; | 38 class PageUsageData; |
| 35 class PageUsageRequest; | 39 class PageUsageRequest; |
| 36 class Profile; | 40 class Profile; |
| 37 | 41 |
| 38 namespace base { | 42 namespace base { |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 // These are not currently used, hopefully we can do something in the future | 617 // These are not currently used, hopefully we can do something in the future |
| 614 // to ensure that the most important things happen first. | 618 // to ensure that the most important things happen first. |
| 615 enum SchedulePriority { | 619 enum SchedulePriority { |
| 616 PRIORITY_UI, // The highest priority (must respond to UI events). | 620 PRIORITY_UI, // The highest priority (must respond to UI events). |
| 617 PRIORITY_NORMAL, // Normal stuff like adding a page. | 621 PRIORITY_NORMAL, // Normal stuff like adding a page. |
| 618 PRIORITY_LOW, // Low priority things like indexing or expiration. | 622 PRIORITY_LOW, // Low priority things like indexing or expiration. |
| 619 }; | 623 }; |
| 620 | 624 |
| 621 private: | 625 private: |
| 622 class BackendDelegate; | 626 class BackendDelegate; |
| 627 #if defined(OS_ANDROID) |
| 628 friend class AndroidHistoryProviderService; |
| 629 #endif |
| 623 friend class base::RefCountedThreadSafe<HistoryService>; | 630 friend class base::RefCountedThreadSafe<HistoryService>; |
| 624 friend class BackendDelegate; | 631 friend class BackendDelegate; |
| 625 friend class FaviconService; | 632 friend class FaviconService; |
| 626 friend class history::HistoryBackend; | 633 friend class history::HistoryBackend; |
| 627 friend class history::HistoryQueryTest; | 634 friend class history::HistoryQueryTest; |
| 628 friend class HistoryOperation; | 635 friend class HistoryOperation; |
| 629 friend class HistoryURLProvider; | 636 friend class HistoryURLProvider; |
| 630 friend class HistoryURLProviderTest; | 637 friend class HistoryURLProviderTest; |
| 631 friend class history::InMemoryURLIndexTest; | 638 friend class history::InMemoryURLIndexTest; |
| 632 template<typename Info, typename Callback> friend class DownloadRequest; | 639 template<typename Info, typename Callback> friend class DownloadRequest; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 DCHECK(thread_) << "History service being called after cleanup"; | 806 DCHECK(thread_) << "History service being called after cleanup"; |
| 800 LoadBackendIfNecessary(); | 807 LoadBackendIfNecessary(); |
| 801 if (consumer) | 808 if (consumer) |
| 802 AddRequest(request, consumer); | 809 AddRequest(request, consumer); |
| 803 ScheduleTask(priority, | 810 ScheduleTask(priority, |
| 804 base::Bind(func, history_backend_.get(), | 811 base::Bind(func, history_backend_.get(), |
| 805 scoped_refptr<RequestType>(request), a, b, c)); | 812 scoped_refptr<RequestType>(request), a, b, c)); |
| 806 return request->handle(); | 813 return request->handle(); |
| 807 } | 814 } |
| 808 | 815 |
| 816 template<typename BackendFunc, |
| 817 class RequestType, // Descendant of CancelableRequstBase. |
| 818 typename ArgA, |
| 819 typename ArgB, |
| 820 typename ArgC, |
| 821 typename ArgD> |
| 822 Handle Schedule(SchedulePriority priority, |
| 823 BackendFunc func, // Function to call on the HistoryBackend. |
| 824 CancelableRequestConsumerBase* consumer, |
| 825 RequestType* request, |
| 826 const ArgA& a, |
| 827 const ArgB& b, |
| 828 const ArgC& c, |
| 829 const ArgD& d) { |
| 830 DCHECK(thread_) << "History service being called after cleanup"; |
| 831 LoadBackendIfNecessary(); |
| 832 if (consumer) |
| 833 AddRequest(request, consumer); |
| 834 ScheduleTask(priority, |
| 835 base::Bind(func, history_backend_.get(), |
| 836 scoped_refptr<RequestType>(request), |
| 837 a, b, c, d)); |
| 838 return request->handle(); |
| 839 } |
| 840 |
| 809 // ScheduleAndForget --------------------------------------------------------- | 841 // ScheduleAndForget --------------------------------------------------------- |
| 810 // | 842 // |
| 811 // Functions for scheduling operations on the history thread that do not need | 843 // Functions for scheduling operations on the history thread that do not need |
| 812 // any callbacks and are not cancelable. | 844 // any callbacks and are not cancelable. |
| 813 | 845 |
| 814 template<typename BackendFunc> | 846 template<typename BackendFunc> |
| 815 void ScheduleAndForget(SchedulePriority priority, | 847 void ScheduleAndForget(SchedulePriority priority, |
| 816 BackendFunc func) { // Function to call on backend. | 848 BackendFunc func) { // Function to call on backend. |
| 817 DCHECK(thread_) << "History service being called after cleanup"; | 849 DCHECK(thread_) << "History service being called after cleanup"; |
| 818 LoadBackendIfNecessary(); | 850 LoadBackendIfNecessary(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 // The index used for quick history lookups. | 943 // The index used for quick history lookups. |
| 912 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; | 944 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; |
| 913 | 945 |
| 914 scoped_refptr<ObserverListThreadSafe<history::VisitDatabaseObserver> > | 946 scoped_refptr<ObserverListThreadSafe<history::VisitDatabaseObserver> > |
| 915 visit_database_observers_; | 947 visit_database_observers_; |
| 916 | 948 |
| 917 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 949 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
| 918 }; | 950 }; |
| 919 | 951 |
| 920 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ | 952 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ |
| OLD | NEW |