Skip to content

Commit

Permalink
chromeos: moves metrics function back onto metrics classes
Browse files Browse the repository at this point in the history
The plan for metrics is to make all the histogram macros and what not
redirect to a service as appropriate. So, this means we can nuke the
calls to ShellPort and instead call directly to the metrics classes.

BUG=671246
TEST=none

Change-Id: I8fa7e45f48b20815e1afeb911bd876f19abffbfc
Reviewed-on: https://chromium-review.googlesource.com/546845
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Elliot Glaysher <erg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#482284}
  • Loading branch information
Scott Violet authored and Commit Bot committed Jun 26, 2017
1 parent e3095a7 commit 41562d1
Show file tree
Hide file tree
Showing 49 changed files with 164 additions and 182 deletions.
6 changes: 3 additions & 3 deletions ash/accelerators/exit_warning_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#include "ash/accelerators/exit_warning_handler.h"

#include "ash/metrics/user_metrics_recorder.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_port.h"
#include "ash/strings/grit/ash_strings.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
Expand Down Expand Up @@ -100,13 +100,13 @@ void ExitWarningHandler::HandleAccelerator() {
state_ = WAIT_FOR_DOUBLE_PRESS;
Show();
StartTimer();
ShellPort::Get()->RecordUserMetricsAction(UMA_ACCEL_EXIT_FIRST_Q);
Shell::Get()->metrics()->RecordUserMetricsAction(UMA_ACCEL_EXIT_FIRST_Q);
break;
case WAIT_FOR_DOUBLE_PRESS:
state_ = EXITING;
CancelTimer();
Hide();
ShellPort::Get()->RecordUserMetricsAction(UMA_ACCEL_EXIT_SECOND_Q);
Shell::Get()->metrics()->RecordUserMetricsAction(UMA_ACCEL_EXIT_SECOND_Q);
Shell::Get()->shell_delegate()->Exit();
break;
case EXITING:
Expand Down
14 changes: 0 additions & 14 deletions ash/aura/shell_port_classic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
#include "ash/keyboard/keyboard_ui.h"
#include "ash/laser/laser_pointer_controller.h"
#include "ash/magnifier/partial_magnification_controller.h"
#include "ash/metrics/task_switch_metrics_recorder.h"
#include "ash/public/cpp/config.h"
#include "ash/shared/immersive_fullscreen_controller.h"
#include "ash/shell.h"
#include "ash/touch/touch_uma.h"
#include "ash/virtual_keyboard_controller.h"
#include "ash/wm/drag_window_resizer.h"
#include "ash/wm/maximize_mode/maximize_mode_event_handler_aura.h"
Expand Down Expand Up @@ -101,18 +99,6 @@ bool ShellPortClassic::IsMouseEventsEnabled() {
return Shell::Get()->cursor_manager()->IsMouseEventsEnabled();
}

void ShellPortClassic::RecordUserMetricsAction(UserMetricsAction action) {
Shell::Get()->metrics()->RecordUserMetricsAction(action);
}

void ShellPortClassic::RecordGestureAction(GestureActionType action) {
TouchUMA::GetInstance()->RecordGestureAction(action);
}

void ShellPortClassic::RecordTaskSwitchMetric(TaskSwitchSource source) {
Shell::Get()->metrics()->task_switch_metrics_recorder().OnTaskSwitch(source);
}

std::unique_ptr<WindowResizer> ShellPortClassic::CreateDragWindowResizer(
std::unique_ptr<WindowResizer> next_window_resizer,
wm::WindowState* window_state) {
Expand Down
3 changes: 0 additions & 3 deletions ash/aura/shell_port_classic.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class ASH_EXPORT ShellPortClassic : public ShellPort {
void SetCursorSize(ui::CursorSize cursor_size) override;
void SetGlobalOverrideCursor(base::Optional<ui::CursorData> cursor) override;
bool IsMouseEventsEnabled() override;
void RecordGestureAction(GestureActionType action) override;
void RecordUserMetricsAction(UserMetricsAction action) override;
void RecordTaskSwitchMetric(TaskSwitchSource source) override;
std::unique_ptr<WindowResizer> CreateDragWindowResizer(
std::unique_ptr<WindowResizer> next_window_resizer,
wm::WindowState* window_state) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

#include "ash/frame/caption_buttons/frame_caption_button.h"
#include "ash/frame/caption_buttons/frame_size_button.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/shell.h"
#include "ash/shell_port.h"
#include "ash/touch/touch_uma.h"
#include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "ui/base/hit_test.h"
#include "ui/base/l10n/l10n_util.h"
Expand Down Expand Up @@ -334,7 +335,7 @@ void FrameCaptionButtonContainerView::ButtonPressed(views::Button* sender,
}

if (event.IsGestureEvent())
ShellPort::Get()->RecordGestureAction(GESTURE_FRAMEMAXIMIZE_TAP);
TouchUMA::GetInstance()->RecordGestureAction(GESTURE_FRAMEMAXIMIZE_TAP);
} else if (sender == close_button_) {
frame_->Close();
action = UMA_WINDOW_CLOSE_BUTTON_CLICK;
Expand All @@ -346,7 +347,7 @@ void FrameCaptionButtonContainerView::ButtonPressed(views::Button* sender,
} else {
return;
}
ShellPort::Get()->RecordUserMetricsAction(action);
Shell::Get()->metrics()->RecordUserMetricsAction(action);
}

bool FrameCaptionButtonContainerView::IsMinimizeButtonVisible() const {
Expand Down
5 changes: 3 additions & 2 deletions ash/frame/caption_buttons/frame_size_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

#include "ash/frame/caption_buttons/frame_size_button.h"

#include "ash/shell_port.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/shell.h"
#include "ash/wm/window_positioning_utils.h"
#include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h"
Expand Down Expand Up @@ -251,7 +252,7 @@ bool FrameSizeButton::CommitSnap(const ui::LocatedEvent& event) {
? wm::WM_EVENT_SNAP_LEFT
: wm::WM_EVENT_SNAP_RIGHT);
window_state->OnWMEvent(&snap_event);
ShellPort::Get()->RecordUserMetricsAction(
Shell::Get()->metrics()->RecordUserMetricsAction(
snap_type_ == SNAP_LEFT ? UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT
: UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT);
SetButtonsToNormalMode(FrameSizeButtonDelegate::ANIMATE_NO);
Expand Down
4 changes: 2 additions & 2 deletions ash/metrics/desktop_task_switch_metric_recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include "ash/metrics/desktop_task_switch_metric_recorder.h"

#include "ash/metrics/user_metrics_recorder.h"
#include "ash/shell.h"
#include "ash/shell_port.h"
#include "ash/wm/window_util.h"
#include "ui/wm/public/activation_client.h"

Expand All @@ -28,7 +28,7 @@ void DesktopTaskSwitchMetricRecorder::OnWindowActivated(
if (last_active_task_window_ != gained_active &&
reason ==
::wm::ActivationChangeObserver::ActivationReason::INPUT_EVENT) {
ShellPort::Get()->RecordUserMetricsAction(UMA_DESKTOP_SWITCH_TASK);
Shell::Get()->metrics()->RecordUserMetricsAction(UMA_DESKTOP_SWITCH_TASK);
}
last_active_task_window_ = gained_active;
}
Expand Down
29 changes: 0 additions & 29 deletions ash/mus/bridge/shell_port_mash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "ash/shared/immersive_fullscreen_controller.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/touch/touch_uma.h"
#include "ash/virtual_keyboard_controller.h"
#include "ash/wallpaper/wallpaper_delegate.h"
#include "ash/wm/drag_window_resizer.h"
Expand Down Expand Up @@ -163,34 +162,6 @@ bool ShellPortMash::IsMouseEventsEnabled() {
return true;
}

void ShellPortMash::RecordGestureAction(GestureActionType action) {
if (GetAshConfig() == Config::MUS) {
TouchUMA::GetInstance()->RecordGestureAction(action);
return;
}
// TODO: http://crbug.com/616581.
NOTIMPLEMENTED();
}

void ShellPortMash::RecordUserMetricsAction(UserMetricsAction action) {
if (GetAshConfig() == Config::MUS) {
Shell::Get()->metrics()->RecordUserMetricsAction(action);
return;
}
// TODO: http://crbug.com/616581.
NOTIMPLEMENTED();
}

void ShellPortMash::RecordTaskSwitchMetric(TaskSwitchSource source) {
if (GetAshConfig() == Config::MUS) {
Shell::Get()->metrics()->task_switch_metrics_recorder().OnTaskSwitch(
source);
return;
}
// TODO: http://crbug.com/616581.
NOTIMPLEMENTED();
}

std::unique_ptr<WindowResizer> ShellPortMash::CreateDragWindowResizer(
std::unique_ptr<WindowResizer> next_window_resizer,
wm::WindowState* window_state) {
Expand Down
3 changes: 0 additions & 3 deletions ash/mus/bridge/shell_port_mash.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ class ShellPortMash : public ShellPort {
void SetCursorSize(ui::CursorSize cursor_size) override;
void SetGlobalOverrideCursor(base::Optional<ui::CursorData> cursor) override;
bool IsMouseEventsEnabled() override;
void RecordGestureAction(GestureActionType action) override;
void RecordUserMetricsAction(UserMetricsAction action) override;
void RecordTaskSwitchMetric(TaskSwitchSource source) override;
std::unique_ptr<WindowResizer> CreateDragWindowResizer(
std::unique_ptr<WindowResizer> next_window_resizer,
wm::WindowState* window_state) override;
Expand Down
12 changes: 8 additions & 4 deletions ash/shelf/shelf_alignment_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#include "ash/shelf/shelf_alignment_menu.h"

#include "ash/metrics/user_metrics_action.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/shelf.h"
#include "ash/shell_port.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"

namespace ash {
Expand Down Expand Up @@ -48,15 +49,18 @@ bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const {
void ShelfAlignmentMenu::ExecuteCommand(int command_id, int event_flags) {
switch (static_cast<MenuItem>(command_id)) {
case MENU_ALIGN_LEFT:
ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT);
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_SHELF_ALIGNMENT_SET_LEFT);
shelf_->SetAlignment(SHELF_ALIGNMENT_LEFT);
break;
case MENU_ALIGN_BOTTOM:
ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM);
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_SHELF_ALIGNMENT_SET_BOTTOM);
shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
break;
case MENU_ALIGN_RIGHT:
ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT);
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_SHELF_ALIGNMENT_SET_RIGHT);
shelf_->SetAlignment(SHELF_ALIGNMENT_RIGHT);
break;
}
Expand Down
16 changes: 10 additions & 6 deletions ash/shelf/shelf_button_pressed_metric_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

#include "ash/shelf/shelf_button_pressed_metric_tracker.h"

#include "ash/shell_port.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/shell.h"
#include "base/metrics/histogram_macros.h"
#include "base/time/default_tick_clock.h"
#include "ui/views/controls/button/button.h"
Expand Down Expand Up @@ -48,10 +49,10 @@ void ShelfButtonPressedMetricTracker::ButtonPressed(
void ShelfButtonPressedMetricTracker::RecordButtonPressedSource(
const ui::Event& event) {
if (event.IsMouseEvent()) {
ShellPort::Get()->RecordUserMetricsAction(
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE);
} else if (event.IsGestureEvent()) {
ShellPort::Get()->RecordUserMetricsAction(
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_LAUNCHER_BUTTON_PRESSED_WITH_TOUCH);
}
}
Expand All @@ -63,13 +64,16 @@ void ShelfButtonPressedMetricTracker::RecordButtonPressedAction(
case SHELF_ACTION_APP_LIST_SHOWN:
break;
case SHELF_ACTION_NEW_WINDOW_CREATED:
ShellPort::Get()->RecordUserMetricsAction(UMA_LAUNCHER_LAUNCH_TASK);
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_LAUNCHER_LAUNCH_TASK);
break;
case SHELF_ACTION_WINDOW_ACTIVATED:
ShellPort::Get()->RecordUserMetricsAction(UMA_LAUNCHER_SWITCH_TASK);
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_LAUNCHER_SWITCH_TASK);
break;
case SHELF_ACTION_WINDOW_MINIMIZED:
ShellPort::Get()->RecordUserMetricsAction(UMA_LAUNCHER_MINIMIZE_TASK);
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_LAUNCHER_MINIMIZE_TASK);
break;
}
}
Expand Down
6 changes: 4 additions & 2 deletions ash/shelf/shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "ash/ash_constants.h"
#include "ash/drag_drop/drag_image_view.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/public/cpp/config.h"
#include "ash/public/cpp/shelf_item_delegate.h"
#include "ash/public/cpp/shelf_model.h"
Expand Down Expand Up @@ -442,11 +443,12 @@ void ShelfView::ButtonPressed(views::Button* sender,
case TYPE_PINNED_APP:
case TYPE_BROWSER_SHORTCUT:
case TYPE_APP:
ShellPort::Get()->RecordUserMetricsAction(UMA_LAUNCHER_CLICK_ON_APP);
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_LAUNCHER_CLICK_ON_APP);
break;

