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
content / browser / media / session / media_session_uma_helper.h [blame]
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_UMA_HELPER_H_
#define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_UMA_HELPER_H_
#include "base/memory/raw_ptr.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
namespace base {
class TickClock;
} // namespace base
namespace content {
class CONTENT_EXPORT MediaSessionUmaHelper {
public:
// This is used for UMA histogram (Media.Session.Suspended). New values should
// be appended only and must be added before |Count|.
enum class MediaSessionSuspendedSource {
kSystemTransient = 0,
kSystemPermanent = 1,
kUI = 2,
kCONTENT = 3,
kSystemTransientDuck = 4,
kMaxValue = kSystemTransientDuck,
};
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class EnterPictureInPictureType {
// EnterPictureInPicture was called for the default handler provided by
// MediaSessionImpl.
kDefaultHandler = 0,
// EnterPictureInPicture was called for an enterpictureinpicture handler
// provided by the website.
kRegisteredManual = 1,
// EnterAutoPictureInPicture was called for an enterpictureinpicture handler
// provided by the website.
kRegisteredAutomatic = 2,
kMaxValue = kRegisteredAutomatic,
};
MediaSessionUmaHelper();
~MediaSessionUmaHelper();
void RecordSessionSuspended(MediaSessionSuspendedSource source) const;
void RecordEnterPictureInPicture(EnterPictureInPictureType type) const;
void OnSessionActive();
void OnSessionSuspended();
void OnSessionInactive();
void SetClockForTest(const base::TickClock* testing_clock);
private:
base::TimeDelta total_active_time_;
base::TimeTicks current_active_time_;
raw_ptr<const base::TickClock> clock_;
};
} // namespace content
#endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_UMA_HELPER_H_