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

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

Issue 1978403004: Add UMA histograms for WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, 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 17 matching lines...) Expand all
28 #include "bindings/core/v8/ScriptState.h" 28 #include "bindings/core/v8/ScriptState.h"
29 #include "core/dom/DOMException.h" 29 #include "core/dom/DOMException.h"
30 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
31 #include "core/dom/ExceptionCode.h" 31 #include "core/dom/ExceptionCode.h"
32 #include "core/dom/ExecutionContext.h" 32 #include "core/dom/ExecutionContext.h"
33 #include "modules/webaudio/AudioListener.h" 33 #include "modules/webaudio/AudioListener.h"
34 #include "modules/webaudio/DeferredTaskHandler.h" 34 #include "modules/webaudio/DeferredTaskHandler.h"
35 #include "modules/webaudio/OfflineAudioCompletionEvent.h" 35 #include "modules/webaudio/OfflineAudioCompletionEvent.h"
36 #include "modules/webaudio/OfflineAudioDestinationNode.h" 36 #include "modules/webaudio/OfflineAudioDestinationNode.h"
37 37
38 #include "platform/Histogram.h"
38 #include "platform/audio/AudioUtilities.h" 39 #include "platform/audio/AudioUtilities.h"
39 40
40 namespace blink { 41 namespace blink {
41 42
42 OfflineAudioContext* OfflineAudioContext::create(ExecutionContext* context, unsi gned numberOfChannels, unsigned numberOfFrames, float sampleRate, ExceptionState & exceptionState) 43 OfflineAudioContext* OfflineAudioContext::create(ExecutionContext* context, unsi gned numberOfChannels, unsigned numberOfFrames, float sampleRate, ExceptionState & exceptionState)
43 { 44 {
44 // FIXME: add support for workers. 45 // FIXME: add support for workers.
45 if (!context || !context->isDocument()) { 46 if (!context || !context->isDocument()) {
46 exceptionState.throwDOMException( 47 exceptionState.throwDOMException(
47 NotSupportedError, 48 NotSupportedError,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 84
84 if (!audioContext->destination()) { 85 if (!audioContext->destination()) {
85 exceptionState.throwDOMException( 86 exceptionState.throwDOMException(
86 NotSupportedError, 87 NotSupportedError,
87 "OfflineAudioContext(" + String::number(numberOfChannels) 88 "OfflineAudioContext(" + String::number(numberOfChannels)
88 + ", " + String::number(numberOfFrames) 89 + ", " + String::number(numberOfFrames)
89 + ", " + String::number(sampleRate) 90 + ", " + String::number(sampleRate)
90 + ")"); 91 + ")");
91 } 92 }
92 93
94 DEFINE_STATIC_LOCAL(SparseHistogram, offlineContextChannelCountHistogram,
Mark P 2016/05/23 18:10:24 SparseHistograms are slow because they acquire a l
Raymond Toy 2016/05/23 20:36:03 We don't expect many offline contexts, so speed is
Mark P 2016/05/23 21:30:24 Yes, I would encourage you to use other types when
Raymond Toy 2016/05/23 23:12:00 Unboundedness might be problem? Not really sure,
Mark P 2016/06/03 19:52:36 I'm still nervous about these being sparse histogr
95 ("WebAudio.OfflineAudioContext.ChannelCount"));
96 DEFINE_STATIC_LOCAL(SparseHistogram, offlineContextSampleRateHistogram,
97 ("WebAudio.OfflineAudioContext.SampleRate"));
98 DEFINE_STATIC_LOCAL(SparseHistogram, offlineContextLengthHistogram,
99 ("WebAudio.OfflineAudioContext.Length"));
100
101 offlineContextChannelCountHistogram.sample(numberOfChannels);
102 offlineContextSampleRateHistogram.sample(static_cast<int>(sampleRate));
103 offlineContextLengthHistogram.sample(clampTo(numberOfFrames, 0, std::numeric _limits<int>::max()));
104
93 audioContext->suspendIfNeeded(); 105 audioContext->suspendIfNeeded();
94 return audioContext; 106 return audioContext;
95 } 107 }
96 108
97 OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfCh annels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionState) 109 OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfCh annels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionState)
98 : AbstractAudioContext(document, numberOfChannels, numberOfFrames, sampleRat e) 110 : AbstractAudioContext(document, numberOfChannels, numberOfFrames, sampleRat e)
99 , m_isRenderingStarted(false) 111 , m_isRenderingStarted(false)
100 , m_totalRenderFrames(numberOfFrames) 112 , m_totalRenderFrames(numberOfFrames)
101 { 113 {
102 // Create a new destination for offline rendering. 114 // Create a new destination for offline rendering.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // Note that the GraphLock is required before this check. Since this needs 428 // Note that the GraphLock is required before this check. Since this needs
417 // to run on the audio thread, OfflineGraphAutoLocker must be used. 429 // to run on the audio thread, OfflineGraphAutoLocker must be used.
418 if (m_scheduledSuspends.contains(currentSampleFrame())) 430 if (m_scheduledSuspends.contains(currentSampleFrame()))
419 return true; 431 return true;
420 432
421 return false; 433 return false;
422 } 434 }
423 435
424 } // namespace blink 436 } // namespace blink
425 437
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698