Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: chrome/browser/history/history.h

Issue 10217010: Completed the code path from AndroidProviderService to HistoryBackend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Init Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string16.h" 17 #include "base/string16.h"
18 #include "chrome/browser/cancelable_request.h" 18 #include "chrome/browser/cancelable_request.h"
19 #include "chrome/browser/favicon/favicon_service.h" 19 #include "chrome/browser/favicon/favicon_service.h"
20 #include "chrome/browser/history/history_types.h" 20 #include "chrome/browser/history/history_types.h"
21 #include "chrome/browser/search_engines/template_url_id.h" 21 #include "chrome/browser/search_engines/template_url_id.h"
22 #include "chrome/common/ref_counted_util.h" 22 #include "chrome/common/ref_counted_util.h"
23 #include "content/public/browser/notification_observer.h" 23 #include "content/public/browser/notification_observer.h"
24 #include "content/public/browser/notification_registrar.h" 24 #include "content/public/browser/notification_registrar.h"
25 #include "content/public/common/page_transition_types.h" 25 #include "content/public/common/page_transition_types.h"
26 #include "sql/init_status.h" 26 #include "sql/init_status.h"
27 27
28 #if defined(OS_ANDROID)
29 #include "chrome/browser/android_provider_service.h"
30 #endif
31
28 class BookmarkService; 32 class BookmarkService;
29 class FilePath; 33 class FilePath;
30 class GURL; 34 class GURL;
31 class HistoryURLProvider; 35 class HistoryURLProvider;
32 struct HistoryURLProviderParams; 36 struct HistoryURLProviderParams;
33 class PageUsageData; 37 class PageUsageData;
34 class PageUsageRequest; 38 class PageUsageRequest;
35 class Profile; 39 class Profile;
36 40
37 namespace base { 41 namespace base {
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // These are not currently used, hopefully we can do something in the future 604 // These are not currently used, hopefully we can do something in the future
601 // to ensure that the most important things happen first. 605 // to ensure that the most important things happen first.
602 enum SchedulePriority { 606 enum SchedulePriority {
603 PRIORITY_UI, // The highest priority (must respond to UI events). 607 PRIORITY_UI, // The highest priority (must respond to UI events).
604 PRIORITY_NORMAL, // Normal stuff like adding a page. 608 PRIORITY_NORMAL, // Normal stuff like adding a page.
605 PRIORITY_LOW, // Low priority things like indexing or expiration. 609 PRIORITY_LOW, // Low priority things like indexing or expiration.
606 }; 610 };
607 611
608 private: 612 private:
609 class BackendDelegate; 613 class BackendDelegate;
614 #if defined(OS_ANDROID)
615 friend class AndroidProviderService;
616 #endif
610 friend class base::RefCountedThreadSafe<HistoryService>; 617 friend class base::RefCountedThreadSafe<HistoryService>;
611 friend class BackendDelegate; 618 friend class BackendDelegate;
612 friend class FaviconService; 619 friend class FaviconService;
613 friend class history::HistoryBackend; 620 friend class history::HistoryBackend;
614 friend class history::HistoryQueryTest; 621 friend class history::HistoryQueryTest;
615 friend class HistoryOperation; 622 friend class HistoryOperation;
616 friend class HistoryURLProvider; 623 friend class HistoryURLProvider;
617 friend class HistoryURLProviderTest; 624 friend class HistoryURLProviderTest;
618 friend class history::InMemoryURLIndexTest; 625 friend class history::InMemoryURLIndexTest;
619 template<typename Info, typename Callback> friend class DownloadRequest; 626 template<typename Info, typename Callback> friend class DownloadRequest;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 DCHECK(thread_) << "History service being called after cleanup"; 793 DCHECK(thread_) << "History service being called after cleanup";
787 LoadBackendIfNecessary(); 794 LoadBackendIfNecessary();
788 if (consumer) 795 if (consumer)
789 AddRequest(request, consumer); 796 AddRequest(request, consumer);
790 ScheduleTask(priority, 797 ScheduleTask(priority,
791 base::Bind(func, history_backend_.get(), 798 base::Bind(func, history_backend_.get(),
792 scoped_refptr<RequestType>(request), a, b, c)); 799 scoped_refptr<RequestType>(request), a, b, c));
793 return request->handle(); 800 return request->handle();
794 } 801 }
795 802
803 template<typename BackendFunc,
804 class RequestType, // Descendant of CancelableRequstBase.
805 typename ArgA,
806 typename ArgB,
807 typename ArgC,
808 typename ArgD>
809 Handle Schedule(SchedulePriority priority,
810 BackendFunc func, // Function to call on the HistoryBackend.
811 CancelableRequestConsumerBase* consumer,
812 RequestType* request,
813 const ArgA& a,
814 const ArgB& b,
815 const ArgC& c,
816 const ArgD& d) {
817 DCHECK(thread_) << "History service being called after cleanup";
818 LoadBackendIfNecessary();
819 if (consumer)
820 AddRequest(request, consumer);
821 ScheduleTask(priority,
822 base::Bind(func, history_backend_.get(),
823 scoped_refptr<RequestType>(request),
824 a, b, c, d));
825 return request->handle();
826 }
827
796 // ScheduleAndForget --------------------------------------------------------- 828 // ScheduleAndForget ---------------------------------------------------------
797 // 829 //
798 // Functions for scheduling operations on the history thread that do not need 830 // Functions for scheduling operations on the history thread that do not need
799 // any callbacks and are not cancelable. 831 // any callbacks and are not cancelable.
800 832
801 template<typename BackendFunc> 833 template<typename BackendFunc>
802 void ScheduleAndForget(SchedulePriority priority, 834 void ScheduleAndForget(SchedulePriority priority,
803 BackendFunc func) { // Function to call on backend. 835 BackendFunc func) { // Function to call on backend.
804 DCHECK(thread_) << "History service being called after cleanup"; 836 DCHECK(thread_) << "History service being called after cleanup";
805 LoadBackendIfNecessary(); 837 LoadBackendIfNecessary();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 const ArgA& a, 878 const ArgA& a,
847 const ArgB& b, 879 const ArgB& b,
848 const ArgC& c, 880 const ArgC& c,
849 const ArgD& d) { 881 const ArgD& d) {
850 DCHECK(thread_) << "History service being called after cleanup"; 882 DCHECK(thread_) << "History service being called after cleanup";
851 LoadBackendIfNecessary(); 883 LoadBackendIfNecessary();
852 ScheduleTask(priority, base::Bind(func, history_backend_.get(), 884 ScheduleTask(priority, base::Bind(func, history_backend_.get(),
853 a, b, c, d)); 885 a, b, c, d));
854 } 886 }
855 887
888 #if defined(OS_ANDROID)
sky 2012/04/25 15:57:25 Why do any of these methods need to be here? If yo
michaelbai 2012/04/26 05:32:48 I followed the pattern of the FaviconService, if y
sky 2012/04/27 21:37:22 I would rather put them in AndroidHistoryProviderS
889 // Android Provider ---------------------------------------------------------
890 //
891 // These Android provider related methods are exposed to the
892 // AndroidProviderService. Instead of calling these methods directly you
893 // should call the respective method on the AndroidProviderService.
894
895 // Used by the AndroidProviderService to add the history and the bookmarks.
896 void InsertHistoryAndBookmark(
897 AndroidProviderService::InsertRequest* request,
898 const history::HistoryAndBookmarkRow& row);
899
900 // Used by the AndroidProviderService to query the history and the bookmarks.
901 void QueryHistoryAndBookmarks(
902 AndroidProviderService::QueryRequest* request,
903 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections,
904 const std::string& selection,
905 const std::vector<string16>& selection_args,
906 const std::string& sort_order);
907
908 // Used by the AndroidProviderService to update the history and the bookmarks.
909 void UpdateHistoryAndBookmarks(
910 AndroidProviderService::UpdateRequest* request,
911 const history::HistoryAndBookmarkRow& row,
912 const std::string& selection,
913 const std::vector<string16>& selection_args);
914
915 // Used by the AndroidProviderService to delete the history and the bookmarks.
916 void DeleteHistoryAndBookmarks(
917 AndroidProviderService::DeleteRequest* request,
918 const std::string& selection,
919 const std::vector<string16>& selection_args);
920
921 // Used by the AndroidProviderService to delete the history.
922 void DeleteHistory(AndroidProviderService::DeleteRequest* request,
923 const std::string& selection,
924 const std::vector<string16>& selection_args);
925
926 // Used by the AndroidProviderService to move the given |statement|'s current
927 // row to |destination|.
928 void MoveStatement(AndroidProviderService::MoveStatementRequest* request,
929 history::AndroidStatement* statement,
930 int current_pos,
931 int destination);
932
933 // Used by the AndroidProviderService to close the statement in db thread.
934 void CloseStatement(history::AndroidStatement* statement);
935
936 // Used by the AndroidProviderService to add the search term.
937 void InsertSearchTerm(AndroidProviderService::InsertRequest* request,
938 const history::SearchRow& row);
939
940 // Used by the AndroidProviderService to update the search terms.
941 void UpdateSearchTerms(AndroidProviderService::UpdateRequest* request,
942 const history::SearchRow& row,
943 const std::string& selection,
944 const std::vector<string16>& selection_arg);
945
946 // Used by the AndroidProviderService to delete the search terms.
947 void DeleteSearchTerms(AndroidProviderService::DeleteRequest* request,
948 const std::string& selection,
sky 2012/04/25 15:57:25 spacing is off
michaelbai 2012/04/26 05:32:48 Done.
949 const std::vector<string16>& selection_arg);
950
951 // Used by the AndroidProviderService to query the search terms.
952 void QuerySearchTerms(
953 AndroidProviderService::QueryRequest* request,
954 const std::vector<history::SearchRow::ColumnID>& projections,
955 const std::string& selection,
956 const std::vector<string16>& selection_args,
957 const std::string& sort_order);
958
959 #endif // defined(OS_ANDROID)
960
856 content::NotificationRegistrar registrar_; 961 content::NotificationRegistrar registrar_;
857 962
858 // Some void primitives require some internal processing in the main thread 963 // Some void primitives require some internal processing in the main thread
859 // when done. We use this internal consumer for this purpose. 964 // when done. We use this internal consumer for this purpose.
860 CancelableRequestConsumer internal_consumer_; 965 CancelableRequestConsumer internal_consumer_;
861 966
862 // The thread used by the history service to run complicated operations. 967 // The thread used by the history service to run complicated operations.
863 // |thread_| is NULL once |Cleanup| is NULL. 968 // |thread_| is NULL once |Cleanup| is NULL.
864 base::Thread* thread_; 969 base::Thread* thread_;
865 970
(...skipping 29 matching lines...) Expand all
895 // True if needs top site migration. 1000 // True if needs top site migration.
896 bool needs_top_sites_migration_; 1001 bool needs_top_sites_migration_;
897 1002
898 // The index used for quick history lookups. 1003 // The index used for quick history lookups.
899 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; 1004 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_;
900 1005
901 DISALLOW_COPY_AND_ASSIGN(HistoryService); 1006 DISALLOW_COPY_AND_ASSIGN(HistoryService);
902 }; 1007 };
903 1008
904 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ 1009 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698