OLD | NEW |
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 UI_APP_LIST_SEARCH_MIXER_H_ | 5 #ifndef UI_APP_LIST_SEARCH_MIXER_H_ |
6 #define UI_APP_LIST_SEARCH_MIXER_H_ | 6 #define UI_APP_LIST_SEARCH_MIXER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // result. The search controller can specify any number of groups, each with a | 28 // result. The search controller can specify any number of groups, each with a |
29 // different number of results and priority boost. The "omnibox" group is | 29 // different number of results and priority boost. The "omnibox" group is |
30 // expected to contain omnibox results, and will be treated specially. | 30 // expected to contain omnibox results, and will be treated specially. |
31 class APP_LIST_EXPORT Mixer { | 31 class APP_LIST_EXPORT Mixer { |
32 public: | 32 public: |
33 explicit Mixer(AppListModel::SearchResults* ui_results); | 33 explicit Mixer(AppListModel::SearchResults* ui_results); |
34 ~Mixer(); | 34 ~Mixer(); |
35 | 35 |
36 // Adds a new mixer group. A maximum of |max_results| results will be | 36 // Adds a new mixer group. A maximum of |max_results| results will be |
37 // displayed from this group (if 0, will allow unlimited results from this | 37 // displayed from this group (if 0, will allow unlimited results from this |
38 // group). Each result in the group will have its score boosted by |boost|. | 38 // group). Behaviour depends on the AppListMixer field trial: |
| 39 // - If default: Each result in the group will have its score boosted by |
| 40 // |boost|. |multiplier| is ignored. |
| 41 // - If "Blended": |max_results| is a "soft" maximum; if there aren't enough |
| 42 // results from all groups, more than |max_results| may be chosen from this |
| 43 // group. Each result in the group will have its score multiplied by |
| 44 // |multiplier|. |boost| is ignored. |
39 // Returns the group's group_id. | 45 // Returns the group's group_id. |
40 size_t AddGroup(size_t max_results, double boost); | 46 size_t AddGroup(size_t max_results, double boost, double multiplier); |
41 | 47 |
42 // Adds a new mixer group for the special "omnibox" group. This group will be | 48 // Adds a new mixer group for the special "omnibox" group. This group will be |
43 // treated specially by the Mixer (it will be truncated such that it fills the | 49 // treated specially by the Mixer (it will be truncated such that it fills the |
44 // remaining slots without overflowing, but with at least one result). A | 50 // remaining slots without overflowing, but with at least one result). A |
45 // maximum of one group should be added using this method. | 51 // maximum of one group should be added using this method. |
46 size_t AddOmniboxGroup(size_t max_results, double boost); | 52 size_t AddOmniboxGroup(size_t max_results, double boost, double multiplier); |
47 | 53 |
48 // Associates a provider with a mixer group. | 54 // Associates a provider with a mixer group. |
49 void AddProviderToGroup(size_t group_id, SearchProvider* provider); | 55 void AddProviderToGroup(size_t group_id, SearchProvider* provider); |
50 | 56 |
51 // Collects the results, sorts and publishes them. | 57 // Collects the results, sorts and publishes them. |
52 void MixAndPublish(bool is_voice_query, const KnownResults& known_results); | 58 void MixAndPublish(bool is_voice_query, const KnownResults& known_results); |
53 | 59 |
54 private: | 60 private: |
55 FRIEND_TEST_ALL_PREFIXES(test::MixerTest, Publish); | 61 FRIEND_TEST_ALL_PREFIXES(test::MixerTest, Publish); |
56 | 62 |
(...skipping 23 matching lines...) Expand all Loading... |
80 // NOTE: This is not necessarily the one with the highest *score*, as | 86 // NOTE: This is not necessarily the one with the highest *score*, as |
81 // |results| may not have been sorted yet. | 87 // |results| may not have been sorted yet. |
82 static void RemoveDuplicates(SortedResults* results); | 88 static void RemoveDuplicates(SortedResults* results); |
83 | 89 |
84 void FetchResults(bool is_voice_query, const KnownResults& known_results); | 90 void FetchResults(bool is_voice_query, const KnownResults& known_results); |
85 | 91 |
86 AppListModel::SearchResults* ui_results_; // Not owned. | 92 AppListModel::SearchResults* ui_results_; // Not owned. |
87 Groups groups_; | 93 Groups groups_; |
88 | 94 |
89 // The ID of the omnibox group. The group with this ID will be treated | 95 // The ID of the omnibox group. The group with this ID will be treated |
90 // specially by the Mixer. | 96 // specially by the Mixer. Ignored if the AppListMixer field trial is |
91 // TODO(mgiuca): Omnibox group should not be treated specially. | 97 // "Blended". |
| 98 // TODO(mgiuca): Remove this after the field trial is complete. |
92 size_t omnibox_group_ = 0; | 99 size_t omnibox_group_ = 0; |
93 // Whether |omnibox_group_| has been set. | 100 // Whether |omnibox_group_| has been set. |
94 bool has_omnibox_group_ = false; | 101 bool has_omnibox_group_ = false; |
95 | 102 |
96 DISALLOW_COPY_AND_ASSIGN(Mixer); | 103 DISALLOW_COPY_AND_ASSIGN(Mixer); |
97 }; | 104 }; |
98 | 105 |
99 } // namespace app_list | 106 } // namespace app_list |
100 | 107 |
101 #endif // UI_APP_LIST_SEARCH_MIXER_H_ | 108 #endif // UI_APP_LIST_SEARCH_MIXER_H_ |
OLD | NEW |