summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortoyoshim <toyoshim@chromium.org>2015-08-09 23:00:26 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-10 06:01:09 +0000
commitdcdd541d15cdfbdf96c401e2129418ba3532ce13 (patch)
tree66d06e68c2227d172008156c4d4c8c175dbcb1f4
parent096d328b8706b539b93d8190a4c567748e828287 (diff)
downloadchromium_src-dcdd541d15cdfbdf96c401e2129418ba3532ce13.zip
chromium_src-dcdd541d15cdfbdf96c401e2129418ba3532ce13.tar.gz
chromium_src-dcdd541d15cdfbdf96c401e2129418ba3532ce13.tar.bz2
Web MIDI: add usage metrics
BUG=465661 Review URL: https://codereview.chromium.org/1269813007 Cr-Commit-Position: refs/heads/master@{#342582}
-rw-r--r--media/midi/midi_manager.cc49
-rw-r--r--tools/metrics/histograms/histograms.xml25
2 files changed, 72 insertions, 2 deletions
diff --git a/media/midi/midi_manager.cc b/media/midi/midi_manager.cc
index d61bd7a..6e8c1a2 100644
--- a/media/midi/midi_manager.cc
+++ b/media/midi/midi_manager.cc
@@ -12,24 +12,58 @@
namespace media {
namespace midi {
+namespace {
+
+using Sample = base::HistogramBase::Sample;
+
+// If many users have more devices, this number will be increased.
+// But the number is expected to be big enough for now.
+const Sample kMaxUmaDevices = 31;
+
+// Used to count events for usage histogram.
+enum class Usage {
+ CREATED,
+ CREATED_ON_UNSUPPORTED_PLATFORMS,
+ SESSION_STARTED,
+ SESSION_ENDED,
+ INITIALIZED,
+ INPUT_PORT_ADDED,
+ OUTPUT_PORT_ADDED,
+
+ // New items should be inserted here, and |MAX| should point the last item.
+ MAX = INITIALIZED,
+};
+
+void ReportUsage(Usage usage) {
+ UMA_HISTOGRAM_ENUMERATION("Media.Midi.Usage",
+ static_cast<Sample>(usage),
+ static_cast<Sample>(Usage::MAX) + 1);
+}
+
+} // namespace
+
MidiManager::MidiManager()
: initialized_(false), result_(Result::NOT_INITIALIZED) {
+ ReportUsage(Usage::CREATED);
}
MidiManager::~MidiManager() {
UMA_HISTOGRAM_ENUMERATION("Media.Midi.ResultOnShutdown",
- static_cast<int>(result_),
- static_cast<int>(Result::MAX) + 1);
+ static_cast<Sample>(result_),
+ static_cast<Sample>(Result::MAX) + 1);
}
#if !defined(OS_MACOSX) && !defined(OS_WIN) && \
!(defined(USE_ALSA) && defined(USE_UDEV)) && !defined(OS_ANDROID)
MidiManager* MidiManager::Create() {
+ ReportUsage(Usage::CREATED_ON_UNSUPPORTED_PLATFORMS);
return new MidiManager;
}
#endif
void MidiManager::StartSession(MidiManagerClient* client) {
+ ReportUsage(Usage::SESSION_STARTED);
+
bool session_is_ready;
bool session_needs_initialization = false;
bool too_many_pending_clients_exist = false;
@@ -90,6 +124,8 @@ void MidiManager::StartSession(MidiManagerClient* client) {
}
void MidiManager::EndSession(MidiManagerClient* client) {
+ ReportUsage(Usage::SESSION_ENDED);
+
// At this point, |client| can be in the destruction process, and calling
// any method of |client| is dangerous.
base::AutoLock auto_lock(lock_);
@@ -129,6 +165,7 @@ void MidiManager::CompleteInitialization(Result result) {
}
void MidiManager::AddInputPort(const MidiPortInfo& info) {
+ ReportUsage(Usage::INPUT_PORT_ADDED);
base::AutoLock auto_lock(lock_);
input_ports_.push_back(info);
for (auto client : clients_)
@@ -136,6 +173,7 @@ void MidiManager::AddInputPort(const MidiPortInfo& info) {
}
void MidiManager::AddOutputPort(const MidiPortInfo& info) {
+ ReportUsage(Usage::OUTPUT_PORT_ADDED);
base::AutoLock auto_lock(lock_);
output_ports_.push_back(info);
for (auto client : clients_)
@@ -171,6 +209,13 @@ void MidiManager::ReceiveMidiData(
void MidiManager::CompleteInitializationInternal(Result result) {
TRACE_EVENT0("midi", "MidiManager::CompleteInitialization");
+ ReportUsage(Usage::INITIALIZED);
+ UMA_HISTOGRAM_ENUMERATION("Media.Midi.InputPorts",
+ static_cast<Sample>(input_ports_.size()),
+ kMaxUmaDevices + 1);
+ UMA_HISTOGRAM_ENUMERATION("Media.Midi.OutputPorts",
+ static_cast<Sample>(output_ports_.size()),
+ kMaxUmaDevices + 1);
base::AutoLock auto_lock(lock_);
DCHECK(clients_.empty());
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index c53b11d..4df04de 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -16503,11 +16503,26 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
+<histogram name="Media.Midi.InputPorts" units="devices">
+ <owner>toyoshim@chromium.org</owner>
+ <summary>Connected input port numbers on the initialization.</summary>
+</histogram>
+
+<histogram name="Media.Midi.OutputPorts" units="devices">
+ <owner>toyoshim@chromium.org</owner>
+ <summary>Connected output port numbers on the initialization.</summary>
+</histogram>
+
<histogram name="Media.Midi.ResultOnShutdown" enum="MidiResult">
<owner>toyoshim@chromium.org</owner>
<summary>The final status of MidiManager on browser shutdown.</summary>
</histogram>
+<histogram name="Media.Midi.Usage" enum="MidiUsage">
+ <owner>toyoshim@chromium.org</owner>
+ <summary>MidiManager usages to understand the API use case.</summary>
+</histogram>
+
<histogram name="Media.MSE.AudioCodec" enum="MSECodec">
<owner>acolwell@chromium.org</owner>
<summary>
@@ -63241,6 +63256,16 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="3" label="Generic initialization error"/>
</enum>
+<enum name="MidiUsage" type="int">
+ <int value="0" label="Instantiated"/>
+ <int value="1" label="Instantiated on unsupported platforms"/>
+ <int value="2" label="Session is started"/>
+ <int value="3" label="Session is ended"/>
+ <int value="4" label="Initialized"/>
+ <int value="5" label="Input port is added"/>
+ <int value="6" label="Output port is added"/>
+</enum>
+
<enum name="MigrationNssToPemNetworkTypes" type="int">
<int value="0" label="EAP"/>
<int value="1" label="OpenVPN"/>