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

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: Moar review fixes. Created 6 years, 2 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // See UpdateMatches() for the use and explanation of this constraint 239 // See UpdateMatches() for the use and explanation of this constraint
240 // and other constraints enforced without the use of helper functions. 240 // and other constraints enforced without the use of helper functions.
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
Mark P 2014/09/25 22:36:45 nit: please revise this comment so as not to refer
groby-ooo-7-16 2014/09/26 00:20:42 Done.
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(bool is_keyword,
252 bool is_keyword, 252 int did_not_accept_suggestion,
253 int did_not_accept_suggestion, 253 MatchMap* map);
254 MatchMap* map); 254
255 // Adds a match for each transformed result in |results| to |map|.
256 void AddTransformedHistoryResultsToMap(
257 const SearchSuggestionParser::SuggestResults& results,
258 int did_not_accept_suggestion,
259 MatchMap* map);
255 260
256 // Calculates relevance scores for all |results|. 261 // Calculates relevance scores for all |results|.
257 SearchSuggestionParser::SuggestResults ScoreHistoryResults( 262 SearchSuggestionParser::SuggestResults ScoreHistoryResultsHelper(
258 const HistoryResults& results, 263 const HistoryResults& results,
259 bool base_prevent_inline_autocomplete, 264 bool base_prevent_inline_autocomplete,
260 bool input_multiple_words, 265 bool input_multiple_words,
261 const base::string16& input_text, 266 const base::string16& input_text,
262 bool is_keyword); 267 bool is_keyword);
263 268
269 // Calculates relevance scores for |results|, adjusting for boundary
270 // conditions around multi-word queries. (See inline comments in function
271 // definition for more details.)
272 void ScoreHistoryResults(
273 const HistoryResults& results,
274 bool is_keyword,
275 SearchSuggestionParser::SuggestResults* scored_results);
276
264 // Adds matches for |results| to |map|. 277 // Adds matches for |results| to |map|.
265 void AddSuggestResultsToMap( 278 void AddSuggestResultsToMap(
266 const SearchSuggestionParser::SuggestResults& results, 279 const SearchSuggestionParser::SuggestResults& results,
267 const std::string& metadata, 280 const std::string& metadata,
268 MatchMap* map); 281 MatchMap* map);
269 282
270 // Gets the relevance score for the verbatim result. This value may be 283 // Gets the relevance score for the verbatim result. This value may be
271 // provided by the suggest server or calculated locally; if 284 // provided by the suggest server or calculated locally; if
272 // |relevance_from_server| is non-NULL, it will be set to indicate which of 285 // |relevance_from_server| is non-NULL, it will be set to indicate which of
273 // those is true. 286 // those is true.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // Returns an AutocompleteMatch for a navigational suggestion. 319 // Returns an AutocompleteMatch for a navigational suggestion.
307 AutocompleteMatch NavigationToMatch( 320 AutocompleteMatch NavigationToMatch(
308 const SearchSuggestionParser::NavigationResult& navigation); 321 const SearchSuggestionParser::NavigationResult& navigation);
309 322
310 // Updates the value of |done_| from the internal state. 323 // Updates the value of |done_| from the internal state.
311 void UpdateDone(); 324 void UpdateDone();
312 325
313 // Obtains a session token, regenerating if necessary. 326 // Obtains a session token, regenerating if necessary.
314 std::string GetSessionToken(); 327 std::string GetSessionToken();
315 328
316 // Answers prefetch handling - finds previously displayed answer matching the 329 // Answers prefetch handling - finds the previously displayed answer matching
317 // current |input| and sets |prefetch_data_|. 330 // the current top-scoring history result. If there is a previous answer,
318 void DoAnswersQuery(const AutocompleteInput& input); 331 // returns the query data associated with it. Otherwise, returns an empty
332 // AnswersQueryData.
333 AnswersQueryData FindAnswersPrefetchData();
319 334
320 // The amount of time to wait before sending a new suggest request after the 335 // 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. 336 // previous one. Non-const because some unittests modify this value.
322 static int kMinimumTimeBetweenSuggestQueriesMs; 337 static int kMinimumTimeBetweenSuggestQueriesMs;
323 338
324 AutocompleteProviderListener* listener_; 339 AutocompleteProviderListener* listener_;
325 340
326 // The number of suggest results that haven't yet arrived. If it's greater 341 // 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. 342 // than 0, it indicates that one of the URLFetchers is still running.
328 int suggest_results_pending_; 343 int suggest_results_pending_;
329 344
330 // Maintains the TemplateURLs used. 345 // Maintains the TemplateURLs used.
331 Providers providers_; 346 Providers providers_;
332 347
333 // The user's input. 348 // The user's input.
334 AutocompleteInput input_; 349 AutocompleteInput input_;
335 350
336 // Input when searching against the keyword provider. 351 // Input when searching against the keyword provider.
337 AutocompleteInput keyword_input_; 352 AutocompleteInput keyword_input_;
338 353
339 // Searches in the user's history that begin with the input text. 354 // Searches in the user's history that begin with the input text.
340 HistoryResults keyword_history_results_; 355 HistoryResults raw_keyword_history_results_;
341 HistoryResults default_history_results_; 356 HistoryResults raw_default_history_results_;
357
358 // Scored searches in the user's history - based on |keyword_history_results_|
359 // or |default_history_results_| as appropriate.
360 SearchSuggestionParser::SuggestResults transformed_keyword_history_results_;
361 SearchSuggestionParser::SuggestResults transformed_default_history_results_;
342 362
343 // A timer to start a query to the suggest server after the user has stopped 363 // A timer to start a query to the suggest server after the user has stopped
344 // typing for long enough. 364 // typing for long enough.
345 base::OneShotTimer<SearchProvider> timer_; 365 base::OneShotTimer<SearchProvider> timer_;
346 366
347 // The time at which we sent a query to the suggest server. 367 // The time at which we sent a query to the suggest server.
348 base::TimeTicks time_suggest_request_sent_; 368 base::TimeTicks time_suggest_request_sent_;
349 369
350 // Fetchers used to retrieve results for the keyword and default providers. 370 // Fetchers used to retrieve results for the keyword and default providers.
351 scoped_ptr<net::URLFetcher> keyword_fetcher_; 371 scoped_ptr<net::URLFetcher> keyword_fetcher_;
(...skipping 15 matching lines...) Expand all
367 base::TimeTicks token_expiration_time_; 387 base::TimeTicks token_expiration_time_;
368 388
369 // Answers prefetch management. 389 // Answers prefetch management.
370 AnswersCache answers_cache_; // Cache for last answers seen. 390 AnswersCache answers_cache_; // Cache for last answers seen.
371 AnswersQueryData prefetch_data_; // Data to use for query prefetching. 391 AnswersQueryData prefetch_data_; // Data to use for query prefetching.
372 392
373 DISALLOW_COPY_AND_ASSIGN(SearchProvider); 393 DISALLOW_COPY_AND_ASSIGN(SearchProvider);
374 }; 394 };
375 395
376 #endif // COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_ 396 #endif // COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider_unittest.cc ('k') | components/omnibox/search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698