Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1441)

Side by Side Diff: chrome/browser/predictors/autocomplete_action_predictor.h

Issue 10548015: Reorder functions in AutocompleteActionPredictor so that if A calls B calls C, they're listed A, B,… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/predictors/autocomplete_action_predictor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ 5 #ifndef CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_
6 #define CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ 6 #define CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 typedef std::map<DBCacheKey, AutocompleteActionPredictorTable::Row::Id> 117 typedef std::map<DBCacheKey, AutocompleteActionPredictorTable::Row::Id>
118 DBIdCacheMap; 118 DBIdCacheMap;
119 119
120 static const int kMaximumDaysToKeepEntry; 120 static const int kMaximumDaysToKeepEntry;
121 121
122 // NotificationObserver 122 // NotificationObserver
123 virtual void Observe(int type, 123 virtual void Observe(int type,
124 const content::NotificationSource& source, 124 const content::NotificationSource& source,
125 const content::NotificationDetails& details) OVERRIDE; 125 const content::NotificationDetails& details) OVERRIDE;
126 126
127 // Removes all rows from the database and caches.
128 void DeleteAllRows();
129
130 // Removes rows from the database and caches that contain a URL in |rows|.
131 void DeleteRowsWithURLs(const history::URLRows& rows);
132
127 // Called when NOTIFICATION_OMNIBOX_OPENED_URL is observed. 133 // Called when NOTIFICATION_OMNIBOX_OPENED_URL is observed.
128 void OnOmniboxOpenedUrl(const AutocompleteLog& log); 134 void OnOmniboxOpenedUrl(const AutocompleteLog& log);
129 135
130 // Deletes any old or invalid entries from the local caches. |url_db| and 136 // Adds and updates rows in the database and caches.
131 // |id_list| must not be NULL. Every row id deleted will be added to id_list. 137 void AddAndUpdateRows(
132 void DeleteOldIdsFromCaches( 138 const AutocompleteActionPredictorTable::Rows& rows_to_add,
133 history::URLDatabase* url_db, 139 const AutocompleteActionPredictorTable::Rows& rows_to_update);
134 std::vector<AutocompleteActionPredictorTable::Row::Id>* id_list);
135
136 // Called to delete any old or invalid entries from the database. Called after
137 // the local caches are created once the history service is available.
138 void DeleteOldEntries(history::URLDatabase* url_db);
139 140
140 // Called to populate the local caches. This also calls DeleteOldEntries 141 // Called to populate the local caches. This also calls DeleteOldEntries
141 // if the history service is available, or registers for the notification of 142 // if the history service is available, or registers for the notification of
142 // it becoming available. 143 // it becoming available.
143 void CreateCaches( 144 void CreateCaches(
144 std::vector<AutocompleteActionPredictorTable::Row>* row_buffer); 145 std::vector<AutocompleteActionPredictorTable::Row>* row_buffer);
145 146
146 // Attempts to call DeleteOldEntries if the in-memory database has been loaded 147 // Attempts to call DeleteOldEntries if the in-memory database has been loaded
147 // by |service|. Returns success as a boolean. 148 // by |service|. Returns success as a boolean.
148 bool TryDeleteOldEntries(HistoryService* service); 149 bool TryDeleteOldEntries(HistoryService* service);
149 150
151 // Called to delete any old or invalid entries from the database. Called after
152 // the local caches are created once the history service is available.
153 void DeleteOldEntries(history::URLDatabase* url_db);
154
155 // Deletes any old or invalid entries from the local caches. |url_db| and
156 // |id_list| must not be NULL. Every row id deleted will be added to id_list.
157 void DeleteOldIdsFromCaches(
158 history::URLDatabase* url_db,
159 std::vector<AutocompleteActionPredictorTable::Row::Id>* id_list);
160
150 // Uses local caches to calculate an exact percentage prediction that the user 161 // Uses local caches to calculate an exact percentage prediction that the user
151 // will take a particular match given what they have typed. |is_in_db| is set 162 // will take a particular match given what they have typed. |is_in_db| is set
152 // to differentiate trivial zero results resulting from a match not being 163 // to differentiate trivial zero results resulting from a match not being
153 // found from actual zero results where the calculation returns 0.0. 164 // found from actual zero results where the calculation returns 0.0.
154 double CalculateConfidence(const string16& user_text, 165 double CalculateConfidence(const string16& user_text,
155 const AutocompleteMatch& match, 166 const AutocompleteMatch& match,
156 bool* is_in_db) const; 167 bool* is_in_db) const;
157 168
158 // Calculates the confidence for an entry in the DBCacheMap. 169 // Calculates the confidence for an entry in the DBCacheMap.
159 double CalculateConfidenceForDbEntry(DBCacheMap::const_iterator iter) const; 170 double CalculateConfidenceForDbEntry(DBCacheMap::const_iterator iter) const;
160 171
161 // Adds and updates rows in the database and caches.
162 void AddAndUpdateRows(
163 const AutocompleteActionPredictorTable::Rows& rows_to_add,
164 const AutocompleteActionPredictorTable::Rows& rows_to_update);
165
166 // Removes all rows from the database and caches.
167 void DeleteAllRows();
168
169 // Removes rows from the database and caches that contain a URL in |rows|.
170 void DeleteRowsWithURLs(const history::URLRows& rows);
171
172 Profile* profile_; 172 Profile* profile_;
173 scoped_refptr<AutocompleteActionPredictorTable> table_; 173 scoped_refptr<AutocompleteActionPredictorTable> table_;
174 content::NotificationRegistrar notification_registrar_; 174 content::NotificationRegistrar notification_registrar_;
175 175
176 // This is cleared after every Omnibox navigation. 176 // This is cleared after every Omnibox navigation.
177 std::vector<TransitionalMatch> transitional_matches_; 177 std::vector<TransitionalMatch> transitional_matches_;
178 178
179 // This allows us to predict the effect of confidence threshold changes on 179 // This allows us to predict the effect of confidence threshold changes on
180 // accuracy. 180 // accuracy. This is cleared after every omnibox navigation.
181 mutable std::vector<std::pair<GURL, double> > tracked_urls_; 181 mutable std::vector<std::pair<GURL, double> > tracked_urls_;
182 182
183 DBCacheMap db_cache_; 183 DBCacheMap db_cache_;
184 DBIdCacheMap db_id_cache_; 184 DBIdCacheMap db_id_cache_;
185 185
186 bool initialized_; 186 bool initialized_;
187 187
188 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor); 188 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor);
189 }; 189 };
190 190
191 } // namespace predictors 191 } // namespace predictors
192 192
193 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ 193 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/predictors/autocomplete_action_predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698