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 COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ |
6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // unit tests. When using the full constructor, |history_client| may only be | 92 // unit tests. When using the full constructor, |history_client| may only be |
93 // null during testing, while |visit_delegate| may be null if the embedder use | 93 // null during testing, while |visit_delegate| may be null if the embedder use |
94 // another way to track visited links. | 94 // another way to track visited links. |
95 HistoryService(); | 95 HistoryService(); |
96 HistoryService(scoped_ptr<HistoryClient> history_client, | 96 HistoryService(scoped_ptr<HistoryClient> history_client, |
97 scoped_ptr<VisitDelegate> visit_delegate); | 97 scoped_ptr<VisitDelegate> visit_delegate); |
98 ~HistoryService() override; | 98 ~HistoryService() override; |
99 | 99 |
100 // Initializes the history service, returning true on success. On false, do | 100 // 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 | 101 // not call any other functions. The given directory will be used for storing |
102 // the history files. |languages| is a comma-separated list of languages to | 102 // the history files. |
103 // use when interpreting URLs, it must not be empty (except during testing). | 103 bool Init(const HistoryDatabaseParams& history_database_params) { |
104 bool Init(const std::string& languages, | 104 return Init(false, history_database_params); |
105 const HistoryDatabaseParams& history_database_params) { | |
106 return Init(false, languages, history_database_params); | |
107 } | 105 } |
108 | 106 |
109 // Triggers the backend to load if it hasn't already, and then returns whether | 107 // Triggers the backend to load if it hasn't already, and then returns whether |
110 // it's finished loading. | 108 // it's finished loading. |
111 // Note: Virtual needed for mocking. | 109 // Note: Virtual needed for mocking. |
112 virtual bool BackendLoaded(); | 110 virtual bool BackendLoaded(); |
113 | 111 |
114 // Returns true if the backend has finished loading. | 112 // Returns true if the backend has finished loading. |
115 bool backend_loaded() const { return backend_loaded_; } | 113 bool backend_loaded() const { return backend_loaded_; } |
116 | 114 |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 friend class favicon::FaviconService; | 559 friend class favicon::FaviconService; |
562 friend class HistoryBackend; | 560 friend class HistoryBackend; |
563 friend class HistoryQueryTest; | 561 friend class HistoryQueryTest; |
564 friend class ::HistoryQuickProviderTest; | 562 friend class ::HistoryQuickProviderTest; |
565 friend class HistoryServiceTest; | 563 friend class HistoryServiceTest; |
566 friend class ::HistoryURLProvider; | 564 friend class ::HistoryURLProvider; |
567 friend class ::InMemoryURLIndexTest; | 565 friend class ::InMemoryURLIndexTest; |
568 friend class ::SyncBookmarkDataTypeControllerTest; | 566 friend class ::SyncBookmarkDataTypeControllerTest; |
569 friend class ::TestingProfile; | 567 friend class ::TestingProfile; |
570 friend scoped_ptr<HistoryService> CreateHistoryService( | 568 friend scoped_ptr<HistoryService> CreateHistoryService( |
571 const base::FilePath& history_dir, | 569 const base::FilePath& history_dir, bool create_db); |
572 const std::string& accept_languages, | |
573 bool create_db); | |
574 | 570 |
575 // Called on shutdown, this will tell the history backend to complete and | 571 // Called on shutdown, this will tell the history backend to complete and |
576 // will release pointers to it. No other functions should be called once | 572 // will release pointers to it. No other functions should be called once |
577 // cleanup has happened that may dispatch to the history thread (because it | 573 // cleanup has happened that may dispatch to the history thread (because it |
578 // will be null). | 574 // will be null). |
579 // | 575 // |
580 // In practice, this will be called by the service manager (BrowserProcess) | 576 // In practice, this will be called by the service manager (BrowserProcess) |
581 // when it is being destroyed. Because that reference is being destroyed, it | 577 // when it is being destroyed. Because that reference is being destroyed, it |
582 // should be impossible for anybody else to call the service, even if it is | 578 // should be impossible for anybody else to call the service, even if it is |
583 // still in memory (pending requests may be holding a reference to us). | 579 // still in memory (pending requests may be holding a reference to us). |
584 void Cleanup(); | 580 void Cleanup(); |
585 | 581 |
586 // Low-level Init(). Same as the public version, but adds a |no_db| parameter | 582 // Low-level Init(). Same as the public version, but adds a |no_db| parameter |
587 // that is only set by unittests which causes the backend to not init its DB. | 583 // that is only set by unittests which causes the backend to not init its DB. |
588 bool Init(bool no_db, | 584 bool Init(bool no_db, const HistoryDatabaseParams& history_database_params); |
589 const std::string& languages, | |
590 const HistoryDatabaseParams& history_database_params); | |
591 | 585 |
592 // Called by the HistoryURLProvider class to schedule an autocomplete, it | 586 // Called by the HistoryURLProvider class to schedule an autocomplete, it |
593 // will be called back on the internal history thread with the history | 587 // will be called back on the internal history thread with the history |
594 // database so it can query. See history_url_provider.h for a diagram. | 588 // database so it can query. See history_url_provider.h for a diagram. |
595 void ScheduleAutocomplete( | 589 void ScheduleAutocomplete( |
596 const base::Callback<void(HistoryBackend*, URLDatabase*)>& callback); | 590 const base::Callback<void(HistoryBackend*, URLDatabase*)>& callback); |
597 | 591 |
598 // Notification from the backend that it has finished loading. Sends | 592 // Notification from the backend that it has finished loading. Sends |
599 // notification (NOTIFY_HISTORY_LOADED) and sets backend_loaded_ to true. | 593 // notification (NOTIFY_HISTORY_LOADED) and sets backend_loaded_ to true. |
600 void OnDBLoaded(); | 594 void OnDBLoaded(); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 | 844 |
851 // All vended weak pointers are invalidated in Cleanup(). | 845 // All vended weak pointers are invalidated in Cleanup(). |
852 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; | 846 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; |
853 | 847 |
854 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 848 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
855 }; | 849 }; |
856 | 850 |
857 } // namespace history | 851 } // namespace history |
858 | 852 |
859 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ | 853 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_SERVICE_H_ |
OLD | NEW |