Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Unified Diff: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h

Issue 2404743002: Web Audio: record autoplay status when an AudioContext is destroyed. (Closed)
Patch Set: move recording Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h
diff --git a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h
index 94474e47482b45c008021199aa0ccc82d0b8ad19..d0e80b9bcbf819140438e96e73a44fbeafe280e5 100644
--- a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h
+++ b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h
@@ -54,6 +54,7 @@ class AudioBufferCallback;
class AudioBufferSourceNode;
class AudioListener;
class AudioSummingJunction;
+class BaseAudioContextTest;
class BiquadFilterNode;
class ChannelMergerNode;
class ChannelSplitterNode;
@@ -299,6 +300,11 @@ class MODULES_EXPORT BaseAudioContext : public EventTargetWithInlineData,
// initialized internally if necessary.
PeriodicWave* periodicWave(int type);
+ // For metrics purpose, records when start() is called on a
+ // AudioScheduledSourceHandler or a AudioBufferSourceHandler without a user
+ // gesture while the AudioContext requires a user gesture.
+ void maybeRecordStartAttempt();
+
protected:
explicit BaseAudioContext(Document*);
BaseAudioContext(Document*,
@@ -342,6 +348,23 @@ class MODULES_EXPORT BaseAudioContext : public EventTargetWithInlineData,
bool isAllowedToStart() const;
private:
+ friend class BaseAudioContextTest;
+
+ // Do not change the order of this enum, it is used for metrics.
+ enum AutoplayStatus {
+ // The AudioContext failed to activate because of user gesture requirements.
+ AutoplayStatusFailed = 0,
+ // Same as AutoplayStatusFailed but start() on a node was called with a user
+ // gesture.
+ AutoplayStatusFailedWithStart = 1,
+ // The AudioContext had user gesture requirements and was able to activate
+ // with a user gesture.
+ AutoplayStatusSucceeded = 2,
+
+ // Keep at the end.
+ AutoplayStatusCount
+ };
+
bool m_isCleared;
void clear();
@@ -383,6 +406,9 @@ class MODULES_EXPORT BaseAudioContext : public EventTargetWithInlineData,
// resolvers.
virtual void rejectPendingResolvers();
+ // Record the current autoplay status and clear it.
+ void recordAutoplayStatus();
+
// True if we're in the process of resolving promises for resume(). Resolving
// can take some time and the audio context process loop is very fast, so we
// don't want to call resolve an excessive number of times.
@@ -422,6 +448,8 @@ class MODULES_EXPORT BaseAudioContext : public EventTargetWithInlineData,
// This is considering 32 is large enough for multiple channels audio.
// It is somewhat arbitrary and could be increased if necessary.
enum { MaxNumberOfChannels = 32 };
+
+ Optional<AutoplayStatus> m_autoplayStatus;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698