// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.chrome.browser.metrics;

import org.chromium.base.metrics.RecordHistogram;

/**
 * Centralizes UMA data collection for Android-specific MediaSession features.
 */
public class MediaSessionUMA {
    // MediaSessionAction defined in tools/metrics/histograms/histograms.xml.
    public static final int MEDIA_SESSION_ACTION_SOURCE_MEDIA_NOTIFICATION = 0;
    public static final int MEDIA_SESSION_ACTION_SOURCE_MAX = 1;

    public static void recordPlay(int action) {
        assert action >= 0 && action < MEDIA_SESSION_ACTION_SOURCE_MAX;
        RecordHistogram.recordEnumeratedHistogram("Media.Session.Play", action,
                MEDIA_SESSION_ACTION_SOURCE_MAX);
    }

    public static void recordPause(int action) {
        assert action >= 0 && action < MEDIA_SESSION_ACTION_SOURCE_MAX;
        RecordHistogram.recordEnumeratedHistogram("Media.Session.Pause", action,
                MEDIA_SESSION_ACTION_SOURCE_MAX);
    }
}

@@ -532,16 +532,272 @@
 ON = 0;%0A
+    // TODO(mlamouri): UMA do not handle well enumerations with only one value.%0A    // Other values will be addede later (like RemoteContro/MediaSession/etc.)%0A    // interactions but we have to fax the max value for now in order to prevent%0A    // crashes.%0A
     publ
@@ -850,17 +850,17 @@
 E_MAX = 
-1
+2
 ;%0A%0A    p

Fix crash because of UMA enum with only one value.