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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // thread that made the request. | 82 // thread that made the request. |
82 class HistoryService : public syncer::SyncableService, | 83 class HistoryService : public syncer::SyncableService, |
83 public KeyedService, | 84 public KeyedService, |
84 public visitedlink::VisitedLinkDelegate { | 85 public visitedlink::VisitedLinkDelegate { |
85 public: | 86 public: |
86 // Miscellaneous commonly-used types. | 87 // Miscellaneous commonly-used types. |
87 typedef std::vector<PageUsageData*> PageUsageDataList; | 88 typedef std::vector<PageUsageData*> PageUsageDataList; |
88 | 89 |
89 // Must call Init after construction. The |history::HistoryClient| object | 90 // Must call Init after construction. The |history::HistoryClient| object |
90 // must be valid for the whole lifetime of |HistoryService|. | 91 // must be valid for the whole lifetime of |HistoryService|. |
91 explicit HistoryService(history::HistoryClient* client, Profile* profile); | 92 HistoryService(history::HistoryClient* client, Profile* profile); |
92 // The empty constructor is provided only for testing. | 93 // The empty constructor is provided only for testing. |
93 HistoryService(); | 94 HistoryService(); |
94 | 95 |
95 ~HistoryService() override; | 96 ~HistoryService() override; |
96 | 97 |
97 // Initializes the history service, returning true on success. On false, do | 98 // Initializes the history service, returning true on success. On false, do |
98 // not call any other functions. The given directory will be used for storing | 99 // not call any other functions. The given directory will be used for storing |
99 // the history files. | 100 // the history files. |languages| is a comma-separated list of languages to |
100 bool Init(const history::HistoryDatabaseParams& history_database_params) { | 101 // use when interpreting URLs, it must not be empty (except during testing). |
101 return Init(false, history_database_params); | 102 bool Init(const std::string& languages, |
| 103 const history::HistoryDatabaseParams& history_database_params) { |
| 104 return Init(false, languages, history_database_params); |
102 } | 105 } |
103 | 106 |
104 // 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 |
105 // it's finished loading. | 108 // it's finished loading. |
106 // Note: Virtual needed for mocking. | 109 // Note: Virtual needed for mocking. |
107 virtual bool BackendLoaded(); | 110 virtual bool BackendLoaded(); |
108 | 111 |
109 // Returns true if the backend has finished loading. | 112 // Returns true if the backend has finished loading. |
110 bool backend_loaded() const { return backend_loaded_; } | 113 bool backend_loaded() const { return backend_loaded_; } |
111 | 114 |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 // 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 |
555 // 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). |
556 void Cleanup(); | 559 void Cleanup(); |
557 | 560 |
558 // Implementation of visitedlink::VisitedLinkDelegate. | 561 // Implementation of visitedlink::VisitedLinkDelegate. |
559 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override; | 562 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override; |
560 | 563 |
561 // 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 |
562 // 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. |
563 bool Init(bool no_db, | 566 bool Init(bool no_db, |
| 567 const std::string& languages, |
564 const history::HistoryDatabaseParams& history_database_params); | 568 const history::HistoryDatabaseParams& history_database_params); |
565 | 569 |
566 // Called by the HistoryURLProvider class to schedule an autocomplete, it | 570 // Called by the HistoryURLProvider class to schedule an autocomplete, it |
567 // 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 |
568 // 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. |
569 void ScheduleAutocomplete(const base::Callback< | 573 void ScheduleAutocomplete(const base::Callback< |
570 void(history::HistoryBackend*, history::URLDatabase*)>& callback); | 574 void(history::HistoryBackend*, history::URLDatabase*)>& callback); |
571 | 575 |
572 // Notification from the backend that it has finished loading. Sends | 576 // Notification from the backend that it has finished loading. Sends |
573 // notification (NOTIFY_HISTORY_LOADED) and sets backend_loaded_ to true. | 577 // notification (NOTIFY_HISTORY_LOADED) and sets backend_loaded_ to true. |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 | 842 |
839 history::DeleteDirectiveHandler delete_directive_handler_; | 843 history::DeleteDirectiveHandler delete_directive_handler_; |
840 | 844 |
841 // All vended weak pointers are invalidated in Cleanup(). | 845 // All vended weak pointers are invalidated in Cleanup(). |
842 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; | 846 base::WeakPtrFactory<HistoryService> weak_ptr_factory_; |
843 | 847 |
844 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 848 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
845 }; | 849 }; |
846 | 850 |
847 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 851 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
OLD | NEW |