OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 UI_APP_LIST_SEARCH_HISTORY_DATA_H_ | 5 #ifndef UI_APP_LIST_SEARCH_HISTORY_DATA_H_ |
6 #define UI_APP_LIST_SEARCH_HISTORY_DATA_H_ | 6 #define UI_APP_LIST_SEARCH_HISTORY_DATA_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
12 #include <string> | 13 #include <string> |
13 | 14 |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "ui/app_list/app_list_export.h" | 19 #include "ui/app_list/app_list_export.h" |
20 #include "ui/app_list/search/history_types.h" | 20 #include "ui/app_list/search/history_types.h" |
21 | 21 |
22 namespace app_list { | 22 namespace app_list { |
23 | 23 |
24 class HistoryDataObserver; | 24 class HistoryDataObserver; |
25 class HistoryDataStore; | 25 class HistoryDataStore; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 HistoryData(HistoryDataStore* store, | 61 HistoryData(HistoryDataStore* store, |
62 size_t max_primary, | 62 size_t max_primary, |
63 size_t max_secondary); | 63 size_t max_secondary); |
64 ~HistoryData(); | 64 ~HistoryData(); |
65 | 65 |
66 // Adds an association. | 66 // Adds an association. |
67 void Add(const std::string& query, const std::string& result_id); | 67 void Add(const std::string& query, const std::string& result_id); |
68 | 68 |
69 // Gets all known search results that were launched using the given |query| | 69 // Gets all known search results that were launched using the given |query| |
70 // or the queries that |query| is a prefix of. | 70 // or the queries that |query| is a prefix of. |
71 scoped_ptr<KnownResults> GetKnownResults(const std::string& query) const; | 71 std::unique_ptr<KnownResults> GetKnownResults(const std::string& query) const; |
72 | 72 |
73 void AddObserver(HistoryDataObserver* observer); | 73 void AddObserver(HistoryDataObserver* observer); |
74 void RemoveObserver(HistoryDataObserver* observer); | 74 void RemoveObserver(HistoryDataObserver* observer); |
75 | 75 |
76 const Associations& associations() const { return associations_; } | 76 const Associations& associations() const { return associations_; } |
77 | 77 |
78 private: | 78 private: |
79 // Invoked from |store| with loaded data. | 79 // Invoked from |store| with loaded data. |
80 void OnStoreLoaded(scoped_ptr<Associations> loaded_data); | 80 void OnStoreLoaded(std::unique_ptr<Associations> loaded_data); |
81 | 81 |
82 // Trims the data to keep the most recent |max_primary_| queries. | 82 // Trims the data to keep the most recent |max_primary_| queries. |
83 void TrimEntries(); | 83 void TrimEntries(); |
84 | 84 |
85 HistoryDataStore* store_; // Not owned. | 85 HistoryDataStore* store_; // Not owned. |
86 const size_t max_primary_; | 86 const size_t max_primary_; |
87 const size_t max_secondary_; | 87 const size_t max_secondary_; |
88 base::ObserverList<HistoryDataObserver, true> observers_; | 88 base::ObserverList<HistoryDataObserver, true> observers_; |
89 | 89 |
90 Associations associations_; | 90 Associations associations_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(HistoryData); | 92 DISALLOW_COPY_AND_ASSIGN(HistoryData); |
93 }; | 93 }; |
94 | 94 |
95 } // namespace app_list | 95 } // namespace app_list |
96 | 96 |
97 #endif // UI_APP_LIST_SEARCH_HISTORY_DATA_H_ | 97 #endif // UI_APP_LIST_SEARCH_HISTORY_DATA_H_ |
OLD | NEW |