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

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

Issue 285233012: Abstract history dependencies on bookmarks through HistoryClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests Created 6 years, 7 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
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_BACKEND_H_ 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/containers/mru_cache.h" 13 #include "base/containers/mru_cache.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/memory_pressure_listener.h" 16 #include "base/memory/memory_pressure_listener.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "chrome/browser/history/archived_database.h" 18 #include "chrome/browser/history/archived_database.h"
19 #include "chrome/browser/history/expire_history_backend.h" 19 #include "chrome/browser/history/expire_history_backend.h"
20 #include "chrome/browser/history/history_database.h" 20 #include "chrome/browser/history/history_database.h"
21 #include "chrome/browser/history/history_marshaling.h" 21 #include "chrome/browser/history/history_marshaling.h"
22 #include "chrome/browser/history/history_types.h" 22 #include "chrome/browser/history/history_types.h"
23 #include "chrome/browser/history/thumbnail_database.h" 23 #include "chrome/browser/history/thumbnail_database.h"
24 #include "chrome/browser/history/visit_tracker.h" 24 #include "chrome/browser/history/visit_tracker.h"
25 #include "chrome/browser/search_engines/template_url_id.h" 25 #include "chrome/browser/search_engines/template_url_id.h"
26 #include "sql/init_status.h" 26 #include "sql/init_status.h"
27 #include "ui/base/layout.h" 27 #include "ui/base/layout.h"
28 28
29 class BookmarkService;
30 class TestingProfile; 29 class TestingProfile;
31 class TypedUrlSyncableService; 30 class TypedUrlSyncableService;
32 struct ThumbnailScore; 31 struct ThumbnailScore;
33 32
34 namespace history { 33 namespace history {
35 #if defined(OS_ANDROID) 34 #if defined(OS_ANDROID)
36 class AndroidProviderBackend; 35 class AndroidProviderBackend;
37 #endif 36 #endif
38 37
39 class CommitLaterTask; 38 class CommitLaterTask;
39 class HistoryClient;
40 class VisitFilter; 40 class VisitFilter;
41 struct DownloadRow; 41 struct DownloadRow;
42 42
43 // The maximum number of icons URLs per page which can be stored in the 43 // The maximum number of icons URLs per page which can be stored in the
44 // thumbnail database. 44 // thumbnail database.
45 static const size_t kMaxFaviconsPerPage = 8; 45 static const size_t kMaxFaviconsPerPage = 8;
46 46
47 // The maximum number of bitmaps for a single icon URL which can be stored in 47 // The maximum number of bitmaps for a single icon URL which can be stored in
48 // the thumbnail database. 48 // the thumbnail database.
49 static const size_t kMaxFaviconBitmapsPerIconURL = 8; 49 static const size_t kMaxFaviconBitmapsPerIconURL = 8;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 }; 98 };
99 99
100 // Init must be called to complete object creation. This object can be 100 // Init must be called to complete object creation. This object can be
101 // constructed on any thread, but all other functions including Init() must 101 // constructed on any thread, but all other functions including Init() must
102 // be called on the history thread. 102 // be called on the history thread.
103 // 103 //
104 // |history_dir| is the directory where the history files will be placed. 104 // |history_dir| is the directory where the history files will be placed.
105 // See the definition of BroadcastNotificationsCallback above. This function 105 // See the definition of BroadcastNotificationsCallback above. This function
106 // takes ownership of the callback pointer. 106 // takes ownership of the callback pointer.
107 // 107 //
108 // |bookmark_service| is used to determine bookmarked URLs when deleting and 108 // |history_client| is used to determine bookmarked URLs when deleting and
109 // may be NULL. 109 // may be NULL.
110 // 110 //
111 // This constructor is fast and does no I/O, so can be called at any time. 111 // This constructor is fast and does no I/O, so can be called at any time.
112 HistoryBackend(const base::FilePath& history_dir, 112 HistoryBackend(const base::FilePath& history_dir,
113 Delegate* delegate, 113 Delegate* delegate,
114 BookmarkService* bookmark_service); 114 HistoryClient* history_client);
115 115
116 // Must be called after creation but before any objects are created. If this 116 // Must be called after creation but before any objects are created. If this
117 // fails, all other functions will fail as well. (Since this runs on another 117 // fails, all other functions will fail as well. (Since this runs on another
118 // thread, we don't bother returning failure.) 118 // thread, we don't bother returning failure.)
119 // 119 //
120 // |languages| gives a list of language encodings with which the history 120 // |languages| gives a list of language encodings with which the history
121 // URLs and omnibox searches are interpreted. 121 // URLs and omnibox searches are interpreted.
122 // |force_fail| can be set during unittests to unconditionally fail to init. 122 // |force_fail| can be set during unittests to unconditionally fail to init.
123 void Init(const std::string& languages, bool force_fail); 123 void Init(const std::string& languages, bool force_fail);
124 124
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 // Deletes all information in the history database, except for the supplied 789 // Deletes all information in the history database, except for the supplied
790 // set of URLs in the URL table (these should correspond to the bookmarked 790 // set of URLs in the URL table (these should correspond to the bookmarked
791 // URLs). 791 // URLs).
792 // 792 //
793 // The IDs of the URLs may change. 793 // The IDs of the URLs may change.
794 bool ClearAllMainHistory(const URLRows& kept_urls); 794 bool ClearAllMainHistory(const URLRows& kept_urls);
795 795
796 // Deletes the FTS index database files, which are no longer used. 796 // Deletes the FTS index database files, which are no longer used.
797 void DeleteFTSIndexDatabases(); 797 void DeleteFTSIndexDatabases();
798 798
799 // Returns the BookmarkService, blocking until it is loaded. This may return 799 // Returns the HistoryClient, blocking until it is loaded. This may return
800 // NULL during testing. 800 // NULL during testing.
801 BookmarkService* GetBookmarkService(); 801 HistoryClient* GetHistoryClient();
802 802
803 // Notify any observers of an addition to the visit database. 803 // Notify any observers of an addition to the visit database.
804 void NotifyVisitObservers(const VisitRow& visit); 804 void NotifyVisitObservers(const VisitRow& visit);
805 805
806 // Data ---------------------------------------------------------------------- 806 // Data ----------------------------------------------------------------------
807 807
808 // Delegate. See the class definition above for more information. This will 808 // Delegate. See the class definition above for more information. This will
809 // be NULL before Init is called and after Cleanup, but is guaranteed 809 // be NULL before Init is called and after Cleanup, but is guaranteed
810 // non-NULL in between. 810 // non-NULL in between.
811 scoped_ptr<Delegate> delegate_; 811 scoped_ptr<Delegate> delegate_;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 VisitTracker tracker_; 856 VisitTracker tracker_;
857 857
858 // A boolean variable to track whether we have already purged obsolete segment 858 // A boolean variable to track whether we have already purged obsolete segment
859 // data. 859 // data.
860 bool segment_queried_; 860 bool segment_queried_;
861 861
862 // HistoryDBTasks to run. Be sure to AddRef when adding, and Release when 862 // HistoryDBTasks to run. Be sure to AddRef when adding, and Release when
863 // done. 863 // done.
864 std::list<HistoryDBTaskRequest*> db_task_requests_; 864 std::list<HistoryDBTaskRequest*> db_task_requests_;
865 865
866 // Used to determine if a URL is bookmarked. This is owned by the Profile and 866 // Used to determine if a URL is bookmarked; may be NULL.
867 // may be NULL (during testing).
868 // 867 //
869 // Use GetBookmarkService to access this, which makes sure the service is 868 // Use GetHistoryClient to access this, which makes sure the data is loaded.
870 // loaded. 869 HistoryClient* history_client_;
871 BookmarkService* bookmark_service_;
872 870
873 #if defined(OS_ANDROID) 871 #if defined(OS_ANDROID)
874 // Used to provide the Android ContentProvider APIs. 872 // Used to provide the Android ContentProvider APIs.
875 scoped_ptr<AndroidProviderBackend> android_provider_backend_; 873 scoped_ptr<AndroidProviderBackend> android_provider_backend_;
876 874
877 // Used to provide UMA on the number of page visits that are to the most 875 // Used to provide UMA on the number of page visits that are to the most
878 // visited URLs. This is here because the backend both has access to this 876 // visited URLs. This is here because the backend both has access to this
879 // information and is notified of page visits. The top sites service should 877 // information and is notified of page visits. The top sites service should
880 // be used instead whenever possible. 878 // be used instead whenever possible.
881 std::map<GURL, int> most_visited_urls_map_; 879 std::map<GURL, int> most_visited_urls_map_;
882 #endif 880 #endif
883 881
884 // Used to manage syncing of the typed urls datatype. This will be NULL 882 // Used to manage syncing of the typed urls datatype. This will be NULL
885 // before Init is called. 883 // before Init is called.
886 scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_; 884 scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_;
887 885
888 // Listens for the system being under memory pressure. 886 // Listens for the system being under memory pressure.
889 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; 887 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
890 888
891 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 889 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
892 }; 890 };
893 891
894 } // namespace history 892 } // namespace history
895 893
896 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 894 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698