| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/webaudio/AudioContext.h" | 6 #include "modules/webaudio/AudioContext.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionMessages.h" | 8 #include "bindings/core/v8/ExceptionMessages.h" |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 { | 75 { |
| 76 visitor->trace(m_closeResolver); | 76 visitor->trace(m_closeResolver); |
| 77 AbstractAudioContext::trace(visitor); | 77 AbstractAudioContext::trace(visitor); |
| 78 } | 78 } |
| 79 | 79 |
| 80 ScriptPromise AudioContext::suspendContext(ScriptState* scriptState) | 80 ScriptPromise AudioContext::suspendContext(ScriptState* scriptState) |
| 81 { | 81 { |
| 82 ASSERT(isMainThread()); | 82 ASSERT(isMainThread()); |
| 83 AutoLocker locker(this); | 83 AutoLocker locker(this); |
| 84 | 84 |
| 85 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 85 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 86 ScriptPromise promise = resolver->promise(); | 86 ScriptPromise promise = resolver->promise(); |
| 87 | 87 |
| 88 if (contextState() == Closed) { | 88 if (contextState() == Closed) { |
| 89 resolver->reject( | 89 resolver->reject( |
| 90 DOMException::create(InvalidStateError, "Cannot suspend a context th
at has been closed")); | 90 DOMException::create(InvalidStateError, "Cannot suspend a context th
at has been closed")); |
| 91 } else { | 91 } else { |
| 92 // Stop rendering now. | 92 // Stop rendering now. |
| 93 if (destination()) | 93 if (destination()) |
| 94 stopRendering(); | 94 stopRendering(); |
| 95 | 95 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 106 ASSERT(isMainThread()); | 106 ASSERT(isMainThread()); |
| 107 | 107 |
| 108 if (isContextClosed()) { | 108 if (isContextClosed()) { |
| 109 return ScriptPromise::rejectWithDOMException( | 109 return ScriptPromise::rejectWithDOMException( |
| 110 scriptState, | 110 scriptState, |
| 111 DOMException::create( | 111 DOMException::create( |
| 112 InvalidAccessError, | 112 InvalidAccessError, |
| 113 "cannot resume a closed AudioContext")); | 113 "cannot resume a closed AudioContext")); |
| 114 } | 114 } |
| 115 | 115 |
| 116 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 116 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 117 ScriptPromise promise = resolver->promise(); | 117 ScriptPromise promise = resolver->promise(); |
| 118 | 118 |
| 119 // Restart the destination node to pull on the audio graph. | 119 // Restart the destination node to pull on the audio graph. |
| 120 if (destination()) | 120 if (destination()) |
| 121 startRendering(); | 121 startRendering(); |
| 122 | 122 |
| 123 // Save the resolver which will get resolved when the destination node start
s pulling on the | 123 // Save the resolver which will get resolved when the destination node start
s pulling on the |
| 124 // graph again. | 124 // graph again. |
| 125 { | 125 { |
| 126 AutoLocker locker(this); | 126 AutoLocker locker(this); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 if (contextState() == Running) { | 179 if (contextState() == Running) { |
| 180 destination()->audioDestinationHandler().stopRendering(); | 180 destination()->audioDestinationHandler().stopRendering(); |
| 181 setContextState(Suspended); | 181 setContextState(Suspended); |
| 182 deferredTaskHandler().clearHandlersToBeDeleted(); | 182 deferredTaskHandler().clearHandlersToBeDeleted(); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace blink | 186 } // namespace blink |
| 187 | 187 |
| 188 #endif // ENABLE(WEB_AUDIO) | 188 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |