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

Side by Side Diff: third_party/WebKit/Source/core/streams/UnderlyingSourceBase.cpp

Issue 1902963003: [Streams] UnderlyingSourceBase should be kept alive only when locked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-stream-operations
Patch Set: Created 4 years, 8 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 // 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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698