1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95

ash / wm / snap_group / snap_group_metrics.h [blame]

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_WM_SNAP_GROUP_SNAP_GROUP_METRICS_H_
#define ASH_WM_SNAP_GROUP_SNAP_GROUP_METRICS_H_

#include <string>

#include "ash/ash_export.h"
#include "base/time/time.h"

namespace ash {

class OverviewItemBase;

// -----------------------------------------------------------------------------
// Faster Split Screen Session Metrics:

inline constexpr char kPartialOverviewSelectedWindowIndex[] =
    "Ash.SplitViewOverviewSession.SelectedWindowIndex";

inline constexpr char kPartialOverviewWindowListSize[] =
    "Ash.SplitViewOverviewSession.WindowListSize";

// -----------------------------------------------------------------------------
// Snap Groups Metrics:

inline constexpr char kSnapGroupsMetricCommonPrefix[] = "Ash.SnapGroups.";

// The duration of a Snap Group where one of the windows remains in the Snap
// Group even after the other window is replaced using 'Snap to Replace'.
inline constexpr char kSnapGroupPersistenceDurationRootWord[] =
    "SnapGroupPersistenceDuration";

// The duration of a Snap Group where the two snapped windows remain unchanged
// throughout its existence.
inline constexpr char kSnapGroupActualDurationRootWord[] =
    "SnapGroupActualDuration";

inline constexpr char kSnapGroupExitPointRootWord[] = "SnapGroupExitPoint";

inline constexpr char kSnapGroupsCountRootWord[] = "SnapGroupsCount";

// Enumeration of Snap Group exit point.
// Note values are persisted to histograms so existing values should
// remain unchanged and new values should be added to the end. This should be
// kept in sync with `SnapGroupExitPoint` enum in
// tools/metrics/histograms/metadata/ash/enums.xml.
// Please keep it in sync with `WindowStateType` in
// chromeos/ui/base/window_state_type.h
enum class SnapGroupExitPoint {
  kDragWindowOut,
  kWindowStateChangeDeprecated,  // Deprecated
  kWindowDestruction,
  kTabletTransition,
  kWindowStateChangedDefault,
  kWindowStateChangedNormal,
  kWindowStateChangedMinimized,
  kWindowStateChangedMaximized,
  kWindowStateChangedInactive,
  kWindowStateChangedFullscreen,
  kWindowStateChangedPrimarySnapped,
  kWindowStateChangedSecondarySnapped,
  kWindowStateChangedPinned,
  kWindowStateChangedTrustedPinned,
  kWindowStateChangedPip,
  kWindowStateChangedFloated,
  kWindowBoundsChange,
  kCanNotFitInWorkArea,
  kSnapToReplace,
  kVisibleOnAllDesks,
  kSelectWindowInSnapGroupInPartialOverview,
  kCoral,
  kMaxValue = kCoral,
};

// Records the partial overview metrics for `item`. Should only be called while
// overview is in session.
void RecordPartialOverviewMetrics(OverviewItemBase* item);

void RecordSnapGroupPersistenceDuration(base::TimeDelta persistence_duration);

void RecordSnapGroupActualDuration(base::TimeDelta actual_duration);

void RecordSnapGroupExitPoint(SnapGroupExitPoint exit_point);

// Records the number of snap groups, up to 101.
void ReportSnapGroupsCountHistogram(int count);

ASH_EXPORT std::string BuildHistogramName(const char* const root_word);

}  // namespace ash

#endif  // ASH_WM_SNAP_GROUP_SNAP_GROUP_METRICS_H_