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

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

Issue 2389253002: reflow comments in modules/{webaudio,vr} (Closed)
Patch Set: . Created 4 years, 2 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // 170 //
171 // See: crbug.com/435867 171 // See: crbug.com/435867
172 if (isContextClosed()) { 172 if (isContextClosed()) {
173 return ScriptPromise::rejectWithDOMException( 173 return ScriptPromise::rejectWithDOMException(
174 scriptState, 174 scriptState,
175 DOMException::create(InvalidStateError, 175 DOMException::create(InvalidStateError,
176 "cannot call startRendering on an " 176 "cannot call startRendering on an "
177 "OfflineAudioContext in a stopped state.")); 177 "OfflineAudioContext in a stopped state."));
178 } 178 }
179 179
180 // If the context is not in the suspended state (i.e. running), reject the pro mise. 180 // If the context is not in the suspended state (i.e. running), reject the
181 // promise.
181 if (contextState() != AudioContextState::Suspended) { 182 if (contextState() != AudioContextState::Suspended) {
182 return ScriptPromise::rejectWithDOMException( 183 return ScriptPromise::rejectWithDOMException(
183 scriptState, 184 scriptState,
184 DOMException::create( 185 DOMException::create(
185 InvalidStateError, 186 InvalidStateError,
186 "cannot startRendering when an OfflineAudioContext is " + state())); 187 "cannot startRendering when an OfflineAudioContext is " + state()));
187 } 188 }
188 189
189 // Can't call startRendering more than once. Return a rejected promise now. 190 // Can't call startRendering more than once. Return a rejected promise now.
190 if (m_isRenderingStarted) { 191 if (m_isRenderingStarted) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 391
391 void OfflineAudioContext::resolveSuspendOnMainThread(size_t frame) { 392 void OfflineAudioContext::resolveSuspendOnMainThread(size_t frame) {
392 DCHECK(isMainThread()); 393 DCHECK(isMainThread());
393 394
394 // Suspend the context first. This will fire onstatechange event. 395 // Suspend the context first. This will fire onstatechange event.
395 setContextState(Suspended); 396 setContextState(Suspended);
396 397
397 // Wait until the suspend map is available for the removal. 398 // Wait until the suspend map is available for the removal.
398 AutoLocker locker(this); 399 AutoLocker locker(this);
399 400
400 // If the context is going away, m_scheduledSuspends could have had all its en tries removed. 401 // If the context is going away, m_scheduledSuspends could have had all its
401 // Check for that here. 402 // entries removed. Check for that here.
402 if (m_scheduledSuspends.size()) { 403 if (m_scheduledSuspends.size()) {
403 // |frame| must exist in the map. 404 // |frame| must exist in the map.
404 DCHECK(m_scheduledSuspends.contains(frame)); 405 DCHECK(m_scheduledSuspends.contains(frame));
405 406
406 SuspendMap::iterator it = m_scheduledSuspends.find(frame); 407 SuspendMap::iterator it = m_scheduledSuspends.find(frame);
407 it->value->resolve(); 408 it->value->resolve();
408 409
409 m_scheduledSuspends.remove(it); 410 m_scheduledSuspends.remove(it);
410 } 411 }
411 } 412 }
412 413
413 void OfflineAudioContext::rejectPendingResolvers() { 414 void OfflineAudioContext::rejectPendingResolvers() {
414 DCHECK(isMainThread()); 415 DCHECK(isMainThread());
415 416
416 // Wait until the suspend map is available for removal. 417 // Wait until the suspend map is available for removal.
417 AutoLocker locker(this); 418 AutoLocker locker(this);
418 419
419 // Offline context is going away so reject any promises that are still pending . 420 // Offline context is going away so reject any promises that are still
421 // pending.
420 422
421 for (auto& pendingSuspendResolver : m_scheduledSuspends) { 423 for (auto& pendingSuspendResolver : m_scheduledSuspends) {
422 pendingSuspendResolver.value->reject( 424 pendingSuspendResolver.value->reject(
423 DOMException::create(InvalidStateError, "Audio context is going away")); 425 DOMException::create(InvalidStateError, "Audio context is going away"));
424 } 426 }
425 427
426 m_scheduledSuspends.clear(); 428 m_scheduledSuspends.clear();
427 DCHECK_EQ(m_resumeResolvers.size(), 0u); 429 DCHECK_EQ(m_resumeResolvers.size(), 0u);
428 430
429 rejectPendingDecodeAudioDataResolvers(); 431 rejectPendingDecodeAudioDataResolvers();
430 } 432 }
431 433
432 bool OfflineAudioContext::shouldSuspend() { 434 bool OfflineAudioContext::shouldSuspend() {
433 DCHECK(isAudioThread()); 435 DCHECK(isAudioThread());
434 436
435 // Note that the GraphLock is required before this check. Since this needs 437 // Note that the GraphLock is required before this check. Since this needs
436 // to run on the audio thread, OfflineGraphAutoLocker must be used. 438 // to run on the audio thread, OfflineGraphAutoLocker must be used.
437 if (m_scheduledSuspends.contains(currentSampleFrame())) 439 if (m_scheduledSuspends.contains(currentSampleFrame()))
438 return true; 440 return true;
439 441
440 return false; 442 return false;
441 } 443 }
442 444
443 } // namespace blink 445 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698