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

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

Issue 1952793002: Move the exception logic to the AudioNode creator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move more things to Node::create() 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) 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // This will propagate the channel count to any nodes connected further downstream in the graph. 107 // This will propagate the channel count to any nodes connected further downstream in the graph.
108 output(0).setNumberOfChannels(numberOfChannels); 108 output(0).setNumberOfChannels(numberOfChannels);
109 initialize(); 109 initialize();
110 } 110 }
111 111
112 AudioHandler::checkNumberOfChannelsForInput(input); 112 AudioHandler::checkNumberOfChannelsForInput(input);
113 } 113 }
114 114
115 // ---------------------------------------------------------------- 115 // ----------------------------------------------------------------
116 116
117 GainNode::GainNode(AbstractAudioContext& context, float sampleRate) 117 GainNode::GainNode(AbstractAudioContext& context)
118 : AudioNode(context) 118 : AudioNode(context)
119 , m_gain(AudioParam::create(context, ParamTypeGainGain, 1.0)) 119 , m_gain(AudioParam::create(context, ParamTypeGainGain, 1.0))
120 { 120 {
121 setHandler(GainHandler::create(*this, sampleRate, m_gain->handler())); 121 setHandler(GainHandler::create(*this, context.sampleRate(), m_gain->handler( )));
122 } 122 }
123 123
124 GainNode* GainNode::create(AbstractAudioContext& context, float sampleRate) 124 GainNode* GainNode::create(AbstractAudioContext& context, ExceptionState& except ionState)
125 { 125 {
126 return new GainNode(context, sampleRate); 126 ASSERT(isMainThread());
hongchan 2016/05/13 01:20:12 DCHECK.
Raymond Toy 2016/05/20 23:12:00 Done.
127
128 if (context.isContextClosed()) {
129 context.throwExceptionForClosedState(exceptionState);
130 return nullptr;
131 }
132
133 return new GainNode(context);
127 } 134 }
128 135
129 AudioParam* GainNode::gain() const 136 AudioParam* GainNode::gain() const
130 { 137 {
131 return m_gain; 138 return m_gain;
132 } 139 }
133 140
134 DEFINE_TRACE(GainNode) 141 DEFINE_TRACE(GainNode)
135 { 142 {
136 visitor->trace(m_gain); 143 visitor->trace(m_gain);
137 AudioNode::trace(visitor); 144 AudioNode::trace(visitor);
138 } 145 }
139 146
140 } // namespace blink 147 } // namespace blink
141 148
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698