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

Unified Diff: components/omnibox/browser/shortcut_match.h

Issue 1877833002: Optimize shortcuts provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes after review, round 1 Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/omnibox/browser/shortcut_match.h
diff --git a/components/omnibox/browser/shortcut_match.h b/components/omnibox/browser/shortcut_match.h
new file mode 100644
index 0000000000000000000000000000000000000000..468c551c950f31fe650e1bee9d52dbec05d85649
--- /dev/null
+++ b/components/omnibox/browser/shortcut_match.h
@@ -0,0 +1,37 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_OMNIBOX_BROWSER_SHORTCUT_MATCH_H_
+#define COMPONENTS_OMNIBOX_BROWSER_SHORTCUT_MATCH_H_
+
+#include <vector>
+
+#include "base/strings/string16.h"
+#include "components/omnibox/browser/shortcuts_backend.h"
+#include "url/gurl.h"
+
+// ShortcutMatch holds sufficient information about a single match from the
+// shortcut database to allow for destination deduping and relevance sorting.
+// After those stages the top matches are converted to the more heavyweight
+// AutocompleteMatch struct. Avoiding constructing the larger struct for every
+// such match can save significant time when there are many shortcut matches to
+// process.
+struct ShortcutMatch {
+ ShortcutMatch(int relevance,
+ const GURL& stripped_destination_url,
+ const ShortcutsDatabase::Shortcut* shortcut);
+ static bool DestinationsEqual(const ShortcutMatch& elem1,
Peter Kasting 2016/04/12 23:29:50 Nit: Since these two methods are each used just on
Alexander Yashkin 2016/04/13 09:29:36 Done, yet i had to inline this call to match_compa
+ const ShortcutMatch& elem2);
+ static bool MoreRelevant(const ShortcutMatch& elem1,
+ const ShortcutMatch& elem2);
+ int relevance;
+ GURL stripped_destination_url;
+ const ShortcutsDatabase::Shortcut* shortcut;
+ base::string16 contents;
+ AutocompleteMatch::Type type;
+};
+
+typedef std::vector<ShortcutMatch> ShortcutMatches;
+
+#endif // COMPONENTS_YANDEX_OMNIBOX_BROWSER_SHORTCUT_MATCH_H_

Powered by Google App Engine
This is Rietveld 408576698