OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_UMA_HELPER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_UMA_HELPER_H_ |
6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_UMA_HELPER_H_ | 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_UMA_HELPER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/time/clock.h" | 10 #include "base/time/clock.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // be appended only and must be added before |Count|. | 22 // be appended only and must be added before |Count|. |
23 enum class MediaSessionSuspendedSource { | 23 enum class MediaSessionSuspendedSource { |
24 SystemTransient = 0, | 24 SystemTransient = 0, |
25 SystemPermanent = 1, | 25 SystemPermanent = 1, |
26 UI = 2, | 26 UI = 2, |
27 CONTENT = 3, | 27 CONTENT = 3, |
28 SystemTransientDuck = 4, | 28 SystemTransientDuck = 4, |
29 Count // Leave at the end. | 29 Count // Leave at the end. |
30 }; | 30 }; |
31 | 31 |
| 32 // Extended enum to blink::mojom::MediaSessionAction, distinguishing default |
| 33 // action handling. |
| 34 enum class MediaSessionUserAction { |
| 35 Play = 0, |
| 36 PlayDefault = 1, |
| 37 Pause = 2, |
| 38 PauseDefault = 3, |
| 39 StopDefault = 4, |
| 40 PreviousTrack = 5, |
| 41 NextTrack = 6, |
| 42 SeekBackward = 7, |
| 43 SeekForward = 8, |
| 44 Count // Leave at the end. |
| 45 }; |
| 46 |
32 MediaSessionUmaHelper(); | 47 MediaSessionUmaHelper(); |
33 ~MediaSessionUmaHelper(); | 48 ~MediaSessionUmaHelper(); |
34 | 49 |
| 50 static void RecordMediaSessionUserAction(MediaSessionUserAction action); |
| 51 |
35 void RecordSessionSuspended(MediaSessionSuspendedSource source) const; | 52 void RecordSessionSuspended(MediaSessionSuspendedSource source) const; |
36 | 53 |
37 // Record the result of calling the native requestAudioFocus(). | 54 // Record the result of calling the native requestAudioFocus(). |
38 void RecordRequestAudioFocusResult(bool result) const; | 55 void RecordRequestAudioFocusResult(bool result) const; |
39 | 56 |
40 void OnSessionActive(); | 57 void OnSessionActive(); |
41 void OnSessionSuspended(); | 58 void OnSessionSuspended(); |
42 void OnSessionInactive(); | 59 void OnSessionInactive(); |
43 | 60 |
44 void SetClockForTest(std::unique_ptr<base::TickClock> testing_clock); | 61 void SetClockForTest(std::unique_ptr<base::TickClock> testing_clock); |
45 | 62 |
46 private: | 63 private: |
47 base::TimeDelta total_active_time_; | 64 base::TimeDelta total_active_time_; |
48 base::TimeTicks current_active_time_; | 65 base::TimeTicks current_active_time_; |
49 std::unique_ptr<base::TickClock> clock_; | 66 std::unique_ptr<base::TickClock> clock_; |
50 }; | 67 }; |
51 | 68 |
52 } // namespace content | 69 } // namespace content |
53 | 70 |
54 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_UMA_HELPER_H_ | 71 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_UMA_HELPER_H_ |
OLD | NEW |