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

Side by Side Diff: components/omnibox/search_provider.h

Issue 470313004: [AiS] Use top local result for prefetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes. Created 6 years, 3 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
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 // This file contains the Search autocomplete provider. This provider is 5 // This file contains the Search autocomplete provider. This provider is
6 // responsible for all autocomplete entries that start with "Search <engine> 6 // responsible for all autocomplete entries that start with "Search <engine>
7 // for ...", including searching for the current input string, search 7 // for ...", including searching for the current input string, search
8 // history, and search suggestions. An instance of it gets created and 8 // history, and search suggestions. An instance of it gets created and
9 // managed by the autocomplete controller. 9 // managed by the autocomplete controller.
10 10
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 bool IsTopMatchSearchWithURLInput() const; 241 bool IsTopMatchSearchWithURLInput() const;
242 242
243 // Converts an appropriate number of navigation results in 243 // Converts an appropriate number of navigation results in
244 // |navigation_results| to matches and adds them to |matches|. 244 // |navigation_results| to matches and adds them to |matches|.
245 void AddNavigationResultsToMatches( 245 void AddNavigationResultsToMatches(
246 const SearchSuggestionParser::NavigationResults& navigation_results, 246 const SearchSuggestionParser::NavigationResults& navigation_results,
247 ACMatches* matches); 247 ACMatches* matches);
248 248
249 // Adds a match for each result in |results| to |map|. |is_keyword| indicates 249 // Adds a match for each result in |results| to |map|. |is_keyword| indicates
250 // whether the results correspond to the keyword provider or default provider. 250 // whether the results correspond to the keyword provider or default provider.
251 void AddHistoryResultsToMap(const HistoryResults& results, 251 void AddRawHistoryResultsToMap(const HistoryResults& results,
252 bool is_keyword, 252 bool is_keyword,
253 int did_not_accept_suggestion, 253 int did_not_accept_suggestion,
254 MatchMap* map); 254 MatchMap* map);
255
256 // Adds a match for each transformed result in |results| to |map|.
257 void AddTransformedHistoryResultsToMap(
258 const SearchSuggestionParser::SuggestResults& results,
259 int did_not_accept_suggestion,
260 MatchMap* map);
255 261
256 // Calculates relevance scores for all |results|. 262 // Calculates relevance scores for all |results|.
257 SearchSuggestionParser::SuggestResults ScoreHistoryResults( 263 SearchSuggestionParser::SuggestResults ScoreHistoryResults(
258 const HistoryResults& results, 264 const HistoryResults& results,
259 bool base_prevent_inline_autocomplete, 265 bool base_prevent_inline_autocomplete,
260 bool input_multiple_words, 266 bool input_multiple_words,
261 const base::string16& input_text, 267 const base::string16& input_text,
262 bool is_keyword); 268 bool is_keyword);
263 269
270 void ScoreHistoryResultsMultiWord(
Mark P 2014/09/16 22:24:55 I know what's bothering me. ScoreHistoryResultsMu
groby-ooo-7-16 2014/09/18 23:27:24 I'll stick with helper. I've spent 30 minutes with
271 const HistoryResults& results,
272 bool is_keyword,
273 SearchSuggestionParser::SuggestResults* scored_results);
274
264 // Adds matches for |results| to |map|. 275 // Adds matches for |results| to |map|.
265 void AddSuggestResultsToMap( 276 void AddSuggestResultsToMap(
266 const SearchSuggestionParser::SuggestResults& results, 277 const SearchSuggestionParser::SuggestResults& results,
267 const std::string& metadata, 278 const std::string& metadata,
268 MatchMap* map); 279 MatchMap* map);
269 280
270 // Gets the relevance score for the verbatim result. This value may be 281 // Gets the relevance score for the verbatim result. This value may be
271 // provided by the suggest server or calculated locally; if 282 // provided by the suggest server or calculated locally; if
272 // |relevance_from_server| is non-NULL, it will be set to indicate which of 283 // |relevance_from_server| is non-NULL, it will be set to indicate which of
273 // those is true. 284 // those is true.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 AutocompleteMatch NavigationToMatch( 318 AutocompleteMatch NavigationToMatch(
308 const SearchSuggestionParser::NavigationResult& navigation); 319 const SearchSuggestionParser::NavigationResult& navigation);
309 320
310 // Updates the value of |done_| from the internal state. 321 // Updates the value of |done_| from the internal state.
311 void UpdateDone(); 322 void UpdateDone();
312 323
313 // Obtains a session token, regenerating if necessary. 324 // Obtains a session token, regenerating if necessary.
314 std::string GetSessionToken(); 325 std::string GetSessionToken();
315 326
316 // Answers prefetch handling - finds previously displayed answer matching the 327 // Answers prefetch handling - finds previously displayed answer matching the
317 // current |input| and sets |prefetch_data_|. 328 // current top-scoring history result and sets |prefetch_data_|.
318 void DoAnswersQuery(const AutocompleteInput& input); 329 // This only happens if |input| is a prefix for the top-scoring result.
Mark P 2014/09/16 22:24:55 This comment is still not appropriate. It, for in
groby-ooo-7-16 2014/09/18 23:27:24 Hopefully, the new comment is a bit clearer.
330 AnswersQueryData FindAnswersPrefetchData(const base::string16& input);
319 331
320 // The amount of time to wait before sending a new suggest request after the 332 // The amount of time to wait before sending a new suggest request after the
321 // previous one. Non-const because some unittests modify this value. 333 // previous one. Non-const because some unittests modify this value.
322 static int kMinimumTimeBetweenSuggestQueriesMs; 334 static int kMinimumTimeBetweenSuggestQueriesMs;
323 335
324 AutocompleteProviderListener* listener_; 336 AutocompleteProviderListener* listener_;
325 337
326 // The number of suggest results that haven't yet arrived. If it's greater 338 // The number of suggest results that haven't yet arrived. If it's greater
327 // than 0, it indicates that one of the URLFetchers is still running. 339 // than 0, it indicates that one of the URLFetchers is still running.
328 int suggest_results_pending_; 340 int suggest_results_pending_;
329 341
330 // Maintains the TemplateURLs used. 342 // Maintains the TemplateURLs used.
331 Providers providers_; 343 Providers providers_;
332 344
333 // The user's input. 345 // The user's input.
334 AutocompleteInput input_; 346 AutocompleteInput input_;
335 347
336 // Input when searching against the keyword provider. 348 // Input when searching against the keyword provider.
337 AutocompleteInput keyword_input_; 349 AutocompleteInput keyword_input_;
338 350
339 // Searches in the user's history that begin with the input text. 351 // Searches in the user's history that begin with the input text.
340 HistoryResults keyword_history_results_; 352 HistoryResults raw_keyword_history_results_;
341 HistoryResults default_history_results_; 353 HistoryResults raw_default_history_results_;
354
355 // Scored searches in the user's history - based on |keyword_history_results_|
356 // or default_history_results_ as appropriate.
Mark P 2014/09/16 22:24:55 nit: be consistent about either using || or not.
groby-ooo-7-16 2014/09/18 23:27:24 Done.
357 SearchSuggestionParser::SuggestResults transformed_keyword_history_results_;
358 SearchSuggestionParser::SuggestResults transformed_default_history_results_;
342 359
343 // A timer to start a query to the suggest server after the user has stopped 360 // A timer to start a query to the suggest server after the user has stopped
344 // typing for long enough. 361 // typing for long enough.
345 base::OneShotTimer<SearchProvider> timer_; 362 base::OneShotTimer<SearchProvider> timer_;
346 363
347 // The time at which we sent a query to the suggest server. 364 // The time at which we sent a query to the suggest server.
348 base::TimeTicks time_suggest_request_sent_; 365 base::TimeTicks time_suggest_request_sent_;
349 366
350 // Fetchers used to retrieve results for the keyword and default providers. 367 // Fetchers used to retrieve results for the keyword and default providers.
351 scoped_ptr<net::URLFetcher> keyword_fetcher_; 368 scoped_ptr<net::URLFetcher> keyword_fetcher_;
(...skipping 15 matching lines...) Expand all
367 base::TimeTicks token_expiration_time_; 384 base::TimeTicks token_expiration_time_;
368 385
369 // Answers prefetch management. 386 // Answers prefetch management.
370 AnswersCache answers_cache_; // Cache for last answers seen. 387 AnswersCache answers_cache_; // Cache for last answers seen.
371 AnswersQueryData prefetch_data_; // Data to use for query prefetching. 388 AnswersQueryData prefetch_data_; // Data to use for query prefetching.
372 389
373 DISALLOW_COPY_AND_ASSIGN(SearchProvider); 390 DISALLOW_COPY_AND_ASSIGN(SearchProvider);
374 }; 391 };
375 392
376 #endif // COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_ 393 #endif // COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698