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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp

Issue 1978403004: Add UMA histograms for WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add histogram for createBuffer() Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webaudio/AudioContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "modules/webaudio/OfflineAudioCompletionEvent.h" 57 #include "modules/webaudio/OfflineAudioCompletionEvent.h"
58 #include "modules/webaudio/OfflineAudioContext.h" 58 #include "modules/webaudio/OfflineAudioContext.h"
59 #include "modules/webaudio/OfflineAudioDestinationNode.h" 59 #include "modules/webaudio/OfflineAudioDestinationNode.h"
60 #include "modules/webaudio/OscillatorNode.h" 60 #include "modules/webaudio/OscillatorNode.h"
61 #include "modules/webaudio/PannerNode.h" 61 #include "modules/webaudio/PannerNode.h"
62 #include "modules/webaudio/PeriodicWave.h" 62 #include "modules/webaudio/PeriodicWave.h"
63 #include "modules/webaudio/PeriodicWaveConstraints.h" 63 #include "modules/webaudio/PeriodicWaveConstraints.h"
64 #include "modules/webaudio/ScriptProcessorNode.h" 64 #include "modules/webaudio/ScriptProcessorNode.h"
65 #include "modules/webaudio/StereoPannerNode.h" 65 #include "modules/webaudio/StereoPannerNode.h"
66 #include "modules/webaudio/WaveShaperNode.h" 66 #include "modules/webaudio/WaveShaperNode.h"
67 #include "platform/Histogram.h"
67 #include "platform/ThreadSafeFunctional.h" 68 #include "platform/ThreadSafeFunctional.h"
68 #include "platform/audio/IIRFilter.h" 69 #include "platform/audio/IIRFilter.h"
69 #include "public/platform/Platform.h" 70 #include "public/platform/Platform.h"
70 #include "wtf/text/WTFString.h" 71 #include "wtf/text/WTFString.h"
71 72
72 namespace blink { 73 namespace blink {
73 74
74 AbstractAudioContext* AbstractAudioContext::create(Document& document, Exception State& exceptionState) 75 AbstractAudioContext* AbstractAudioContext::create(Document& document, Exception State& exceptionState)
75 { 76 {
76 return AudioContext::create(document, exceptionState); 77 return AudioContext::create(document, exceptionState);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void AbstractAudioContext::throwExceptionForClosedState(ExceptionState& exceptio nState) 200 void AbstractAudioContext::throwExceptionForClosedState(ExceptionState& exceptio nState)
200 { 201 {
201 exceptionState.throwDOMException(InvalidStateError, "AudioContext has been c losed."); 202 exceptionState.throwDOMException(InvalidStateError, "AudioContext has been c losed.");
202 } 203 }
203 204
204 AudioBuffer* AbstractAudioContext::createBuffer(unsigned numberOfChannels, size_ t numberOfFrames, float sampleRate, ExceptionState& exceptionState) 205 AudioBuffer* AbstractAudioContext::createBuffer(unsigned numberOfChannels, size_ t numberOfFrames, float sampleRate, ExceptionState& exceptionState)
205 { 206 {
206 // It's ok to call createBuffer, even if the context is closed because the A udioBuffer doesn't 207 // It's ok to call createBuffer, even if the context is closed because the A udioBuffer doesn't
207 // really "belong" to any particular context. 208 // really "belong" to any particular context.
208 209
209 return AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate, exc eptionState); 210 AudioBuffer* buffer = AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate, exceptionState);
211
212 if (buffer) {
213 // Only record the data if the creation succeeded.
214 DEFINE_STATIC_LOCAL(SparseHistogram, audioBufferChannelsHistogram,
215 ("WebAudio.AudioBuffer.NumberOfChannels"));
216 DEFINE_STATIC_LOCAL(SparseHistogram, audioBufferLengthHistogram,
217 ("WebAudio.AudioBuffer.Length"));
218 DEFINE_STATIC_LOCAL(SparseHistogram, audioBufferSampleRateHistogram,
hongchan 2016/05/18 22:07:01 I think we can move anything related to the sample
Raymond Toy 2016/05/18 22:25:30 The sample rate for the buffer is an argument to c
hongchan 2016/05/19 21:43:53 Acknowledged.
219 ("WebAudio.AudioBuffer.SampleRate"));
220 DEFINE_STATIC_LOCAL(SparseHistogram, audioBufferSampleRateRatioHistogram ,
hongchan 2016/05/19 21:43:53 Yes, I think this needs to be inside of the if cla
Raymond Toy 2016/05/20 20:21:25 Done.
221 ("WebAudio.AudioBuffer.SampleRateRatio"));
222 audioBufferChannelsHistogram.sample(numberOfChannels);
223 audioBufferLengthHistogram.sample(clampTo(numberOfFrames, 0, std::numeri c_limits<int>::max()));
224 audioBufferSampleRateHistogram.sample(static_cast<int>(sampleRate));
225
226 // Compute the ratio of the buffer rate and the context rate so we know
227 // how often the buffer needs to be resampled to match the context. For
228 // the histogram, we multiply the ratio by 100 and round to the nearest
229 // integer. If the context is closed, don't record this because we
230 // don't have a sample rate for closed context.
231 if (!isContextClosed()) {
232 float ratio = 100 * sampleRate / this->sampleRate();
233 audioBufferSampleRateRatioHistogram.sample(static_cast<int>(ratio + 0.5));
234 }
235 }
236
237 return buffer;
210 } 238 }
211 239
212 ScriptPromise AbstractAudioContext::decodeAudioData(ScriptState* scriptState, DO MArrayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallba ck* errorCallback, ExceptionState& exceptionState) 240 ScriptPromise AbstractAudioContext::decodeAudioData(ScriptState* scriptState, DO MArrayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallba ck* errorCallback, ExceptionState& exceptionState)
213 { 241 {
214 ASSERT(isMainThread()); 242 ASSERT(isMainThread());
215 ASSERT(audioData); 243 ASSERT(audioData);
216 244
217 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 245 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
218 ScriptPromise promise = resolver->promise(); 246 ScriptPromise promise = resolver->promise();
219 247
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 1009
982 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const 1010 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const
983 { 1011 {
984 if (getExecutionContext()) 1012 if (getExecutionContext())
985 return getExecutionContext()->getSecurityOrigin(); 1013 return getExecutionContext()->getSecurityOrigin();
986 1014
987 return nullptr; 1015 return nullptr;
988 } 1016 }
989 1017
990 } // namespace blink 1018 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webaudio/AudioContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698