File: wallpaper_handlers_metric_utils.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (82 lines) | stat: -rw-r--r-- 3,113 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
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_ASH_WALLPAPER_HANDLERS_WALLPAPER_HANDLERS_METRIC_UTILS_H_
#define CHROME_BROWSER_ASH_WALLPAPER_HANDLERS_WALLPAPER_HANDLERS_METRIC_UTILS_H_

#include <optional>
#include <string>

#include "ash/webui/common/mojom/sea_pen.mojom.h"
#include "base/time/time.h"
#include "components/manta/manta_status.h"

namespace wallpaper_handlers {

// Enumeration of Google Photos API endpoints.
enum class GooglePhotosApi {
  kGetAlbum,
  kGetAlbums,
  kGetEnabled,
  kGetPhoto,
  kGetPhotos,
  kGetSharedAlbums,
};

// Records the following on Google Photos API response parsing completion:
// * Ash.Wallpaper.GooglePhotos.Api.{Api}.ResponseTime.[Success|Failure]
// * Ash.Wallpaper.GooglePhotos.Api.{Api}.Result
// * Ash.Wallpaper.GooglePhotos.Api.{Api}.Result.Count
// NOTE: success/failure is assumed by the presence/absence of `result_count`.
void RecordGooglePhotosApiResponseParsed(GooglePhotosApi api,
                                         base::TimeDelta response_time,
                                         std::optional<size_t> result_count);

// Records Ash.Wallpaper.GooglePhotos.Api.{Api}.RefreshCount metric.
void RecordGooglePhotosApiRefreshCount(GooglePhotosApi api, int refresh_count);

// Used to record metrics for SeaPen initial thumbnails request and SeaPen
// upscale request. Keep in sync with histograms.xml variant SeaPenApiType.
enum class SeaPenApiType {
  kThumbnails,
  kWallpaper,
};

// Records the client side latency of an API request. Only record if the request
// completed successfully and did not timeout.
void RecordSeaPenLatency(
    ash::personalization_app::mojom::SeaPenQuery::Tag query_tag,
    base::TimeDelta elapsed_time,
    SeaPenApiType sea_pen_sea_pen_api_type);

// Records the status code of an API request before any client side modification
// (e.g. client changes status code to kGenericError if the response is missing
// images).
void RecordSeaPenMantaStatusCode(
    ash::personalization_app::mojom::SeaPenQuery::Tag query_tag,
    manta::MantaStatusCode status_code,
    SeaPenApiType sea_pen_sea_pen_api_type);

// Records whether the request timed out.
void RecordSeaPenTimeout(
    ash::personalization_app::mojom::SeaPenQuery::Tag query_tag,
    bool hit_timeout,
    SeaPenApiType sea_pen_sea_pen_api_type);

// Records the number of thumbnails returned. Only recorded if the request
// completed successfully. Expected to be in bounds [0,
// kNumThumbnailsRequested].
void RecordSeaPenThumbnailsCount(
    ash::personalization_app::mojom::SeaPenQuery::Tag query_tag,
    size_t thumbnails_count);

// Records whether at least one image exists on the response for full size
// wallpaper image. Only recorded if the request completed successfully.
void RecordSeaPenWallpaperHasImage(
    ash::personalization_app::mojom::SeaPenQuery::Tag query_tag,
    bool has_image);

}  // namespace wallpaper_handlers

#endif  // CHROME_BROWSER_ASH_WALLPAPER_HANDLERS_WALLPAPER_HANDLERS_METRIC_UTILS_H_