Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_ANSWERS_CACHE_H_ | |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_ANSWERS_CACHE_H_ | |
| 7 | |
| 8 #include <list> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/strings/string16.h" | |
| 12 | |
| 13 struct AnswersQueryData { | |
| 14 AnswersQueryData(); | |
| 15 AnswersQueryData(const base::string16& full_query_text, | |
| 16 const base::string16& query_type); | |
| 17 base::string16 full_query_text; | |
| 18 base::string16 query_type; | |
| 19 }; | |
| 20 | |
| 21 // Cache for the most-recently seen answer for AiS. | |
|
Peter Kasting
2014/08/11 22:15:33
Nit: Probably should spell out "AiS"
groby-ooo-7-16
2014/08/12 01:16:26
Done.
| |
| 22 class AnswersCache { | |
| 23 public: | |
| 24 explicit AnswersCache(size_t max_entries); | |
| 25 ~AnswersCache(); | |
| 26 | |
| 27 // Get the top answer query completion for the query term. The query data | |
|
Peter Kasting
2014/08/11 22:15:33
Nit: Get -> Gets (and similar below)
groby-ooo-7-16
2014/08/12 01:16:26
Done.
| |
| 28 // will contain empty query text and type if no matching data was found. | |
| 29 AnswersQueryData GetTopAnswerEntry(const base::string16& query); | |
| 30 | |
| 31 // Register a query that received an answer suggestion. | |
| 32 void UpdateRecentAnswers(const base::string16& full_query_text, | |
| 33 const base::string16& query_type); | |
| 34 | |
| 35 bool IsEmpty(); // Signal if cache is empty. | |
|
Peter Kasting
2014/08/11 22:15:33
Nit: Put the comment above the function.
groby-ooo-7-16
2014/08/12 01:16:26
Done.
| |
| 36 | |
| 37 private: | |
| 38 size_t max_entries_; | |
| 39 typedef std::list<AnswersQueryData> Cache; | |
|
Peter Kasting
2014/08/11 22:15:33
Did you consider a priority_queue (or queue or deq
groby-ooo-7-16
2014/08/12 01:16:26
I've considered a queue/priority_queue, yes. But
| |
| 40 Cache cache_; | |
| 41 | |
| 42 DISALLOW_COPY_AND_ASSIGN(AnswersCache); | |
| 43 }; | |
| 44 | |
| 45 #endif // CHROME_BROWSER_AUTOCOMPLETE_ANSWERS_CACHE_H_ | |
| OLD | NEW |