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

Side by Side Diff: chrome/browser/ui/app_list/search/mixer.h

Issue 621823004: Simplifies the structure of app_list search a bit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_MIXER_H_ 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_MIXER_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_MIXER_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_MIXER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 #include "chrome/browser/ui/app_list/search/history_types.h" 11 #include "chrome/browser/ui/app_list/search/history_types.h"
12 #include "ui/app_list/app_list_model.h" 12 #include "ui/app_list/app_list_model.h"
13 13
14 namespace app_list { 14 namespace app_list {
15 15
16 namespace test { 16 namespace test {
17 FORWARD_DECLARE_TEST(MixerTest, Publish); 17 FORWARD_DECLARE_TEST(MixerTest, Publish);
18 } 18 }
19 19
20 class ChromeSearchResult;
21 class SearchProvider; 20 class SearchProvider;
21 class SearchResult;
22 22
23 // Mixer collects results from providers, sorts them and publishes them to the 23 // Mixer collects results from providers, sorts them and publishes them to the
24 // SearchResults UI model. The targeted results have 6 slots to hold the 24 // SearchResults UI model. The targeted results have 6 slots to hold the
25 // result. These slots could be viewed as having three groups: main group 25 // result. These slots could be viewed as having three groups: main group
26 // (local apps and contacts), omnibox group and web store group. The 26 // (local apps and contacts), omnibox group and web store group. The
27 // main group takes no more than 4 slots. The web store takes no more than 2 27 // main group takes no more than 4 slots. The web store takes no more than 2
28 // slots. The omnibox group takes all the remaining slots. 28 // slots. The omnibox group takes all the remaining slots.
29 class Mixer { 29 class Mixer {
30 public: 30 public:
31 // The enum represents mixer groups. Note this must matches the order 31 // The enum represents mixer groups. Note this must matches the order
(...skipping 16 matching lines...) Expand all
48 48
49 // Collects the results, sorts and publishes them. 49 // Collects the results, sorts and publishes them.
50 void MixAndPublish(const KnownResults& known_results); 50 void MixAndPublish(const KnownResults& known_results);
51 51
52 private: 52 private:
53 FRIEND_TEST_ALL_PREFIXES(test::MixerTest, Publish); 53 FRIEND_TEST_ALL_PREFIXES(test::MixerTest, Publish);
54 54
55 // Used for sorting and mixing results. 55 // Used for sorting and mixing results.
56 struct SortData { 56 struct SortData {
57 SortData(); 57 SortData();
58 SortData(ChromeSearchResult* result, double score); 58 SortData(SearchResult* result, double score);
59 59
60 bool operator<(const SortData& other) const; 60 bool operator<(const SortData& other) const;
61 61
62 ChromeSearchResult* result; // Not owned. 62 SearchResult* result; // Not owned.
63 double score; 63 double score;
64 }; 64 };
65 typedef std::vector<Mixer::SortData> SortedResults; 65 typedef std::vector<Mixer::SortData> SortedResults;
66 66
67 class Group; 67 class Group;
68 typedef ScopedVector<Group> Groups; 68 typedef ScopedVector<Group> Groups;
69 69
70 // Publishes the given |new_results| to |ui_results|, deleting any existing 70 // Publishes the given |new_results| to |ui_results|, deleting any existing
71 // results that are not in |new_results|. Results that already exist in 71 // results that are not in |new_results|. Results that already exist in
72 // |ui_results| are reused to avoid flickering caused by icon reload. 72 // |ui_results| are reused to avoid flickering caused by icon reload.
73 static void Publish(const SortedResults& results, 73 static void Publish(const SortedResults& results,
74 AppListModel::SearchResults* ui_results); 74 AppListModel::SearchResults* ui_results);
75 75
76 // Removes duplicates from |results|. 76 // Removes duplicates from |results|.
77 static void RemoveDuplicates(SortedResults* results); 77 static void RemoveDuplicates(SortedResults* results);
78 78
79 void FetchResults(const KnownResults& known_results); 79 void FetchResults(const KnownResults& known_results);
80 80
81 AppListModel::SearchResults* ui_results_; // Not owned. 81 AppListModel::SearchResults* ui_results_; // Not owned.
82 Groups groups_; 82 Groups groups_;
83 83
84 DISALLOW_COPY_AND_ASSIGN(Mixer); 84 DISALLOW_COPY_AND_ASSIGN(Mixer);
85 }; 85 };
86 86
87 } // namespace app_list 87 } // namespace app_list
88 88
89 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_MIXER_H_ 89 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_MIXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698