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

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

Issue 11573060: Remove VisitedLink dependency on rest of chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass scoped_refptr<Enumerator> by const ref (instead of by value) Created 7 years, 11 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
« no previous file with comments | « chrome/browser/history/DEPS ('k') | chrome/browser/history/history.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/bind.h" 12 #include "base/bind.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/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "base/string16.h" 20 #include "base/string16.h"
21 #include "base/time.h" 21 #include "base/time.h"
22 #include "base/threading/thread_checker.h" 22 #include "base/threading/thread_checker.h"
23 #include "chrome/browser/common/cancelable_request.h" 23 #include "chrome/browser/common/cancelable_request.h"
24 #include "chrome/browser/favicon/favicon_service.h" 24 #include "chrome/browser/favicon/favicon_service.h"
25 #include "chrome/browser/history/history_types.h" 25 #include "chrome/browser/history/history_types.h"
26 #include "chrome/browser/profiles/profile_keyed_service.h" 26 #include "chrome/browser/profiles/profile_keyed_service.h"
27 #include "chrome/browser/search_engines/template_url_id.h" 27 #include "chrome/browser/search_engines/template_url_id.h"
28 #include "chrome/browser/visitedlink/visitedlink_delegate.h"
28 #include "chrome/common/cancelable_task_tracker.h" 29 #include "chrome/common/cancelable_task_tracker.h"
29 #include "chrome/common/ref_counted_util.h" 30 #include "chrome/common/ref_counted_util.h"
30 #include "content/public/browser/notification_observer.h" 31 #include "content/public/browser/notification_observer.h"
31 #include "content/public/browser/notification_registrar.h" 32 #include "content/public/browser/notification_registrar.h"
32 #include "content/public/common/page_transition_types.h" 33 #include "content/public/common/page_transition_types.h"
33 #include "sql/init_status.h" 34 #include "sql/init_status.h"
34 #include "sync/api/syncable_service.h" 35 #include "sync/api/syncable_service.h"
35 #include "ui/base/layout.h" 36 #include "ui/base/layout.h"
36 37
37 #if defined(OS_ANDROID) 38 #if defined(OS_ANDROID)
38 #include "chrome/browser/history/android/android_history_provider_service.h" 39 #include "chrome/browser/history/android/android_history_provider_service.h"
39 #endif 40 #endif
40 41
41 class BookmarkService; 42 class BookmarkService;
42 class FilePath; 43 class FilePath;
43 class GURL; 44 class GURL;
44 class HistoryURLProvider; 45 class HistoryURLProvider;
45 class PageUsageData; 46 class PageUsageData;
46 class PageUsageRequest; 47 class PageUsageRequest;
47 class Profile; 48 class Profile;
49 class VisitedLinkMaster;
48 struct HistoryURLProviderParams; 50 struct HistoryURLProviderParams;
49 51
50 namespace base { 52 namespace base {
51 class Thread; 53 class Thread;
52 } 54 }
53 55
54 56
55 namespace history { 57 namespace history {
56 58
57 class HistoryBackend; 59 class HistoryBackend;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 }; 102 };
101 103
102 // The history service records page titles, and visit times, as well as 104 // The history service records page titles, and visit times, as well as
103 // (eventually) information about autocomplete. 105 // (eventually) information about autocomplete.
104 // 106 //
105 // This service is thread safe. Each request callback is invoked in the 107 // This service is thread safe. Each request callback is invoked in the
106 // thread that made the request. 108 // thread that made the request.
107 class HistoryService : public CancelableRequestProvider, 109 class HistoryService : public CancelableRequestProvider,
108 public content::NotificationObserver, 110 public content::NotificationObserver,
109 public syncer::SyncableService, 111 public syncer::SyncableService,
110 public ProfileKeyedService { 112 public ProfileKeyedService,
113 public VisitedLinkDelegate {
111 public: 114 public:
112 // Miscellaneous commonly-used types. 115 // Miscellaneous commonly-used types.
113 typedef std::vector<PageUsageData*> PageUsageDataList; 116 typedef std::vector<PageUsageData*> PageUsageDataList;
114 117
115 // Must call Init after construction. 118 // Must call Init after construction.
116 explicit HistoryService(Profile* profile); 119 explicit HistoryService(Profile* profile);
117 // The empty constructor is provided only for testing. 120 // The empty constructor is provided only for testing.
118 HistoryService(); 121 HistoryService();
119 122
120 virtual ~HistoryService(); 123 virtual ~HistoryService();
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 257
255 // Indexing ------------------------------------------------------------------ 258 // Indexing ------------------------------------------------------------------
256 259
257 // Notifies history of the body text of the given recently-visited URL. 260 // Notifies history of the body text of the given recently-visited URL.
258 // If the URL was not visited "recently enough," the history system may 261 // If the URL was not visited "recently enough," the history system may
259 // discard it. 262 // discard it.
260 void SetPageContents(const GURL& url, const string16& contents); 263 void SetPageContents(const GURL& url, const string16& contents);
261 264
262 // Querying ------------------------------------------------------------------ 265 // Querying ------------------------------------------------------------------
263 266
264 // Callback class that a client can implement to iterate over URLs. The
265 // callbacks WILL BE CALLED ON THE BACKGROUND THREAD! Your implementation
266 // should handle this appropriately.
267 class URLEnumerator {
268 public:
269 // Indicates that a URL is available. There will be exactly one call for
270 // every URL in history.
271 virtual void OnURL(const history::URLRow& url_row) = 0;
272
273 // Indicates we are done iterating over URLs. Once called, there will be no
274 // more callbacks made. This call is guaranteed to occur, even if there are
275 // no URLs. If all URLs were iterated, success will be true.
276 virtual void OnComplete(bool success) = 0;
277
278 protected:
279 virtual ~URLEnumerator() {}
280 };
281
282 // Enumerate all URLs in history. The given iterator will be owned by the
283 // caller, so the caller should ensure it exists until OnComplete is called.
284 // You should not generally use this since it will be slow to slurp all URLs
285 // in from the database. It is designed for rebuilding the visited link
286 // database from history.
287 void IterateURLs(URLEnumerator* iterator);
288
289 // Returns the information about the requested URL. If the URL is found, 267 // Returns the information about the requested URL. If the URL is found,
290 // success will be true and the information will be in the URLRow parameter. 268 // success will be true and the information will be in the URLRow parameter.
291 // On success, the visits, if requested, will be sorted by date. If they have 269 // On success, the visits, if requested, will be sorted by date. If they have
292 // not been requested, the pointer will be valid, but the vector will be 270 // not been requested, the pointer will be valid, but the vector will be
293 // empty. 271 // empty.
294 // 272 //
295 // If success is false, neither the row nor the vector will be valid. 273 // If success is false, neither the row nor the vector will be valid.
296 typedef base::Callback<void( 274 typedef base::Callback<void(
297 Handle, 275 Handle,
298 bool, // Success flag, when false, nothing else is valid. 276 bool, // Success flag, when false, nothing else is valid.
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 template<typename Info, typename Callback> friend class DownloadRequest; 650 template<typename Info, typename Callback> friend class DownloadRequest;
673 friend class PageUsageRequest; 651 friend class PageUsageRequest;
674 friend class RedirectRequest; 652 friend class RedirectRequest;
675 friend class TestingProfile; 653 friend class TestingProfile;
676 654
677 // Implementation of content::NotificationObserver. 655 // Implementation of content::NotificationObserver.
678 virtual void Observe(int type, 656 virtual void Observe(int type,
679 const content::NotificationSource& source, 657 const content::NotificationSource& source,
680 const content::NotificationDetails& details) OVERRIDE; 658 const content::NotificationDetails& details) OVERRIDE;
681 659
660 // Implementation of VisitedLinkDelegate.
661 virtual bool AreEquivalentContexts(
662 content::BrowserContext* context1,
663 content::BrowserContext* context2) OVERRIDE;
664 virtual void RebuildTable(
665 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE;
666
682 // Low-level Init(). Same as the public version, but adds a |no_db| parameter 667 // Low-level Init(). Same as the public version, but adds a |no_db| parameter
683 // that is only set by unittests which causes the backend to not init its DB. 668 // that is only set by unittests which causes the backend to not init its DB.
684 bool Init(const FilePath& history_dir, 669 bool Init(const FilePath& history_dir,
685 BookmarkService* bookmark_service, 670 BookmarkService* bookmark_service,
686 bool no_db); 671 bool no_db);
687 672
688 // Called by the HistoryURLProvider class to schedule an autocomplete, it 673 // Called by the HistoryURLProvider class to schedule an autocomplete, it
689 // will be called back on the internal history thread with the history 674 // will be called back on the internal history thread with the history
690 // database so it can query. See history_autocomplete.cc for a diagram. 675 // database so it can query. See history_autocomplete.cc for a diagram.
691 void ScheduleAutocomplete(HistoryURLProvider* provider, 676 void ScheduleAutocomplete(HistoryURLProvider* provider,
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 // on the background thread. 1081 // on the background thread.
1097 // TODO(mrossetti): Consider changing ownership. See http://crbug.com/138321 1082 // TODO(mrossetti): Consider changing ownership. See http://crbug.com/138321
1098 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_; 1083 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_;
1099 1084
1100 // Used to propagate local delete directives to sync. 1085 // Used to propagate local delete directives to sync.
1101 scoped_ptr<syncer::SyncChangeProcessor> sync_change_processor_; 1086 scoped_ptr<syncer::SyncChangeProcessor> sync_change_processor_;
1102 1087
1103 // The profile, may be null when testing. 1088 // The profile, may be null when testing.
1104 Profile* profile_; 1089 Profile* profile_;
1105 1090
1091 // Used for propagating link highlighting data across renderers. May be null
1092 // in tests.
1093 scoped_ptr<VisitedLinkMaster> visitedlink_master_;
1094
1106 // Has the backend finished loading? The backend is loaded once Init has 1095 // Has the backend finished loading? The backend is loaded once Init has
1107 // completed. 1096 // completed.
1108 bool backend_loaded_; 1097 bool backend_loaded_;
1109 1098
1110 // The id of the current backend. This is only valid when history_backend_ 1099 // The id of the current backend. This is only valid when history_backend_
1111 // is not NULL. 1100 // is not NULL.
1112 int current_backend_id_; 1101 int current_backend_id_;
1113 1102
1114 // Cached values from Init(), used whenever we need to reload the backend. 1103 // Cached values from Init(), used whenever we need to reload the backend.
1115 FilePath history_dir_; 1104 FilePath history_dir_;
1116 BookmarkService* bookmark_service_; 1105 BookmarkService* bookmark_service_;
1117 bool no_db_; 1106 bool no_db_;
1118 1107
1119 // True if needs top site migration. 1108 // True if needs top site migration.
1120 bool needs_top_sites_migration_; 1109 bool needs_top_sites_migration_;
1121 1110
1122 // The index used for quick history lookups. 1111 // The index used for quick history lookups.
1123 // TODO(mrossetti): Move in_memory_url_index out of history_service. 1112 // TODO(mrossetti): Move in_memory_url_index out of history_service.
1124 // See http://crbug.com/138321 1113 // See http://crbug.com/138321
1125 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; 1114 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_;
1126 1115
1127 ObserverList<history::VisitDatabaseObserver> visit_database_observers_; 1116 ObserverList<history::VisitDatabaseObserver> visit_database_observers_;
1128 1117
1129 DISALLOW_COPY_AND_ASSIGN(HistoryService); 1118 DISALLOW_COPY_AND_ASSIGN(HistoryService);
1130 }; 1119 };
1131 1120
1132 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ 1121 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/DEPS ('k') | chrome/browser/history/history.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698