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 <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/callback_list.h" | 15 #include "base/callback_list.h" |
15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // thread that made the request. | 84 // thread that made the request. |
84 class HistoryService : public syncer::SyncableService, | 85 class HistoryService : public syncer::SyncableService, |
85 public KeyedService, | 86 public KeyedService, |
86 public visitedlink::VisitedLinkDelegate { | 87 public visitedlink::VisitedLinkDelegate { |
87 public: | 88 public: |
88 // Miscellaneous commonly-used types. | 89 // Miscellaneous commonly-used types. |
89 typedef std::vector<PageUsageData*> PageUsageDataList; | 90 typedef std::vector<PageUsageData*> PageUsageDataList; |
90 | 91 |
91 // Must call Init after construction. The |history::HistoryClient| object | 92 // Must call Init after construction. The |history::HistoryClient| object |
92 // must be valid for the whole lifetime of |HistoryService|. | 93 // must be valid for the whole lifetime of |HistoryService|. |
93 explicit HistoryService(history::HistoryClient* client, Profile* profile); | 94 HistoryService(history::HistoryClient* client, Profile* profile); |
94 // The empty constructor is provided only for testing. | 95 // The empty constructor is provided only for testing. |
95 HistoryService(); | 96 HistoryService(); |
96 | 97 |
97 ~HistoryService() override; | 98 ~HistoryService() override; |
98 | 99 |
99 // Initializes the history service, returning true on success. On false, do | 100 // Initializes the history service, returning true on success. On false, do |
100 // 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 |
101 // the history files. | 102 // the history files. |
102 bool Init(const history::HistoryDatabaseParams& history_database_params) { | 103 bool Init(const std::string& languages, |
103 return Init(false, history_database_params); | 104 const history::HistoryDatabaseParams& history_database_params) { |
| 105 return Init(false, languages, history_database_params); |
104 } | 106 } |
105 | 107 |
106 // Triggers the backend to load if it hasn't already, and then returns whether | 108 // Triggers the backend to load if it hasn't already, and then returns whether |
107 // it's finished loading. | 109 // it's finished loading. |
108 // Note: Virtual needed for mocking. | 110 // Note: Virtual needed for mocking. |
109 virtual bool BackendLoaded(); | 111 virtual bool BackendLoaded(); |
110 | 112 |
111 // Returns true if the backend has finished loading. | 113 // Returns true if the backend has finished loading. |
112 bool backend_loaded() const { return backend_loaded_; } | 114 bool backend_loaded() const { return backend_loaded_; } |
113 | 115 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // should be impossible for anybody else to call the service, even if it is | 554 // should be impossible for anybody else to call the service, even if it is |
553 // still in memory (pending requests may be holding a reference to us). | 555 // still in memory (pending requests may be holding a reference to us). |
554 void Cleanup(); | 556 void Cleanup(); |
555 | 557 |
556 // Implementation of visitedlink::VisitedLinkDelegate. | 558 // Implementation of visitedlink::VisitedLinkDelegate. |
557 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override; | 559 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override; |
558 | 560 |
559 // Low-level Init(). Same as the public version, but adds a |no_db| parameter | 561 // Low-level Init(). Same as the public version, but adds a |no_db| parameter |
560 // that is only set by unittests which causes the backend to not init its DB. | 562 // that is only set by unittests which causes the backend to not init its DB. |
561 bool Init(bool no_db, | 563 bool Init(bool no_db, |
| 564 const std::string& languages, |
562 const history::HistoryDatabaseParams& history_database_params); | 565 const history::HistoryDatabaseParams& history_database_params); |
563 | 566 |
564 // Called by the HistoryURLProvider class to schedule an autocomplete, it | 567 // Called by the HistoryURLProvider class to schedule an autocomplete, it |
565 // will be called back on the internal history thread with the history | 568 // will be called back on the internal history thread with the history |
566 // database so it can query. See history_autocomplete.cc for a diagram. | 569 // database so it can query. See history_autocomplete.cc for a diagram. |
567 void ScheduleAutocomplete(const base::Callback< | 570 void ScheduleAutocomplete(const base::Callback< |
568 void(history::HistoryBackend*, history::URLDatabase*)>& callback); | 571 void(history::HistoryBackend*, history::URLDatabase*)>& callback); |
569 | 572 |
570 // Notification from the backend that it has finished loading. Sends | 573 // Notification from the backend that it has finished loading. Sends |
571 // notification (NOTIFY_HISTORY_LOADED) and sets backend_loaded_ to true. | 574 // notification (NOTIFY_HISTORY_LOADED) and sets backend_loaded_ to true. |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 | 839 |
837 history::DeleteDirectiveHandler delete_directive_handler_; | 840 history::DeleteDirectiveHandler delete_directive_handler_; |
838 | 841 |
839 // All vended weak pointers are invalidated in Cleanup(). | 842 // All vended weak pointers are invalidated in Cleanup(). |
840 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; | 843 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; |
841 | 844 |
842 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 845 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
843 }; | 846 }; |
844 | 847 |
845 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 848 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
OLD | NEW |