case TYPE_APP_LIST:
ShellPort::Get()->RecordUserMetricsAction(
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON);
break;

Expand Down
6 changes: 2 additions & 4 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,7 @@ Shell::~Shell() {

const Config config = shell_port_->GetAshConfig();

if (config != Config::MASH)
user_metrics_recorder_->OnShellShuttingDown();
user_metrics_recorder_->OnShellShuttingDown();

shell_delegate_->PreShutdown();

Expand Down Expand Up @@ -1112,8 +1111,7 @@ void Shell::Init(const ShellInitParams& init_params) {
for (auto& observer : shell_observers_)
observer.OnShellInitialized();

if (config != Config::MASH)
user_metrics_recorder_->OnShellInitialized();
user_metrics_recorder_->OnShellInitialized();
}

void Shell::InitRootWindow(aura::Window* root_window) {
Expand Down
6 changes: 0 additions & 6 deletions ash/shell_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include <vector>

#include "ash/ash_export.h"
#include "ash/metrics/gesture_action_type.h"
#include "ash/metrics/user_metrics_action.h"
#include "ash/wm/lock_state_observer.h"
#include "base/observer_list.h"
#include "base/optional.h"
Expand Down Expand Up @@ -111,10 +109,6 @@ class ASH_EXPORT ShellPort {
base::Optional<ui::CursorData> cursor) = 0;
virtual bool IsMouseEventsEnabled() = 0;

virtual void RecordGestureAction(GestureActionType action) = 0;
virtual void RecordUserMetricsAction(UserMetricsAction action) = 0;
virtual void RecordTaskSwitchMetric(TaskSwitchSource source) = 0;

// Shows the context menu for the wallpaper or shelf at |location_in_screen|.
void ShowContextMenu(const gfx::Point& location_in_screen,
ui::MenuSourceType source_type);
Expand Down
4 changes: 2 additions & 2 deletions ash/system/audio/tray_audio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include "ash/system/audio/tray_audio.h"

#include "ash/metrics/user_metrics_recorder.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/shell_port.h"
#include "ash/system/audio/audio_detailed_view.h"
#include "ash/system/audio/volume_view.h"
#include "ash/system/tray/system_tray.h"
Expand Down Expand Up @@ -69,7 +69,7 @@ views::View* TrayAudio::CreateDetailedView(LoginStatus status) {
volume_view_ = new tray::VolumeView(this, false);
return volume_view_;
} else {
ShellPort::Get()->RecordUserMetricsAction(
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_STATUS_AREA_DETAILED_AUDIO_VIEW);
audio_detail_view_ = new tray::AudioDetailedView(this);
return audio_detail_view_;
Expand Down
5 changes: 3 additions & 2 deletions ash/system/audio/volume_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
#include <algorithm>

#include "ash/metrics/user_metrics_action.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/shell_port.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/tray/actionable_view.h"
#include "ash/system/tray/system_tray_item.h"
Expand Down Expand Up @@ -267,7 +268,7 @@ void VolumeView::SliderValueChanged(views::Slider* sender,
int current_volume = CrasAudioHandler::Get()->GetOutputVolumePercent();
if (new_volume == current_volume)
return;
ShellPort::Get()->RecordUserMetricsAction(
Shell::Get()->metrics()->RecordUserMetricsAction(
is_default_view_ ? UMA_STATUS_AREA_CHANGED_VOLUME_MENU
: UMA_STATUS_AREA_CHANGED_VOLUME_POPUP);
if (new_volume > current_volume)
Expand Down
6 changes: 3 additions & 3 deletions ash/system/bluetooth/tray_bluetooth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include <set>
#include <string>

#include "ash/metrics/user_metrics_recorder.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/shell.h"
#include "ash/shell_port.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/bluetooth/tray_bluetooth_helper.h"
#include "ash/system/tray/hover_highlight_view.h"
Expand Down Expand Up @@ -388,7 +388,7 @@ class BluetoothDetailedView : public TrayDetailsView {
const ui::Event& event) override {
if (sender == toggle_) {
TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper();
ShellPort::Get()->RecordUserMetricsAction(
Shell::Get()->metrics()->RecordUserMetricsAction(
helper->GetBluetoothEnabled() ? UMA_STATUS_AREA_BLUETOOTH_DISABLED
: UMA_STATUS_AREA_BLUETOOTH_ENABLED);
helper->ToggleBluetoothEnabled();
Expand Down Expand Up @@ -545,7 +545,7 @@ views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) {
views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) {
if (!Shell::Get()->tray_bluetooth_helper()->GetBluetoothAvailable())
return nullptr;
ShellPort::Get()->RecordUserMetricsAction(
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW);
CHECK(detailed_ == nullptr);
detailed_ = new tray::BluetoothDetailedView(this, status);
Expand Down
Loading

0 comments on commit 41562d1

Please sign in to comment.