| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 public: | 90 public: |
| 91 // Miscellaneous commonly-used types. | 91 // Miscellaneous commonly-used types. |
| 92 typedef std::vector<PageUsageData*> PageUsageDataList; | 92 typedef std::vector<PageUsageData*> PageUsageDataList; |
| 93 | 93 |
| 94 // Must call Init after construction. The |history::HistoryClient| object | 94 // Must call Init after construction. The |history::HistoryClient| object |
| 95 // must be valid for the whole lifetime of |HistoryService|. | 95 // must be valid for the whole lifetime of |HistoryService|. |
| 96 explicit HistoryService(history::HistoryClient* client, Profile* profile); | 96 explicit HistoryService(history::HistoryClient* client, Profile* profile); |
| 97 // The empty constructor is provided only for testing. | 97 // The empty constructor is provided only for testing. |
| 98 HistoryService(); | 98 HistoryService(); |
| 99 | 99 |
| 100 virtual ~HistoryService(); | 100 ~HistoryService() override; |
| 101 | 101 |
| 102 // Initializes the history service, returning true on success. On false, do | 102 // Initializes the history service, returning true on success. On false, do |
| 103 // not call any other functions. The given directory will be used for storing | 103 // not call any other functions. The given directory will be used for storing |
| 104 // the history files. | 104 // the history files. |
| 105 bool Init(const base::FilePath& history_dir) { | 105 bool Init(const base::FilePath& history_dir) { |
| 106 return Init(history_dir, false); | 106 return Init(history_dir, false); |
| 107 } | 107 } |
| 108 | 108 |
| 109 // 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 |
| 110 // it's finished loading. | 110 // it's finished loading. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // This method should only be called from the history thread, because the | 144 // This method should only be called from the history thread, because the |
| 145 // returned service is intended to be accessed only via the history thread. | 145 // returned service is intended to be accessed only via the history thread. |
| 146 history::TypedUrlSyncableService* GetTypedUrlSyncableService() const; | 146 history::TypedUrlSyncableService* GetTypedUrlSyncableService() const; |
| 147 | 147 |
| 148 // Return the quick history index. | 148 // Return the quick history index. |
| 149 history::InMemoryURLIndex* InMemoryIndex() const { | 149 history::InMemoryURLIndex* InMemoryIndex() const { |
| 150 return in_memory_url_index_.get(); | 150 return in_memory_url_index_.get(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 // KeyedService: | 153 // KeyedService: |
| 154 virtual void Shutdown() override; | 154 void Shutdown() override; |
| 155 | 155 |
| 156 // Navigation ---------------------------------------------------------------- | 156 // Navigation ---------------------------------------------------------------- |
| 157 | 157 |
| 158 // Adds the given canonical URL to history with the given time as the visit | 158 // Adds the given canonical URL to history with the given time as the visit |
| 159 // time. Referrer may be the empty string. | 159 // time. Referrer may be the empty string. |
| 160 // | 160 // |
| 161 // The supplied context id is used to scope the given page ID. Page IDs | 161 // The supplied context id is used to scope the given page ID. Page IDs |
| 162 // are only unique inside a given context, so we need that to differentiate | 162 // are only unique inside a given context, so we need that to differentiate |
| 163 // them. | 163 // them. |
| 164 // | 164 // |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 // Returns true if this looks like the type of URL we want to add to the | 495 // Returns true if this looks like the type of URL we want to add to the |
| 496 // history. We filter out some URLs such as JavaScript. | 496 // history. We filter out some URLs such as JavaScript. |
| 497 static bool CanAddURL(const GURL& url); | 497 static bool CanAddURL(const GURL& url); |
| 498 | 498 |
| 499 // Returns the HistoryClient. | 499 // Returns the HistoryClient. |
| 500 history::HistoryClient* history_client() { return history_client_; } | 500 history::HistoryClient* history_client() { return history_client_; } |
| 501 | 501 |
| 502 base::WeakPtr<HistoryService> AsWeakPtr(); | 502 base::WeakPtr<HistoryService> AsWeakPtr(); |
| 503 | 503 |
| 504 // syncer::SyncableService implementation. | 504 // syncer::SyncableService implementation. |
| 505 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 505 syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 506 syncer::ModelType type, | 506 syncer::ModelType type, |
| 507 const syncer::SyncDataList& initial_sync_data, | 507 const syncer::SyncDataList& initial_sync_data, |
| 508 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 508 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 509 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; | 509 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; |
| 510 virtual void StopSyncing(syncer::ModelType type) override; | 510 void StopSyncing(syncer::ModelType type) override; |
| 511 virtual syncer::SyncDataList GetAllSyncData( | 511 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| 512 syncer::ModelType type) const override; | 512 syncer::SyncError ProcessSyncChanges( |
| 513 virtual syncer::SyncError ProcessSyncChanges( | |
| 514 const tracked_objects::Location& from_here, | 513 const tracked_objects::Location& from_here, |
| 515 const syncer::SyncChangeList& change_list) override; | 514 const syncer::SyncChangeList& change_list) override; |
| 516 | 515 |
| 517 protected: | 516 protected: |
| 518 // These are not currently used, hopefully we can do something in the future | 517 // These are not currently used, hopefully we can do something in the future |
| 519 // to ensure that the most important things happen first. | 518 // to ensure that the most important things happen first. |
| 520 enum SchedulePriority { | 519 enum SchedulePriority { |
| 521 PRIORITY_UI, // The highest priority (must respond to UI events). | 520 PRIORITY_UI, // The highest priority (must respond to UI events). |
| 522 PRIORITY_NORMAL, // Normal stuff like adding a page. | 521 PRIORITY_NORMAL, // Normal stuff like adding a page. |
| 523 PRIORITY_LOW, // Low priority things like indexing or expiration. | 522 PRIORITY_LOW, // Low priority things like indexing or expiration. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 549 // cleanup has happened that may dispatch to the history thread (because it | 548 // cleanup has happened that may dispatch to the history thread (because it |
| 550 // will be NULL). | 549 // will be NULL). |
| 551 // | 550 // |
| 552 // In practice, this will be called by the service manager (BrowserProcess) | 551 // In practice, this will be called by the service manager (BrowserProcess) |
| 553 // when it is being destroyed. Because that reference is being destroyed, it | 552 // when it is being destroyed. Because that reference is being destroyed, it |
| 554 // should be impossible for anybody else to call the service, even if it is | 553 // should be impossible for anybody else to call the service, even if it is |
| 555 // still in memory (pending requests may be holding a reference to us). | 554 // still in memory (pending requests may be holding a reference to us). |
| 556 void Cleanup(); | 555 void Cleanup(); |
| 557 | 556 |
| 558 // Implementation of content::NotificationObserver. | 557 // Implementation of content::NotificationObserver. |
| 559 virtual void Observe(int type, | 558 void Observe(int type, |
| 560 const content::NotificationSource& source, | 559 const content::NotificationSource& source, |
| 561 const content::NotificationDetails& details) override; | 560 const content::NotificationDetails& details) override; |
| 562 | 561 |
| 563 // Implementation of visitedlink::VisitedLinkDelegate. | 562 // Implementation of visitedlink::VisitedLinkDelegate. |
| 564 virtual void RebuildTable( | 563 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override; |
| 565 const scoped_refptr<URLEnumerator>& enumerator) override; | |
| 566 | 564 |
| 567 // Low-level Init(). Same as the public version, but adds a |no_db| parameter | 565 // Low-level Init(). Same as the public version, but adds a |no_db| parameter |
| 568 // that is only set by unittests which causes the backend to not init its DB. | 566 // that is only set by unittests which causes the backend to not init its DB. |
| 569 bool Init(const base::FilePath& history_dir, bool no_db); | 567 bool Init(const base::FilePath& history_dir, bool no_db); |
| 570 | 568 |
| 571 // Called by the HistoryURLProvider class to schedule an autocomplete, it | 569 // Called by the HistoryURLProvider class to schedule an autocomplete, it |
| 572 // will be called back on the internal history thread with the history | 570 // will be called back on the internal history thread with the history |
| 573 // database so it can query. See history_autocomplete.cc for a diagram. | 571 // database so it can query. See history_autocomplete.cc for a diagram. |
| 574 void ScheduleAutocomplete(const base::Callback< | 572 void ScheduleAutocomplete(const base::Callback< |
| 575 void(history::HistoryBackend*, history::URLDatabase*)>& callback); | 573 void(history::HistoryBackend*, history::URLDatabase*)>& callback); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 | 893 |
| 896 history::DeleteDirectiveHandler delete_directive_handler_; | 894 history::DeleteDirectiveHandler delete_directive_handler_; |
| 897 | 895 |
| 898 // All vended weak pointers are invalidated in Cleanup(). | 896 // All vended weak pointers are invalidated in Cleanup(). |
| 899 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; | 897 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; |
| 900 | 898 |
| 901 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 899 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
| 902 }; | 900 }; |
| 903 | 901 |
| 904 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 902 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
| OLD | NEW |