Commit 9aa69c91 authored by calamity's avatar calamity Committed by Commit bot

Add Apps.AppListSearchResultDistanceFromOrigin UMA stat.

This CL adds a UMA stat that tracks how far an opened app list search
result is from the top left of the search results view. This will provide
information on the quality of search result ranking.

BUG=485449

Review URL: https://codereview.chromium.org/1132943004

Cr-Commit-Position: refs/heads/master@{#329368}
parent 98291957
...@@ -533,6 +533,14 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -533,6 +533,14 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary> </summary>
</histogram> </histogram>
<histogram name="Apps.AppListSearchResultDistanceFromOrigin" units="keystrokes">
<owner>calamity@chromium.org</owner>
<summary>
The minimum number of arrow keys a user would need to press to navigate to
the opened search result. This is gathered per click of a search result.
</summary>
</histogram>
<histogram name="Apps.AppListSearchResultOpenDisplayType" <histogram name="Apps.AppListSearchResultOpenDisplayType"
enum="AppListSearchResultDisplayType"> enum="AppListSearchResultDisplayType">
<owner>calamity@chromium.org</owner> <owner>calamity@chromium.org</owner>
...@@ -132,6 +132,11 @@ const char kSearchResultOpenDisplayTypeHistogram[] = ...@@ -132,6 +132,11 @@ const char kSearchResultOpenDisplayTypeHistogram[] =
// opened. // opened.
const char kSearchQueryLength[] = "Apps.AppListSearchQueryLength"; const char kSearchQueryLength[] = "Apps.AppListSearchQueryLength";
// The UMA histogram that logs the Manhattan distance from the origin of the
// search results to the selected result.
const char kSearchResultDistanceFromOrigin[] =
"Apps.AppListSearchResultDistanceFromOrigin";
#if defined(OS_LINUX) #if defined(OS_LINUX)
#if defined(GOOGLE_CHROME_BUILD) #if defined(GOOGLE_CHROME_BUILD)
const char kAppListWMClass[] = "chrome_app_list"; const char kAppListWMClass[] = "chrome_app_list";
......
...@@ -83,6 +83,7 @@ APP_LIST_EXPORT extern const ui::ResourceBundle::FontStyle kItemTextFontStyle; ...@@ -83,6 +83,7 @@ APP_LIST_EXPORT extern const ui::ResourceBundle::FontStyle kItemTextFontStyle;
APP_LIST_EXPORT extern const char kPageOpenedHistogram[]; APP_LIST_EXPORT extern const char kPageOpenedHistogram[];
APP_LIST_EXPORT extern const char kSearchResultOpenDisplayTypeHistogram[]; APP_LIST_EXPORT extern const char kSearchResultOpenDisplayTypeHistogram[];
APP_LIST_EXPORT extern const char kSearchQueryLength[]; APP_LIST_EXPORT extern const char kSearchQueryLength[];
APP_LIST_EXPORT extern const char kSearchResultDistanceFromOrigin[];
#if defined(OS_LINUX) #if defined(OS_LINUX)
// The WM_CLASS name for the app launcher window on Linux. // The WM_CLASS name for the app launcher window on Linux.
......
...@@ -84,6 +84,11 @@ void SearchController::OpenResult(SearchResult* result, int event_flags) { ...@@ -84,6 +84,11 @@ void SearchController::OpenResult(SearchResult* result, int event_flags) {
UMA_HISTOGRAM_COUNTS_100(kSearchQueryLength, search_box_->text().size()); UMA_HISTOGRAM_COUNTS_100(kSearchQueryLength, search_box_->text().size());
if (result->distance_from_origin() >= 0) {
UMA_HISTOGRAM_COUNTS_100(kSearchResultDistanceFromOrigin,
result->distance_from_origin());
}
result->Open(event_flags); result->Open(event_flags);
if (history_ && history_->IsReady()) { if (history_ && history_->IsReady()) {
......
...@@ -32,6 +32,7 @@ SearchResult::Action::~Action() {} ...@@ -32,6 +32,7 @@ SearchResult::Action::~Action() {}
SearchResult::SearchResult() SearchResult::SearchResult()
: relevance_(0), : relevance_(0),
display_type_(DISPLAY_LIST), display_type_(DISPLAY_LIST),
distance_from_origin_(-1),
voice_result_(false), voice_result_(false),
is_installing_(false), is_installing_(false),
percent_downloaded_(0) { percent_downloaded_(0) {
......
...@@ -113,6 +113,11 @@ class APP_LIST_EXPORT SearchResult { ...@@ -113,6 +113,11 @@ class APP_LIST_EXPORT SearchResult {
display_type_ = display_type; display_type_ = display_type;
} }
int distance_from_origin() { return distance_from_origin_; }
void set_distance_from_origin(int distance) {
distance_from_origin_ = distance;
}
const Actions& actions() const { const Actions& actions() const {
return actions_; return actions_;
} }
...@@ -180,6 +185,10 @@ class APP_LIST_EXPORT SearchResult { ...@@ -180,6 +185,10 @@ class APP_LIST_EXPORT SearchResult {
double relevance_; double relevance_;
DisplayType display_type_; DisplayType display_type_;
// The Manhattan distance from the origin of all search results to this
// result. This is logged for UMA.
int distance_from_origin_;
Actions actions_; Actions actions_;
bool voice_result_; bool voice_result_;
......
...@@ -61,6 +61,10 @@ void SearchResultContainerView::ScheduleUpdate() { ...@@ -61,6 +61,10 @@ void SearchResultContainerView::ScheduleUpdate() {
} }
} }
bool SearchResultContainerView::UpdateScheduled() {
return update_factory_.HasWeakPtrs();
}
void SearchResultContainerView::ListItemsAdded(size_t start, size_t count) { void SearchResultContainerView::ListItemsAdded(size_t start, size_t count) {
ScheduleUpdate(); ScheduleUpdate();
} }
...@@ -79,10 +83,10 @@ void SearchResultContainerView::ListItemsChanged(size_t start, size_t count) { ...@@ -79,10 +83,10 @@ void SearchResultContainerView::ListItemsChanged(size_t start, size_t count) {
} }
void SearchResultContainerView::DoUpdate() { void SearchResultContainerView::DoUpdate() {
update_factory_.InvalidateWeakPtrs();
num_results_ = Update(); num_results_ = Update();
Layout(); Layout();
PreferredSizeChanged(); PreferredSizeChanged();
update_factory_.InvalidateWeakPtrs();
} }
} // namespace app_list } // namespace app_list
...@@ -43,10 +43,22 @@ class APP_LIST_EXPORT SearchResultContainerView : public views::View, ...@@ -43,10 +43,22 @@ class APP_LIST_EXPORT SearchResultContainerView : public views::View,
void set_container_score(double score) { container_score_ = score; } void set_container_score(double score) { container_score_ = score; }
double container_score() const { return container_score_; } double container_score() const { return container_score_; }
// Updates the distance_from_origin() properties of the results in this
// container. |y_index| is the absolute y-index of the first result of this
// container (counting from the top of the app list).
virtual void NotifyFirstResultYIndex(int y_index) = 0;
// Gets the number of down keystrokes from the beginning to the end of this
// container.
virtual int GetYSize() = 0;
// Schedules an Update call using |update_factory_|. Do nothing if there is a // Schedules an Update call using |update_factory_|. Do nothing if there is a
// pending call. // pending call.
void ScheduleUpdate(); void ScheduleUpdate();
// Returns whether an update is currently scheduled for this container.
bool UpdateScheduled();
// Overridden from ui::ListModelObserver: // Overridden from ui::ListModelObserver:
void ListItemsAdded(size_t start, size_t count) override; void ListItemsAdded(size_t start, size_t count) override;
void ListItemsRemoved(size_t start, size_t count) override; void ListItemsRemoved(size_t start, size_t count) override;
......
...@@ -144,6 +144,15 @@ void SearchResultListView::OnContainerSelected(bool from_bottom, ...@@ -144,6 +144,15 @@ void SearchResultListView::OnContainerSelected(bool from_bottom,
SetSelectedIndex(from_bottom ? num_results() - 1 : 0); SetSelectedIndex(from_bottom ? num_results() - 1 : 0);
} }
void SearchResultListView::NotifyFirstResultYIndex(int y_index) {
for (size_t i = 0; i < static_cast<size_t>(num_results()); ++i)
GetResultViewAt(i)->result()->set_distance_from_origin(i + y_index);
}
int SearchResultListView::GetYSize() {
return num_results();
}
int SearchResultListView::Update() { int SearchResultListView::Update() {
std::vector<SearchResult*> display_results = std::vector<SearchResult*> display_results =
AppListModel::FilterSearchResultsByDisplayType( AppListModel::FilterSearchResultsByDisplayType(
......
...@@ -55,6 +55,8 @@ class APP_LIST_EXPORT SearchResultListView : public gfx::AnimationDelegate, ...@@ -55,6 +55,8 @@ class APP_LIST_EXPORT SearchResultListView : public gfx::AnimationDelegate,
// Overridden from SearchResultContainerView: // Overridden from SearchResultContainerView:
void OnContainerSelected(bool from_bottom, void OnContainerSelected(bool from_bottom,
bool directional_movement) override; bool directional_movement) override;
void NotifyFirstResultYIndex(int y_index) override;
int GetYSize() override;
private: private:
friend class test::SearchResultListViewTest; friend class test::SearchResultListViewTest;
......
...@@ -157,9 +157,17 @@ void SearchResultPageView::ChildPreferredSizeChanged(views::View* child) { ...@@ -157,9 +157,17 @@ void SearchResultPageView::ChildPreferredSizeChanged(views::View* child) {
return a->container_score() > b->container_score(); return a->container_score() > b->container_score();
}); });
int result_y_index = 0;
for (size_t i = 0; i < result_container_views_.size(); ++i) { for (size_t i = 0; i < result_container_views_.size(); ++i) {
result_container_views_[i]->ClearSelectedIndex(); SearchResultContainerView* view = result_container_views_[i];
ReorderChildView(result_container_views_[i]->parent(), i); view->ClearSelectedIndex();
ReorderChildView(view->parent(), i);
// Only notify containers that have finished updating.
if (!view->UpdateScheduled())
view->NotifyFirstResultYIndex(result_y_index);
result_y_index += view->GetYSize();
} }
} }
......
...@@ -58,6 +58,15 @@ void SearchResultTileItemListView::OnContainerSelected( ...@@ -58,6 +58,15 @@ void SearchResultTileItemListView::OnContainerSelected(
SetSelectedIndex(select_last ? num_results() - 1 : 0); SetSelectedIndex(select_last ? num_results() - 1 : 0);
} }
void SearchResultTileItemListView::NotifyFirstResultYIndex(int y_index) {
for (size_t i = 0; i < static_cast<size_t>(num_results()); ++i)
tile_views_[i]->result()->set_distance_from_origin(i + y_index);
}
int SearchResultTileItemListView::GetYSize() {
return num_results() ? 1 : 0;
}
int SearchResultTileItemListView::Update() { int SearchResultTileItemListView::Update() {
std::vector<SearchResult*> display_results = std::vector<SearchResult*> display_results =
AppListModel::FilterSearchResultsByDisplayType( AppListModel::FilterSearchResultsByDisplayType(
......
...@@ -30,6 +30,8 @@ class APP_LIST_EXPORT SearchResultTileItemListView ...@@ -30,6 +30,8 @@ class APP_LIST_EXPORT SearchResultTileItemListView
// Overridden from SearchResultContainerView: // Overridden from SearchResultContainerView:
void OnContainerSelected(bool from_bottom, void OnContainerSelected(bool from_bottom,
bool directional_movement) override; bool directional_movement) override;
void NotifyFirstResultYIndex(int y_index) override;
int GetYSize() override;
// Overridden from views::View: // Overridden from views::View:
bool OnKeyPressed(const ui::KeyEvent& event) override; bool OnKeyPressed(const ui::KeyEvent& event) override;
......
...@@ -29,6 +29,7 @@ class APP_LIST_EXPORT SearchResultTileItemView ...@@ -29,6 +29,7 @@ class APP_LIST_EXPORT SearchResultTileItemView
AppListViewDelegate* view_delegate); AppListViewDelegate* view_delegate);
~SearchResultTileItemView() override; ~SearchResultTileItemView() override;
SearchResult* result() { return item_; }
void SetSearchResult(SearchResult* item); void SetSearchResult(SearchResult* item);
// Overridden from TileItemView: // Overridden from TileItemView:
......
...@@ -126,6 +126,8 @@ class StartPageView::StartPageTilesContainer ...@@ -126,6 +126,8 @@ class StartPageView::StartPageTilesContainer
void UpdateSelectedIndex(int old_selected, int new_selected) override; void UpdateSelectedIndex(int old_selected, int new_selected) override;
void OnContainerSelected(bool from_bottom, void OnContainerSelected(bool from_bottom,
bool directional_movement) override; bool directional_movement) override;
void NotifyFirstResultYIndex(int y_index) override;
int GetYSize() override;
private: private:
ContentsView* contents_view_; ContentsView* contents_view_;
...@@ -218,6 +220,17 @@ void StartPageView::StartPageTilesContainer::UpdateSelectedIndex( ...@@ -218,6 +220,17 @@ void StartPageView::StartPageTilesContainer::UpdateSelectedIndex(
void StartPageView::StartPageTilesContainer::OnContainerSelected( void StartPageView::StartPageTilesContainer::OnContainerSelected(
bool /*from_bottom*/, bool /*from_bottom*/,
bool /*directional_movement*/) { bool /*directional_movement*/) {
NOTREACHED();
}
void StartPageView::StartPageTilesContainer::NotifyFirstResultYIndex(
int /*y_index*/) {
NOTREACHED();
}
int StartPageView::StartPageTilesContainer::GetYSize() {
NOTREACHED();
return 0;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment