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

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

Issue 10872032: Revert 152946 - Replace HistoryQuickProvider protobuf-based caching with an SQLite-based database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/diagnostics/sqlite_diagnostics.cc ('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
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Must call Init after construction. 104 // Must call Init after construction.
105 explicit HistoryService(Profile* profile); 105 explicit HistoryService(Profile* profile);
106 // The empty constructor is provided only for testing. 106 // The empty constructor is provided only for testing.
107 HistoryService(); 107 HistoryService();
108 108
109 // Initializes the history service, returning true on success. On false, do 109 // Initializes the history service, returning true on success. On false, do
110 // not call any other functions. The given directory will be used for storing 110 // not call any other functions. The given directory will be used for storing
111 // the history files. The BookmarkService is used when deleting URLs to 111 // the history files. The BookmarkService is used when deleting URLs to
112 // test if a URL is bookmarked; it may be NULL during testing. 112 // test if a URL is bookmarked; it may be NULL during testing.
113 bool Init(const FilePath& history_dir, BookmarkService* bookmark_service) { 113 bool Init(const FilePath& history_dir, BookmarkService* bookmark_service) {
114 return Init(history_dir, bookmark_service, false, false); 114 return Init(history_dir, bookmark_service, false);
115 } 115 }
116 116
117 // Triggers the backend to load if it hasn't already, and then returns whether 117 // Triggers the backend to load if it hasn't already, and then returns whether
118 // it's finished loading. 118 // it's finished loading.
119 // Note: Virtual needed for mocking. 119 // Note: Virtual needed for mocking.
120 virtual bool BackendLoaded(); 120 virtual bool BackendLoaded();
121 121
122 // Returns true if the backend has finished loading. 122 // Returns true if the backend has finished loading.
123 bool backend_loaded() const { return backend_loaded_; } 123 bool backend_loaded() const { return backend_loaded_; }
124 124
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 // Querying ------------------------------------------------------------------ 248 // Querying ------------------------------------------------------------------
249 249
250 // Callback class that a client can implement to iterate over URLs. The 250 // Callback class that a client can implement to iterate over URLs. The
251 // callbacks WILL BE CALLED ON THE BACKGROUND THREAD! Your implementation 251 // callbacks WILL BE CALLED ON THE BACKGROUND THREAD! Your implementation
252 // should handle this appropriately. 252 // should handle this appropriately.
253 class URLEnumerator { 253 class URLEnumerator {
254 public: 254 public:
255 // Indicates that a URL is available. There will be exactly one call for 255 // Indicates that a URL is available. There will be exactly one call for
256 // every URL in history. 256 // every URL in history.
257 virtual void OnURL(const history::URLRow& url_row) = 0; 257 virtual void OnURL(const GURL& url) = 0;
258 258
259 // Indicates we are done iterating over URLs. Once called, there will be no 259 // Indicates we are done iterating over URLs. Once called, there will be no
260 // more callbacks made. This call is guaranteed to occur, even if there are 260 // more callbacks made. This call is guaranteed to occur, even if there are
261 // no URLs. If all URLs were iterated, success will be true. 261 // no URLs. If all URLs were iterated, success will be true.
262 virtual void OnComplete(bool success) = 0; 262 virtual void OnComplete(bool success) = 0;
263 263
264 protected: 264 protected:
265 virtual ~URLEnumerator() {} 265 virtual ~URLEnumerator() {}
266 }; 266 };
267 267
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 QueryFilteredURLsCallback; 382 QueryFilteredURLsCallback;
383 383
384 // Request the |result_count| most visited URLs and the chain of 384 // Request the |result_count| most visited URLs and the chain of
385 // redirects leading to each of these URLs. |days_back| is the 385 // redirects leading to each of these URLs. |days_back| is the
386 // number of days of history to use. Used by TopSites. 386 // number of days of history to use. Used by TopSites.
387 Handle QueryMostVisitedURLs(int result_count, int days_back, 387 Handle QueryMostVisitedURLs(int result_count, int days_back,
388 CancelableRequestConsumerBase* consumer, 388 CancelableRequestConsumerBase* consumer,
389 const QueryMostVisitedURLsCallback& callback); 389 const QueryMostVisitedURLsCallback& callback);
390 390
391 // Request the |result_count| URLs filtered and sorted based on the |filter|. 391 // Request the |result_count| URLs filtered and sorted based on the |filter|.
392 // If |extended_info| is true, additional data will be provided in the 392 // If |extended_info| is enabled, additional data will be provided in the
393 // results. Computing this additional data is expensive, likely to become 393 // results.
394 // more expensive as additional data points are added in future changes, and
395 // not useful in most cases. Set |extended_info| to true only if you
396 // explicitly require the additional data.
397 Handle QueryFilteredURLs( 394 Handle QueryFilteredURLs(
398 int result_count, 395 int result_count,
399 const history::VisitFilter& filter, 396 const history::VisitFilter& filter,
400 bool extended_info, 397 bool extended_info,
401 CancelableRequestConsumerBase* consumer, 398 CancelableRequestConsumerBase* consumer,
402 const QueryFilteredURLsCallback& callback); 399 const QueryFilteredURLsCallback& callback);
403 400
404 // Thumbnails ---------------------------------------------------------------- 401 // Thumbnails ----------------------------------------------------------------
405 402
406 // Implemented by consumers to get thumbnail data. Called when a request for 403 // Implemented by consumers to get thumbnail data. Called when a request for
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 void StartTopSitesMigration(int backend_id); 611 void StartTopSitesMigration(int backend_id);
615 612
616 // Called by TopSites after the thumbnails were read and it is safe 613 // Called by TopSites after the thumbnails were read and it is safe
617 // to delete the thumbnails DB. 614 // to delete the thumbnails DB.
618 void OnTopSitesReady(); 615 void OnTopSitesReady();
619 616
620 // Returns true if this looks like the type of URL we want to add to the 617 // Returns true if this looks like the type of URL we want to add to the
621 // history. We filter out some URLs such as JavaScript. 618 // history. We filter out some URLs such as JavaScript.
622 static bool CanAddURL(const GURL& url); 619 static bool CanAddURL(const GURL& url);
623 620
624 // Returns the history backend associated with this service.
625 history::HistoryBackend* get_history_backend_for_testing() {
626 return history_backend_.get();
627 }
628
629 protected: 621 protected:
630 virtual ~HistoryService(); 622 virtual ~HistoryService();
631 623
632 // These are not currently used, hopefully we can do something in the future 624 // These are not currently used, hopefully we can do something in the future
633 // to ensure that the most important things happen first. 625 // to ensure that the most important things happen first.
634 enum SchedulePriority { 626 enum SchedulePriority {
635 PRIORITY_UI, // The highest priority (must respond to UI events). 627 PRIORITY_UI, // The highest priority (must respond to UI events).
636 PRIORITY_NORMAL, // Normal stuff like adding a page. 628 PRIORITY_NORMAL, // Normal stuff like adding a page.
637 PRIORITY_LOW, // Low priority things like indexing or expiration. 629 PRIORITY_LOW, // Low priority things like indexing or expiration.
638 }; 630 };
639 631
640 private: 632 private:
641 class BackendDelegate; 633 class BackendDelegate;
642 #if defined(OS_ANDROID) 634 #if defined(OS_ANDROID)
643 friend class AndroidHistoryProviderService; 635 friend class AndroidHistoryProviderService;
644 #endif 636 #endif
645 friend class base::RefCountedThreadSafe<HistoryService>; 637 friend class base::RefCountedThreadSafe<HistoryService>;
646 friend class BackendDelegate; 638 friend class BackendDelegate;
647 friend class CacheTestingProfile;
648 friend class FaviconService; 639 friend class FaviconService;
649 friend class history::HistoryBackend; 640 friend class history::HistoryBackend;
650 friend class history::HistoryQueryTest; 641 friend class history::HistoryQueryTest;
651 friend class HistoryOperation; 642 friend class HistoryOperation;
652 friend class HistoryURLProvider; 643 friend class HistoryURLProvider;
653 friend class HistoryURLProviderTest; 644 friend class HistoryURLProviderTest;
654 friend class InMemoryURLIndexBaseTest; 645 friend class history::InMemoryURLIndexTest;
655 template<typename Info, typename Callback> friend class DownloadRequest; 646 template<typename Info, typename Callback> friend class DownloadRequest;
656 friend class PageUsageRequest; 647 friend class PageUsageRequest;
657 friend class RedirectRequest; 648 friend class RedirectRequest;
658 friend class TestingProfile; 649 friend class TestingProfile;
659 650
660 // Implementation of content::NotificationObserver. 651 // Implementation of content::NotificationObserver.
661 virtual void Observe(int type, 652 virtual void Observe(int type,
662 const content::NotificationSource& source, 653 const content::NotificationSource& source,
663 const content::NotificationDetails& details) OVERRIDE; 654 const content::NotificationDetails& details) OVERRIDE;
664 655
665 // Low-level Init(). Same as the public version, but adds the |no_db| and 656 // Low-level Init(). Same as the public version, but adds a |no_db| parameter
666 // |disable_index_cache| parameters that are only set by unittests. |no_db| 657 // that is only set by unittests which causes the backend to not init its DB.
667 // causes the backend to not init its DB. |disable_index_cache| causes the
668 // InMemoryURLIndex to not create or use its cache database.
669 bool Init(const FilePath& history_dir, 658 bool Init(const FilePath& history_dir,
670 BookmarkService* bookmark_service, 659 BookmarkService* bookmark_service,
671 bool no_db, 660 bool no_db);
672 bool disable_index_cache);
673 661
674 // Called by the HistoryURLProvider class to schedule an autocomplete, it 662 // Called by the HistoryURLProvider class to schedule an autocomplete, it
675 // will be called back on the internal history thread with the history 663 // will be called back on the internal history thread with the history
676 // database so it can query. See history_autocomplete.cc for a diagram. 664 // database so it can query. See history_autocomplete.cc for a diagram.
677 void ScheduleAutocomplete(HistoryURLProvider* provider, 665 void ScheduleAutocomplete(HistoryURLProvider* provider,
678 HistoryURLProviderParams* params); 666 HistoryURLProviderParams* params);
679 667
680 // Broadcasts the given notification. This is called by the backend so that 668 // Broadcasts the given notification. This is called by the backend so that
681 // the notification will be broadcast on the main thread. 669 // the notification will be broadcast on the main thread.
682 // 670 //
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 // You MUST communicate with this class ONLY through the thread_'s 919 // You MUST communicate with this class ONLY through the thread_'s
932 // message_loop(). 920 // message_loop().
933 // 921 //
934 // This pointer will be NULL once Cleanup() has been called, meaning no 922 // This pointer will be NULL once Cleanup() has been called, meaning no
935 // more calls should be made to the history thread. 923 // more calls should be made to the history thread.
936 scoped_refptr<history::HistoryBackend> history_backend_; 924 scoped_refptr<history::HistoryBackend> history_backend_;
937 925
938 // A cache of the user-typed URLs kept in memory that is used by the 926 // A cache of the user-typed URLs kept in memory that is used by the
939 // autocomplete system. This will be NULL until the database has been created 927 // autocomplete system. This will be NULL until the database has been created
940 // on the background thread. 928 // on the background thread.
941 // TODO(mrossetti): Consider changing ownership. See http://crbug.com/138321
942 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_; 929 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_;
943 930
944 // The profile, may be null when testing. 931 // The profile, may be null when testing.
945 Profile* profile_; 932 Profile* profile_;
946 933
947 // Has the backend finished loading? The backend is loaded once Init has 934 // Has the backend finished loading? The backend is loaded once Init has
948 // completed. 935 // completed.
949 bool backend_loaded_; 936 bool backend_loaded_;
950 937
951 // The id of the current backend. This is only valid when history_backend_ 938 // The id of the current backend. This is only valid when history_backend_
952 // is not NULL. 939 // is not NULL.
953 int current_backend_id_; 940 int current_backend_id_;
954 941
955 // Cached values from Init(), used whenever we need to reload the backend. 942 // Cached values from Init(), used whenever we need to reload the backend.
956 FilePath history_dir_; 943 FilePath history_dir_;
957 BookmarkService* bookmark_service_; 944 BookmarkService* bookmark_service_;
958 bool no_db_; 945 bool no_db_;
959 946
960 // True if needs top site migration. 947 // True if needs top site migration.
961 bool needs_top_sites_migration_; 948 bool needs_top_sites_migration_;
962 949
963 // The index used for quick history lookups. 950 // The index used for quick history lookups.
964 // TODO(mrossetti): Move in_memory_url_index out of history_service.
965 // See http://crbug.com/138321
966 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; 951 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_;
967 952
968 scoped_refptr<ObserverListThreadSafe<history::VisitDatabaseObserver> > 953 scoped_refptr<ObserverListThreadSafe<history::VisitDatabaseObserver> >
969 visit_database_observers_; 954 visit_database_observers_;
970 955
971 DISALLOW_COPY_AND_ASSIGN(HistoryService); 956 DISALLOW_COPY_AND_ASSIGN(HistoryService);
972 }; 957 };
973 958
974 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ 959 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_
OLDNEW
« no previous file with comments | « chrome/browser/diagnostics/sqlite_diagnostics.cc ('k') | chrome/browser/history/history.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698