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

Side by Side Diff: components/omnibox/browser/search_provider.cc

Issue 1815653002: Revert of Add traces for main omnibox providers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "components/omnibox/browser/search_provider.h" 5 #include "components/omnibox/browser/search_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/base64.h" 12 #include "base/base64.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/i18n/break_iterator.h" 15 #include "base/i18n/break_iterator.h"
16 #include "base/i18n/case_conversion.h" 16 #include "base/i18n/case_conversion.h"
17 #include "base/json/json_string_value_serializer.h" 17 #include "base/json/json_string_value_serializer.h"
18 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
19 #include "base/metrics/user_metrics.h" 19 #include "base/metrics/user_metrics.h"
20 #include "base/rand_util.h" 20 #include "base/rand_util.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/trace_event/trace_event.h"
24 #include "components/data_use_measurement/core/data_use_user_data.h" 23 #include "components/data_use_measurement/core/data_use_user_data.h"
25 #include "components/history/core/browser/in_memory_database.h" 24 #include "components/history/core/browser/in_memory_database.h"
26 #include "components/history/core/browser/keyword_search_term.h" 25 #include "components/history/core/browser/keyword_search_term.h"
27 #include "components/metrics/proto/omnibox_input_type.pb.h" 26 #include "components/metrics/proto/omnibox_input_type.pb.h"
28 #include "components/omnibox/browser/autocomplete_provider_client.h" 27 #include "components/omnibox/browser/autocomplete_provider_client.h"
29 #include "components/omnibox/browser/autocomplete_provider_listener.h" 28 #include "components/omnibox/browser/autocomplete_provider_listener.h"
30 #include "components/omnibox/browser/autocomplete_result.h" 29 #include "components/omnibox/browser/autocomplete_result.h"
31 #include "components/omnibox/browser/keyword_provider.h" 30 #include "components/omnibox/browser/keyword_provider.h"
32 #include "components/omnibox/browser/omnibox_field_trial.h" 31 #include "components/omnibox/browser/omnibox_field_trial.h"
33 #include "components/omnibox/browser/suggestion_answer.h" 32 #include "components/omnibox/browser/suggestion_answer.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // static 212 // static
214 ACMatches::iterator SearchProvider::FindTopMatch(ACMatches* matches) { 213 ACMatches::iterator SearchProvider::FindTopMatch(ACMatches* matches) {
215 ACMatches::iterator it = matches->begin(); 214 ACMatches::iterator it = matches->begin();
216 while ((it != matches->end()) && !it->allowed_to_be_default_match) 215 while ((it != matches->end()) && !it->allowed_to_be_default_match)
217 ++it; 216 ++it;
218 return it; 217 return it;
219 } 218 }
220 219
221 void SearchProvider::Start(const AutocompleteInput& input, 220 void SearchProvider::Start(const AutocompleteInput& input,
222 bool minimal_changes) { 221 bool minimal_changes) {
223 TRACE_EVENT0("omnibox", "SearchProvider::Start");
224 // Do our best to load the model as early as possible. This will reduce 222 // Do our best to load the model as early as possible. This will reduce
225 // odds of having the model not ready when really needed (a non-empty input). 223 // odds of having the model not ready when really needed (a non-empty input).
226 TemplateURLService* model = client()->GetTemplateURLService(); 224 TemplateURLService* model = client()->GetTemplateURLService();
227 DCHECK(model); 225 DCHECK(model);
228 model->Load(); 226 model->Load();
229 227
230 matches_.clear(); 228 matches_.clear();
231 set_field_trial_triggered(false); 229 set_field_trial_triggered(false);
232 230
233 // Can't return search/suggest results for bogus input. 231 // Can't return search/suggest results for bogus input.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // Hence, it's always necessary to update matches to use the new template 380 // Hence, it's always necessary to update matches to use the new template
383 // URL. (One could cache the template URL and only call UpdateMatches() and 381 // URL. (One could cache the template URL and only call UpdateMatches() and
384 // OnProviderUpdate() if a keyword was deleted/renamed or the template URL 382 // OnProviderUpdate() if a keyword was deleted/renamed or the template URL
385 // was changed. That would save extra calls to these functions. However, 383 // was changed. That would save extra calls to these functions. However,
386 // this is uncommon and not likely to be worth the extra work.) 384 // this is uncommon and not likely to be worth the extra work.)
387 UpdateMatches(); 385 UpdateMatches();
388 listener_->OnProviderUpdate(true); // always pretend something changed 386 listener_->OnProviderUpdate(true); // always pretend something changed
389 } 387 }
390 388
391 void SearchProvider::OnURLFetchComplete(const net::URLFetcher* source) { 389 void SearchProvider::OnURLFetchComplete(const net::URLFetcher* source) {
392 TRACE_EVENT0("omnibox", "SearchProvider::OnURLFetchComplete");
393 DCHECK(!done_); 390 DCHECK(!done_);
394 const bool is_keyword = source == keyword_fetcher_.get(); 391 const bool is_keyword = source == keyword_fetcher_.get();
395 392
396 // Ensure the request succeeded and that the provider used is still available. 393 // Ensure the request succeeded and that the provider used is still available.
397 // A verbatim match cannot be generated without this provider, causing errors. 394 // A verbatim match cannot be generated without this provider, causing errors.
398 const bool request_succeeded = 395 const bool request_succeeded =
399 source->GetStatus().is_success() && (source->GetResponseCode() == 200) && 396 source->GetStatus().is_success() && (source->GetResponseCode() == 200) &&
400 GetTemplateURL(is_keyword); 397 GetTemplateURL(is_keyword);
401 398
402 LogFetchComplete(request_succeeded, is_keyword); 399 LogFetchComplete(request_succeeded, is_keyword);
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) 1508 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i)
1512 matches.push_back(i->second); 1509 matches.push_back(i->second);
1513 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); 1510 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant);
1514 1511
1515 // If there is a top scoring entry, find the corresponding answer. 1512 // If there is a top scoring entry, find the corresponding answer.
1516 if (!matches.empty()) 1513 if (!matches.empty())
1517 return answers_cache_.GetTopAnswerEntry(matches[0].contents); 1514 return answers_cache_.GetTopAnswerEntry(matches[0].contents);
1518 1515
1519 return AnswersQueryData(); 1516 return AnswersQueryData();
1520 } 1517 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/keyword_provider.cc ('k') | components/omnibox/browser/shortcuts_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698