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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/ChannelMergerNode.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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // channcelCountMode must be 'explicit'. 112 // channcelCountMode must be 'explicit'.
113 if (mode != "explicit") { 113 if (mode != "explicit") {
114 exceptionState.throwDOMException( 114 exceptionState.throwDOMException(
115 InvalidStateError, 115 InvalidStateError,
116 "ChannelMerger: channelCountMode cannot be changed from 'explicit'") ; 116 "ChannelMerger: channelCountMode cannot be changed from 'explicit'") ;
117 } 117 }
118 } 118 }
119 119
120 // ---------------------------------------------------------------- 120 // ----------------------------------------------------------------
121 121
122 ChannelMergerNode::ChannelMergerNode(AbstractAudioContext& context, float sample Rate, unsigned numberOfInputs) 122 ChannelMergerNode::ChannelMergerNode(AbstractAudioContext& context, unsigned num berOfInputs)
123 : AudioNode(context) 123 : AudioNode(context)
124 { 124 {
125 setHandler(ChannelMergerHandler::create(*this, sampleRate, numberOfInputs)); 125 setHandler(ChannelMergerHandler::create(*this, context.sampleRate(), numberO fInputs));
126 } 126 }
127 127
128 ChannelMergerNode* ChannelMergerNode::create(AbstractAudioContext& context, floa t sampleRate, unsigned numberOfInputs) 128 ChannelMergerNode* ChannelMergerNode::create(AbstractAudioContext& context, Exce ptionState& exceptionState)
129 { 129 {
130 if (!numberOfInputs || numberOfInputs > AbstractAudioContext::maxNumberOfCha nnels()) 130 ASSERT(isMainThread());
hongchan 2016/05/13 01:20:11 DCHECK?
Raymond Toy 2016/05/20 23:12:00 Done.
131
132 const unsigned ChannelMergerDefaultNumberOfInputs = 6;
hongchan 2016/05/13 01:20:11 Can we add TODO here? - "Create a global config fi
Raymond Toy 2016/05/13 15:59:51 Having a global for a constant that is used in exa
133 return create(context, ChannelMergerDefaultNumberOfInputs, exceptionState);
134 }
135
136 ChannelMergerNode* ChannelMergerNode::create(AbstractAudioContext& context, unsi gned numberOfInputs, ExceptionState& exceptionState)
137 {
138 ASSERT(isMainThread());
hongchan 2016/05/13 01:20:11 Ditto.
Raymond Toy 2016/05/20 23:12:00 Done.
139
140 if (context.isContextClosed()) {
141 context.throwExceptionForClosedState(exceptionState);
131 return nullptr; 142 return nullptr;
132 return new ChannelMergerNode(context, sampleRate, numberOfInputs); 143 }
144
145 if (!numberOfInputs || numberOfInputs > AbstractAudioContext::maxNumberOfCha nnels()) {
146 exceptionState.throwDOMException(
147 IndexSizeError,
148 ExceptionMessages::indexOutsideRange<size_t>(
149 "number of inputs",
150 numberOfInputs,
151 1,
152 ExceptionMessages::InclusiveBound,
153 AbstractAudioContext::maxNumberOfChannels(),
154 ExceptionMessages::InclusiveBound));
155 return nullptr;
156 }
157
158 return new ChannelMergerNode(context, numberOfInputs);
133 } 159 }
134 160
135 } // namespace blink 161 } // namespace blink
136 162
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698