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

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

Issue 1805363002: Add traces for main omnibox providers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TBR=oysteine@chromium.org 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 (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 #include "components/omnibox/browser/shortcuts_provider.h" 5 #include "components/omnibox/browser/shortcuts_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <map> 11 #include <map>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/i18n/break_iterator.h" 14 #include "base/i18n/break_iterator.h"
15 #include "base/i18n/case_conversion.h" 15 #include "base/i18n/case_conversion.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "base/trace_event/trace_event.h"
22 #include "components/history/core/browser/history_service.h" 23 #include "components/history/core/browser/history_service.h"
23 #include "components/metrics/proto/omnibox_input_type.pb.h" 24 #include "components/metrics/proto/omnibox_input_type.pb.h"
24 #include "components/omnibox/browser/autocomplete_i18n.h" 25 #include "components/omnibox/browser/autocomplete_i18n.h"
25 #include "components/omnibox/browser/autocomplete_input.h" 26 #include "components/omnibox/browser/autocomplete_input.h"
26 #include "components/omnibox/browser/autocomplete_match.h" 27 #include "components/omnibox/browser/autocomplete_match.h"
27 #include "components/omnibox/browser/autocomplete_provider_client.h" 28 #include "components/omnibox/browser/autocomplete_provider_client.h"
28 #include "components/omnibox/browser/autocomplete_result.h" 29 #include "components/omnibox/browser/autocomplete_result.h"
29 #include "components/omnibox/browser/history_provider.h" 30 #include "components/omnibox/browser/history_provider.h"
30 #include "components/omnibox/browser/omnibox_field_trial.h" 31 #include "components/omnibox/browser/omnibox_field_trial.h"
31 #include "components/omnibox/browser/url_prefix.h" 32 #include "components/omnibox/browser/url_prefix.h"
(...skipping 26 matching lines...) Expand all
58 scoped_refptr<ShortcutsBackend> backend = client_->GetShortcutsBackend(); 59 scoped_refptr<ShortcutsBackend> backend = client_->GetShortcutsBackend();
59 if (backend.get()) { 60 if (backend.get()) {
60 backend->AddObserver(this); 61 backend->AddObserver(this);
61 if (backend->initialized()) 62 if (backend->initialized())
62 initialized_ = true; 63 initialized_ = true;
63 } 64 }
64 } 65 }
65 66
66 void ShortcutsProvider::Start(const AutocompleteInput& input, 67 void ShortcutsProvider::Start(const AutocompleteInput& input,
67 bool minimal_changes) { 68 bool minimal_changes) {
69 TRACE_EVENT0("omnibox", "ShortcutsProvider::Start");
68 matches_.clear(); 70 matches_.clear();
69 71
70 if (input.from_omnibox_focus() || 72 if (input.from_omnibox_focus() ||
71 (input.type() == metrics::OmniboxInputType::INVALID) || 73 (input.type() == metrics::OmniboxInputType::INVALID) ||
72 (input.type() == metrics::OmniboxInputType::FORCED_QUERY) || 74 (input.type() == metrics::OmniboxInputType::FORCED_QUERY) ||
73 input.text().empty() || !initialized_) 75 input.text().empty() || !initialized_)
74 return; 76 return;
75 77
76 base::TimeTicks start_time = base::TimeTicks::Now(); 78 base::TimeTicks start_time = base::TimeTicks::Now();
77 GetMatches(input); 79 GetMatches(input);
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 const double kMaxDecaySpeedDivisor = 5.0; 416 const double kMaxDecaySpeedDivisor = 5.0;
415 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0; 417 const double kNumUsesPerDecaySpeedDivisorIncrement = 5.0;
416 double decay_divisor = std::min( 418 double decay_divisor = std::min(
417 kMaxDecaySpeedDivisor, 419 kMaxDecaySpeedDivisor,
418 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) / 420 (shortcut.number_of_hits + kNumUsesPerDecaySpeedDivisorIncrement - 1) /
419 kNumUsesPerDecaySpeedDivisorIncrement); 421 kNumUsesPerDecaySpeedDivisorIncrement);
420 422
421 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) + 423 return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) +
422 0.5); 424 0.5);
423 } 425 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/search_provider.cc ('k') | components/omnibox/browser/zero_suggest_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698