File: stats.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (138 lines) | stat: -rw-r--r-- 5,311 bytes parent folder | download | duplicates (6)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// 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 COMPONENTS_SAVED_TAB_GROUPS_INTERNAL_STATS_H_
#define COMPONENTS_SAVED_TAB_GROUPS_INTERNAL_STATS_H_

#include <stddef.h>

#include <unordered_set>

#include "base/uuid.h"
#include "components/saved_tab_groups/public/types.h"

namespace tab_groups {

class SavedTabGroupModel;
class SavedTabGroup;
class SavedTabGroupTab;
class TabGroupVisualData;

namespace stats {

// Please keep in sync with "SavedTabGroupSyncBridge.MigrationResult" in
// tools/metrics/histograms/metadata/tab/enums.xml. These values are
// persisted to logs. Entries should not be renumbered and numeric values should
// never be reused.
//
// LINT.IfChange(MigrationResult)
enum class MigrationResult {
  kStoreCreateFailed = 0,
  kStoreLoadStarted = 1,
  kStoreLoadFailed = 2,
  kStoreLoadCompleted = 3,
  kSpecificsToDataMigrationStarted = 4,
  kSpecificsToDataMigrationParseFailedAtLeastOnce = 5,
  kSpecificsToDataMigrationWriteFailed = 6,
  kSpecificsToDataMigrationSuccess = 7,
  kSpecificsToDataMigrationAlreadyComplete = 8,
  kSharedPrefMigrationStarted = 9,
  kSharedPrefMigrationParseFailedAtLeastOnce = 10,
  kSharedPrefMigrationAtLeastOneEntryMigrated = 11,
  kSharedPrefMigrationWriteFailed = 12,
  kSharedPrefMigrationSuccess = 13,
  kReadAllMetadataFailed = 14,
  kReadAllMetadataSuccess = 15,
  kCount
};
// LINT.ThenChange(//tools/metrics/histograms/metadata/tab/enums.xml:SavedTabGroupSyncBridge.MigrationResult)

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// LINT.IfChange(SharedTabGroupDataLoadFromDiskResult)
enum class SharedTabGroupDataLoadFromDiskResult {
  kSuccess = 0,
  kFailedToParse = 1,
  kUnexpectedGuid = 2,
  kMissingCollaborationId = 3,
  kMissingGroupAndTab = 4,

  kMaxValue = kMissingGroupAndTab,
};
// LINT.ThenChange(//tools/metrics/histograms/metadata/tab/enums.xml:SharedTabGroupDataLoadFromDiskResult)

// Types of tab title sanitization.
enum class TitleSanitizationType {
  // A tab was added to a group.
  kAddTab = 0,
  // A navigation was triggered in the tab.
  kNavigateTab = 1,
  // A tab group become shared.
  kShareTabGroup = 2,

  kMaxValue = kShareTabGroup
};

// Records metrics about the state of model such as the number of saved groups,
// the number of tabs in each group, and more.
// Only used for desktop code that uses SavedTabGroupKeyedService. Soon to be
// deprecated.
void RecordSavedTabGroupMetrics(SavedTabGroupModel* model);

// Records the difference in the number of tabs between local group and the
// synced version when the local tab group is connected with the synced one.
void RecordTabCountMismatchOnConnect(size_t tabs_in_saved_group,
                                     size_t tabs_in_group);

// Records various migration step outcomes during initialization.
void RecordMigrationResult(MigrationResult migration_result);

// Records the number of entries in DataTypeStore that failed to parse as a
// specific during migration.
void RecordSpecificsParseFailureCount(int parse_failure_count,
                                      int total_entries);

// Records the number of entries in DataTypeStore that failed to parse as a
// SavedTabGroupData in the final stage of startup.
void RecordParsedSavedTabGroupDataCount(int parsed_entries_count,
                                        int total_entries);

// Records metrics related to tab group creation dialog.
void RecordTabGroupVisualsMetrics(
    const tab_groups::TabGroupVisualData* visual_data);

// Records the result of loading SharedTabGroupData from disk.
void RecordSharedTabGroupDataLoadFromDiskResult(
    SharedTabGroupDataLoadFromDiskResult result);

void RecordEmptyGroupsMetricsOnLoad(
    const std::vector<SavedTabGroup>& all_groups,
    const std::vector<SavedTabGroupTab>& all_tabs,
    const std::unordered_set<base::Uuid, base::UuidHash>&
        groups_with_filtered_tabs);

// Records whether the group is currently empty when it is added to the
// SavedTabGroupModel.
void RecordEmptyGroupsMetricsOnGroupAddedLocally(const SavedTabGroup& group,
                                                 bool model_is_loaded);
void RecordEmptyGroupsMetricsOnGroupAddedFromSync(const SavedTabGroup& group,
                                                  bool model_is_loaded);

// Records whether the group is currently empty, before the tab is added to the
// SavedTabGroupModel. The tab must not be in the group yet.
void RecordEmptyGroupsMetricsOnTabAddedLocally(const SavedTabGroup& group,
                                               const SavedTabGroupTab& tab,
                                               bool model_is_loaded);
void RecordEmptyGroupsMetricsOnTabAddedFromSync(const SavedTabGroup& group,
                                                const SavedTabGroupTab& tab,
                                                bool model_is_loaded);

// Records metrics about title sanitization for shared tab groups.
void RecordSharedGroupTitleSanitization(
    bool use_url_as_title,
    TitleSanitizationType title_sanitization_type);
}  // namespace stats
}  // namespace tab_groups

#endif  // COMPONENTS_SAVED_TAB_GROUPS_INTERNAL_STATS_H_