| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/streams/UnderlyingSourceBase.h" | 5 #include "core/streams/UnderlyingSourceBase.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
| 10 #include "core/streams/ReadableStreamController.h" | 10 #include "core/streams/ReadableStreamController.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 { | 39 { |
| 40 m_controller->noteHasBeenCanceled(); | 40 m_controller->noteHasBeenCanceled(); |
| 41 return cancel(scriptState, reason); | 41 return cancel(scriptState, reason); |
| 42 } | 42 } |
| 43 | 43 |
| 44 ScriptPromise UnderlyingSourceBase::cancel(ScriptState* scriptState, ScriptValue
reason) | 44 ScriptPromise UnderlyingSourceBase::cancel(ScriptState* scriptState, ScriptValue
reason) |
| 45 { | 45 { |
| 46 return ScriptPromise::castUndefined(scriptState); | 46 return ScriptPromise::castUndefined(scriptState); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void UnderlyingSourceBase::notifyLockAcquired() |
| 50 { |
| 51 m_isStreamLocked = true; |
| 52 } |
| 53 |
| 54 void UnderlyingSourceBase::notifyLockReleased() |
| 55 { |
| 56 m_isStreamLocked = false; |
| 57 } |
| 58 |
| 49 bool UnderlyingSourceBase::hasPendingActivity() const | 59 bool UnderlyingSourceBase::hasPendingActivity() const |
| 50 { | 60 { |
| 51 // This will return false within a finite time period _assuming_ that | 61 // This will return false within a finite time period _assuming_ that |
| 52 // consumers use the controller to close or error the stream. | 62 // consumers use the controller to close or error the stream. |
| 53 // Browser-created readable streams should always close or error within a | 63 // Browser-created readable streams should always close or error within a |
| 54 // finite time period, due to timeouts etc. | 64 // finite time period, due to timeouts etc. |
| 55 return m_controller && m_controller->isActive(); | 65 return m_controller && m_controller->isActive() && m_isStreamLocked; |
| 56 } | 66 } |
| 57 | 67 |
| 58 void UnderlyingSourceBase::stop() | 68 void UnderlyingSourceBase::stop() |
| 59 { | 69 { |
| 60 m_controller->noteHasBeenCanceled(); | 70 m_controller->noteHasBeenCanceled(); |
| 61 m_controller.clear(); | 71 m_controller.clear(); |
| 62 } | 72 } |
| 63 | 73 |
| 64 DEFINE_TRACE(UnderlyingSourceBase) | 74 DEFINE_TRACE(UnderlyingSourceBase) |
| 65 { | 75 { |
| 66 ActiveDOMObject::trace(visitor); | 76 ActiveDOMObject::trace(visitor); |
| 67 visitor->trace(m_controller); | 77 visitor->trace(m_controller); |
| 68 } | 78 } |
| 69 | 79 |
| 70 } // namespace blink | 80 } // namespace blink |
| OLD | NEW |