watch_time_keys.cc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "media/base/watch_time_keys.h"
  5. #include "base/notreached.h"
  6. namespace media {
  7. // TODO(dalecurtis): Key strings aren't really necessary anymore, so instead
  8. // of hard coding these, switch to generating them.
  9. // Audio+video watch time metrics.
  10. static const char kWatchTimeAudioVideoAll[] = "Media.WatchTime.AudioVideo.All";
  11. static const char kWatchTimeAudioVideoMse[] = "Media.WatchTime.AudioVideo.MSE";
  12. static const char kWatchTimeAudioVideoEme[] = "Media.WatchTime.AudioVideo.EME";
  13. static const char kWatchTimeAudioVideoSrc[] = "Media.WatchTime.AudioVideo.SRC";
  14. static const char kWatchTimeAudioVideoBattery[] =
  15. "Media.WatchTime.AudioVideo.Battery";
  16. static const char kWatchTimeAudioVideoAc[] = "Media.WatchTime.AudioVideo.AC";
  17. static const char kWatchTimeAudioVideoDisplayFullscreen[] =
  18. "Media.WatchTime.AudioVideo.DisplayFullscreen";
  19. static const char kWatchTimeAudioVideoDisplayInline[] =
  20. "Media.WatchTime.AudioVideo.DisplayInline";
  21. static const char kWatchTimeAudioVideoDisplayPictureInPicture[] =
  22. "Media.WatchTime.AudioVideo.DisplayPictureInPicture";
  23. static const char kWatchTimeAudioVideoEmbeddedExperience[] =
  24. "Media.WatchTime.AudioVideo.EmbeddedExperience";
  25. static const char kWatchTimeAudioVideoNativeControlsOn[] =
  26. "Media.WatchTime.AudioVideo.NativeControlsOn";
  27. static const char kWatchTimeAudioVideoNativeControlsOff[] =
  28. "Media.WatchTime.AudioVideo.NativeControlsOff";
  29. // Audio only "watch time" metrics.
  30. static const char kWatchTimeAudioAll[] = "Media.WatchTime.Audio.All";
  31. static const char kWatchTimeAudioMse[] = "Media.WatchTime.Audio.MSE";
  32. static const char kWatchTimeAudioEme[] = "Media.WatchTime.Audio.EME";
  33. static const char kWatchTimeAudioSrc[] = "Media.WatchTime.Audio.SRC";
  34. static const char kWatchTimeAudioBattery[] = "Media.WatchTime.Audio.Battery";
  35. static const char kWatchTimeAudioAc[] = "Media.WatchTime.Audio.AC";
  36. static const char kWatchTimeAudioEmbeddedExperience[] =
  37. "Media.WatchTime.Audio.EmbeddedExperience";
  38. static const char kWatchTimeAudioNativeControlsOn[] =
  39. "Media.WatchTime.Audio.NativeControlsOn";
  40. static const char kWatchTimeAudioNativeControlsOff[] =
  41. "Media.WatchTime.Audio.NativeControlsOff";
  42. static const char kWatchTimeAudioBackgroundAll[] =
  43. "Media.WatchTime.Audio.Background.All";
  44. static const char kWatchTimeAudioBackgroundMse[] =
  45. "Media.WatchTime.Audio.Background.MSE";
  46. static const char kWatchTimeAudioBackgroundEme[] =
  47. "Media.WatchTime.Audio.Background.EME";
  48. static const char kWatchTimeAudioBackgroundSrc[] =
  49. "Media.WatchTime.Audio.Background.SRC";
  50. static const char kWatchTimeAudioBackgroundBattery[] =
  51. "Media.WatchTime.Audio.Background.Battery";
  52. static const char kWatchTimeAudioBackgroundAc[] =
  53. "Media.WatchTime.Audio.Background.AC";
  54. static const char kWatchTimeAudioBackgroundEmbeddedExperience[] =
  55. "Media.WatchTime.Audio.Background.EmbeddedExperience";
  56. // Audio+video background watch time metrics.
  57. static const char kWatchTimeAudioVideoBackgroundAll[] =
  58. "Media.WatchTime.AudioVideo.Background.All";
  59. static const char kWatchTimeAudioVideoBackgroundMse[] =
  60. "Media.WatchTime.AudioVideo.Background.MSE";
  61. static const char kWatchTimeAudioVideoBackgroundEme[] =
  62. "Media.WatchTime.AudioVideo.Background.EME";
  63. static const char kWatchTimeAudioVideoBackgroundSrc[] =
  64. "Media.WatchTime.AudioVideo.Background.SRC";
  65. static const char kWatchTimeAudioVideoBackgroundBattery[] =
  66. "Media.WatchTime.AudioVideo.Background.Battery";
  67. static const char kWatchTimeAudioVideoBackgroundAc[] =
  68. "Media.WatchTime.AudioVideo.Background.AC";
  69. static const char kWatchTimeAudioVideoBackgroundEmbeddedExperience[] =
  70. "Media.WatchTime.AudioVideo.Background.EmbeddedExperience";
  71. // Audio+video muted watch time metrics.
  72. static const char kWatchTimeAudioVideoMutedAll[] =
  73. "Media.WatchTime.AudioVideo.Muted.All";
  74. static const char kWatchTimeAudioVideoMutedMse[] =
  75. "Media.WatchTime.AudioVideo.Muted.MSE";
  76. static const char kWatchTimeAudioVideoMutedEme[] =
  77. "Media.WatchTime.AudioVideo.Muted.EME";
  78. static const char kWatchTimeAudioVideoMutedSrc[] =
  79. "Media.WatchTime.AudioVideo.Muted.SRC";
  80. const char kWatchTimeUnderflowCount[] = "UnderflowCount";
  81. const char kMeanTimeBetweenRebuffersAudioSrc[] =
  82. "Media.MeanTimeBetweenRebuffers.Audio.SRC";
  83. const char kMeanTimeBetweenRebuffersAudioMse[] =
  84. "Media.MeanTimeBetweenRebuffers.Audio.MSE";
  85. const char kMeanTimeBetweenRebuffersAudioEme[] =
  86. "Media.MeanTimeBetweenRebuffers.Audio.EME";
  87. const char kMeanTimeBetweenRebuffersAudioVideoSrc[] =
  88. "Media.MeanTimeBetweenRebuffers.AudioVideo.SRC";
  89. const char kMeanTimeBetweenRebuffersAudioVideoMse[] =
  90. "Media.MeanTimeBetweenRebuffers.AudioVideo.MSE";
  91. const char kMeanTimeBetweenRebuffersAudioVideoEme[] =
  92. "Media.MeanTimeBetweenRebuffers.AudioVideo.EME";
  93. const char kRebuffersCountAudioSrc[] = "Media.RebuffersCount.Audio.SRC";
  94. const char kRebuffersCountAudioMse[] = "Media.RebuffersCount.Audio.MSE";
  95. const char kRebuffersCountAudioEme[] = "Media.RebuffersCount.Audio.EME";
  96. const char kRebuffersCountAudioVideoSrc[] =
  97. "Media.RebuffersCount.AudioVideo.SRC";
  98. const char kRebuffersCountAudioVideoMse[] =
  99. "Media.RebuffersCount.AudioVideo.MSE";
  100. const char kRebuffersCountAudioVideoEme[] =
  101. "Media.RebuffersCount.AudioVideo.EME";
  102. const char kDiscardedWatchTimeAudioSrc[] =
  103. "Media.WatchTime.Audio.Discarded.SRC";
  104. const char kDiscardedWatchTimeAudioMse[] =
  105. "Media.WatchTime.Audio.Discarded.MSE";
  106. const char kDiscardedWatchTimeAudioEme[] =
  107. "Media.WatchTime.Audio.Discarded.EME";
  108. const char kDiscardedWatchTimeAudioVideoSrc[] =
  109. "Media.WatchTime.AudioVideo.Discarded.SRC";
  110. const char kDiscardedWatchTimeAudioVideoMse[] =
  111. "Media.WatchTime.AudioVideo.Discarded.MSE";
  112. const char kDiscardedWatchTimeAudioVideoEme[] =
  113. "Media.WatchTime.AudioVideo.Discarded.EME";
  114. base::StringPiece ConvertWatchTimeKeyToStringForUma(WatchTimeKey key) {
  115. // WARNING: Returning a non-empty value will log the key to UMA.
  116. switch (key) {
  117. case WatchTimeKey::kAudioAll:
  118. return kWatchTimeAudioAll;
  119. case WatchTimeKey::kAudioMse:
  120. return kWatchTimeAudioMse;
  121. case WatchTimeKey::kAudioEme:
  122. return kWatchTimeAudioEme;
  123. case WatchTimeKey::kAudioSrc:
  124. return kWatchTimeAudioSrc;
  125. case WatchTimeKey::kAudioBattery:
  126. return kWatchTimeAudioBattery;
  127. case WatchTimeKey::kAudioAc:
  128. return kWatchTimeAudioAc;
  129. case WatchTimeKey::kAudioEmbeddedExperience:
  130. return kWatchTimeAudioEmbeddedExperience;
  131. case WatchTimeKey::kAudioNativeControlsOn:
  132. return kWatchTimeAudioNativeControlsOn;
  133. case WatchTimeKey::kAudioNativeControlsOff:
  134. return kWatchTimeAudioNativeControlsOff;
  135. case WatchTimeKey::kAudioBackgroundAll:
  136. return kWatchTimeAudioBackgroundAll;
  137. case WatchTimeKey::kAudioBackgroundMse:
  138. return kWatchTimeAudioBackgroundMse;
  139. case WatchTimeKey::kAudioBackgroundEme:
  140. return kWatchTimeAudioBackgroundEme;
  141. case WatchTimeKey::kAudioBackgroundSrc:
  142. return kWatchTimeAudioBackgroundSrc;
  143. case WatchTimeKey::kAudioBackgroundBattery:
  144. return kWatchTimeAudioBackgroundBattery;
  145. case WatchTimeKey::kAudioBackgroundAc:
  146. return kWatchTimeAudioBackgroundAc;
  147. case WatchTimeKey::kAudioBackgroundEmbeddedExperience:
  148. return kWatchTimeAudioBackgroundEmbeddedExperience;
  149. case WatchTimeKey::kAudioVideoAll:
  150. return kWatchTimeAudioVideoAll;
  151. case WatchTimeKey::kAudioVideoMse:
  152. return kWatchTimeAudioVideoMse;
  153. case WatchTimeKey::kAudioVideoEme:
  154. return kWatchTimeAudioVideoEme;
  155. case WatchTimeKey::kAudioVideoSrc:
  156. return kWatchTimeAudioVideoSrc;
  157. case WatchTimeKey::kAudioVideoBattery:
  158. return kWatchTimeAudioVideoBattery;
  159. case WatchTimeKey::kAudioVideoAc:
  160. return kWatchTimeAudioVideoAc;
  161. case WatchTimeKey::kAudioVideoDisplayFullscreen:
  162. return kWatchTimeAudioVideoDisplayFullscreen;
  163. case WatchTimeKey::kAudioVideoDisplayInline:
  164. return kWatchTimeAudioVideoDisplayInline;
  165. case WatchTimeKey::kAudioVideoDisplayPictureInPicture:
  166. return kWatchTimeAudioVideoDisplayPictureInPicture;
  167. case WatchTimeKey::kAudioVideoEmbeddedExperience:
  168. return kWatchTimeAudioVideoEmbeddedExperience;
  169. case WatchTimeKey::kAudioVideoNativeControlsOn:
  170. return kWatchTimeAudioVideoNativeControlsOn;
  171. case WatchTimeKey::kAudioVideoNativeControlsOff:
  172. return kWatchTimeAudioVideoNativeControlsOff;
  173. case WatchTimeKey::kAudioVideoBackgroundAll:
  174. return kWatchTimeAudioVideoBackgroundAll;
  175. case WatchTimeKey::kAudioVideoBackgroundMse:
  176. return kWatchTimeAudioVideoBackgroundMse;
  177. case WatchTimeKey::kAudioVideoBackgroundEme:
  178. return kWatchTimeAudioVideoBackgroundEme;
  179. case WatchTimeKey::kAudioVideoBackgroundSrc:
  180. return kWatchTimeAudioVideoBackgroundSrc;
  181. case WatchTimeKey::kAudioVideoBackgroundBattery:
  182. return kWatchTimeAudioVideoBackgroundBattery;
  183. case WatchTimeKey::kAudioVideoBackgroundAc:
  184. return kWatchTimeAudioVideoBackgroundAc;
  185. case WatchTimeKey::kAudioVideoBackgroundEmbeddedExperience:
  186. return kWatchTimeAudioVideoBackgroundEmbeddedExperience;
  187. case WatchTimeKey::kAudioVideoMutedAll:
  188. return kWatchTimeAudioVideoMutedAll;
  189. case WatchTimeKey::kAudioVideoMutedMse:
  190. return kWatchTimeAudioVideoMutedMse;
  191. case WatchTimeKey::kAudioVideoMutedEme:
  192. return kWatchTimeAudioVideoMutedEme;
  193. case WatchTimeKey::kAudioVideoMutedSrc:
  194. return kWatchTimeAudioVideoMutedSrc;
  195. // WARNING: Returning a non-empty value will log the key to UMA.
  196. // The following keys are not reported to UMA and thus have no conversion.
  197. // We don't report keys to UMA that we don't have a strong use case for
  198. // since UMA requires us to break out each state manually (ac, inline, etc).
  199. case WatchTimeKey::kAudioVideoMutedBattery:
  200. case WatchTimeKey::kAudioVideoMutedAc:
  201. case WatchTimeKey::kAudioVideoMutedEmbeddedExperience:
  202. case WatchTimeKey::kAudioVideoMutedDisplayFullscreen:
  203. case WatchTimeKey::kAudioVideoMutedDisplayInline:
  204. case WatchTimeKey::kAudioVideoMutedDisplayPictureInPicture:
  205. case WatchTimeKey::kAudioVideoMutedNativeControlsOn:
  206. case WatchTimeKey::kAudioVideoMutedNativeControlsOff:
  207. case WatchTimeKey::kVideoAll:
  208. case WatchTimeKey::kVideoMse:
  209. case WatchTimeKey::kVideoEme:
  210. case WatchTimeKey::kVideoSrc:
  211. case WatchTimeKey::kVideoBattery:
  212. case WatchTimeKey::kVideoAc:
  213. case WatchTimeKey::kVideoDisplayFullscreen:
  214. case WatchTimeKey::kVideoDisplayInline:
  215. case WatchTimeKey::kVideoDisplayPictureInPicture:
  216. case WatchTimeKey::kVideoEmbeddedExperience:
  217. case WatchTimeKey::kVideoNativeControlsOn:
  218. case WatchTimeKey::kVideoNativeControlsOff:
  219. case WatchTimeKey::kVideoBackgroundAll:
  220. case WatchTimeKey::kVideoBackgroundMse:
  221. case WatchTimeKey::kVideoBackgroundEme:
  222. case WatchTimeKey::kVideoBackgroundSrc:
  223. case WatchTimeKey::kVideoBackgroundBattery:
  224. case WatchTimeKey::kVideoBackgroundAc:
  225. case WatchTimeKey::kVideoBackgroundEmbeddedExperience:
  226. return base::StringPiece();
  227. };
  228. NOTREACHED();
  229. return base::StringPiece();
  230. }
  231. } // namespace media