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