Chromium Code Reviews| 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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
| 6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 #include "sync/api/syncable_service.h" | 35 #include "sync/api/syncable_service.h" |
| 36 #include "ui/base/page_transition_types.h" | 36 #include "ui/base/page_transition_types.h" |
| 37 | 37 |
| 38 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) |
| 39 class AndroidHistoryProviderService; | 39 class AndroidHistoryProviderService; |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 class GURL; | 42 class GURL; |
| 43 class PageUsageData; | 43 class PageUsageData; |
| 44 class PageUsageRequest; | 44 class PageUsageRequest; |
| 45 class PrefService; | |
| 45 class Profile; | 46 class Profile; |
| 46 struct ImportedFaviconUsage; | 47 struct ImportedFaviconUsage; |
| 47 class SkBitmap; | 48 class SkBitmap; |
| 48 | 49 |
| 49 namespace base { | 50 namespace base { |
| 50 class FilePath; | 51 class FilePath; |
| 51 class Thread; | 52 class Thread; |
| 52 } | 53 } |
| 53 | 54 |
| 54 namespace visitedlink { | 55 namespace visitedlink { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 84 // thread that made the request. | 85 // thread that made the request. |
| 85 class HistoryService : public syncer::SyncableService, | 86 class HistoryService : public syncer::SyncableService, |
| 86 public KeyedService, | 87 public KeyedService, |
| 87 public visitedlink::VisitedLinkDelegate { | 88 public visitedlink::VisitedLinkDelegate { |
| 88 public: | 89 public: |
| 89 // Miscellaneous commonly-used types. | 90 // Miscellaneous commonly-used types. |
| 90 typedef std::vector<PageUsageData*> PageUsageDataList; | 91 typedef std::vector<PageUsageData*> PageUsageDataList; |
| 91 | 92 |
| 92 // Must call Init after construction. The |history::HistoryClient| object | 93 // Must call Init after construction. The |history::HistoryClient| object |
| 93 // must be valid for the whole lifetime of |HistoryService|. | 94 // must be valid for the whole lifetime of |HistoryService|. |
| 94 explicit HistoryService(history::HistoryClient* client, Profile* profile); | 95 explicit HistoryService(history::HistoryClient* client, Profile* profile); |
|
droger
2015/01/30 16:31:14
Can you remove |profile| here?
| |
| 95 // The empty constructor is provided only for testing. | 96 // The empty constructor is provided only for testing. |
| 96 HistoryService(); | 97 HistoryService(); |
| 97 | 98 |
| 98 ~HistoryService() override; | 99 ~HistoryService() override; |
| 99 | 100 |
| 100 // Initializes the history service, returning true on success. On false, do | 101 // Initializes the history service, returning true on success. On false, do |
| 101 // not call any other functions. The given directory will be used for storing | 102 // not call any other functions. The given directory will be used for storing |
| 102 // the history files. | 103 // the history files. |
| 103 bool Init(const history::HistoryDatabaseParams& history_database_params) { | 104 bool Init(PrefService* prefs, |
| 104 return Init(false, history_database_params); | 105 const history::HistoryDatabaseParams& history_database_params) { |
| 106 return Init(false, prefs, history_database_params); | |
| 105 } | 107 } |
| 106 | 108 |
| 107 // Triggers the backend to load if it hasn't already, and then returns whether | 109 // Triggers the backend to load if it hasn't already, and then returns whether |
| 108 // it's finished loading. | 110 // it's finished loading. |
| 109 // Note: Virtual needed for mocking. | 111 // Note: Virtual needed for mocking. |
| 110 virtual bool BackendLoaded(); | 112 virtual bool BackendLoaded(); |
| 111 | 113 |
| 112 // Returns true if the backend has finished loading. | 114 // Returns true if the backend has finished loading. |
| 113 bool backend_loaded() const { return backend_loaded_; } | 115 bool backend_loaded() const { return backend_loaded_; } |
| 114 | 116 |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 // should be impossible for anybody else to call the service, even if it is | 557 // should be impossible for anybody else to call the service, even if it is |
| 556 // still in memory (pending requests may be holding a reference to us). | 558 // still in memory (pending requests may be holding a reference to us). |
| 557 void Cleanup(); | 559 void Cleanup(); |
| 558 | 560 |
| 559 // Implementation of visitedlink::VisitedLinkDelegate. | 561 // Implementation of visitedlink::VisitedLinkDelegate. |
| 560 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override; | 562 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override; |
| 561 | 563 |
| 562 // Low-level Init(). Same as the public version, but adds a |no_db| parameter | 564 // Low-level Init(). Same as the public version, but adds a |no_db| parameter |
| 563 // that is only set by unittests which causes the backend to not init its DB. | 565 // that is only set by unittests which causes the backend to not init its DB. |
| 564 bool Init(bool no_db, | 566 bool Init(bool no_db, |
| 567 PrefService* prefs, | |
| 565 const history::HistoryDatabaseParams& history_database_params); | 568 const history::HistoryDatabaseParams& history_database_params); |
| 566 | 569 |
| 567 // Called by the HistoryURLProvider class to schedule an autocomplete, it | 570 // Called by the HistoryURLProvider class to schedule an autocomplete, it |
| 568 // will be called back on the internal history thread with the history | 571 // will be called back on the internal history thread with the history |
| 569 // database so it can query. See history_autocomplete.cc for a diagram. | 572 // database so it can query. See history_autocomplete.cc for a diagram. |
| 570 void ScheduleAutocomplete(const base::Callback< | 573 void ScheduleAutocomplete(const base::Callback< |
| 571 void(history::HistoryBackend*, history::URLDatabase*)>& callback); | 574 void(history::HistoryBackend*, history::URLDatabase*)>& callback); |
| 572 | 575 |
| 573 // Notification from the backend that it has finished loading. Sends | 576 // Notification from the backend that it has finished loading. Sends |
| 574 // notification (NOTIFY_HISTORY_LOADED) and sets backend_loaded_ to true. | 577 // notification (NOTIFY_HISTORY_LOADED) and sets backend_loaded_ to true. |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 806 // A cache of the user-typed URLs kept in memory that is used by the | 809 // A cache of the user-typed URLs kept in memory that is used by the |
| 807 // autocomplete system. This will be NULL until the database has been created | 810 // autocomplete system. This will be NULL until the database has been created |
| 808 // on the background thread. | 811 // on the background thread. |
| 809 // TODO(mrossetti): Consider changing ownership. See http://crbug.com/138321 | 812 // TODO(mrossetti): Consider changing ownership. See http://crbug.com/138321 |
| 810 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_; | 813 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_; |
| 811 | 814 |
| 812 // The history client, may be null when testing. The object should otherwise | 815 // The history client, may be null when testing. The object should otherwise |
| 813 // outlive |HistoryService|. | 816 // outlive |HistoryService|. |
| 814 history::HistoryClient* history_client_; | 817 history::HistoryClient* history_client_; |
| 815 | 818 |
| 816 // The profile, may be null when testing. | |
| 817 Profile* profile_; | |
| 818 | |
| 819 // Used for propagating link highlighting data across renderers. May be null | 819 // Used for propagating link highlighting data across renderers. May be null |
| 820 // in tests. | 820 // in tests. |
| 821 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_; | 821 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_; |
| 822 | 822 |
| 823 // Has the backend finished loading? The backend is loaded once Init has | 823 // Has the backend finished loading? The backend is loaded once Init has |
| 824 // completed. | 824 // completed. |
| 825 bool backend_loaded_; | 825 bool backend_loaded_; |
| 826 | 826 |
| 827 // Cached values from Init(), used whenever we need to reload the backend. | 827 // Cached values from Init(), used whenever we need to reload the backend. |
| 828 base::FilePath history_dir_; | 828 base::FilePath history_dir_; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 839 | 839 |
| 840 history::DeleteDirectiveHandler delete_directive_handler_; | 840 history::DeleteDirectiveHandler delete_directive_handler_; |
| 841 | 841 |
| 842 // All vended weak pointers are invalidated in Cleanup(). | 842 // All vended weak pointers are invalidated in Cleanup(). |
| 843 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; | 843 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; |
| 844 | 844 |
| 845 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 845 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
| 846 }; | 846 }; |
| 847 | 847 |
| 848 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 848 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
| OLD | NEW |