Rename vector icon header files.
[chromium-blink-merge.git] / chrome / browser / predictors / autocomplete_action_predictor_table.h
blob5c2fb23a5f9e8799bdf3ef70766edb880ac11bc3
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_TABLE_H_
6 #define CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_TABLE_H_
8 #include <string>
9 #include <vector>
11 #include "base/strings/string16.h"
12 #include "chrome/browser/predictors/predictor_table_base.h"
13 #include "url/gurl.h"
15 namespace predictors {
17 // This manages the autocomplete predictor table within the SQLite database
18 // passed in to the constructor. It expects the following scheme:
20 // network_action_predictor
21 // id A unique id.
22 // user_text What the user typed.
23 // url The URL of the entry.
24 // number_of_hits Number of times the entry was shown to the user and
25 // selected.
26 // number_of_misses Number of times the entry was shown to the user but not
27 // selected.
29 // TODO(dominich): Consider adding this table to one of the history databases.
30 // In memory is currently used, but adding to the on-disk visits database
31 // would allow DeleteOldEntries to be cheaper through use of a join.
33 // All the functions apart from constructor and destructor have to be called in
34 // the DB thread.
35 class AutocompleteActionPredictorTable : public PredictorTableBase {
36 public:
37 struct Row {
38 // TODO(dominich): Make this 64-bit integer as an optimization. This
39 // requires some investigation into how to make sure the id is unique for
40 // each user_text/url pair.
41 // http://crbug.com/102020
42 typedef std::string Id;
44 Row();
46 // Only used by unit tests.
47 Row(const Id& id,
48 const base::string16& user_text,
49 const GURL& url,
50 int number_of_hits,
51 int number_of_misses);
53 Row(const Row& row);
55 Id id;
56 base::string16 user_text;
57 GURL url;
58 int number_of_hits;
59 int number_of_misses;
62 typedef std::vector<Row> Rows;
64 // DB thread functions.
65 void GetRow(const Row::Id& id, Row* row);
66 void GetAllRows(Rows* row_buffer);
67 void AddRow(const Row& row);
68 void UpdateRow(const Row& row);
69 void AddAndUpdateRows(const Rows& rows_to_add, const Rows& rows_to_update);
70 void DeleteRows(const std::vector<Row::Id>& id_list);
71 void DeleteAllRows();
73 private:
74 friend class PredictorDatabaseInternal;
76 AutocompleteActionPredictorTable();
77 ~AutocompleteActionPredictorTable() override;
79 // PredictorTableBase methods (DB thread).
80 void CreateTableIfNonExistent() override;
81 void LogDatabaseStats() override;
83 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictorTable);
86 } // namespace predictors
88 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_TABLE_H_