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

Side by Side Diff: Source/modules/fetch/Body.cpp

Issue 837673002: Introduce ExclusiveStreamReader. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/fetch/Body.h" 6 #include "modules/fetch/Body.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ASSERT(m_state != Initial); 105 ASSERT(m_state != Initial);
106 ASSERT(m_state != BodyUsed); 106 ASSERT(m_state != BodyUsed);
107 ASSERT(m_stream); 107 ASSERT(m_stream);
108 m_drainingStreamBuffer = new BodyStreamBuffer(); 108 m_drainingStreamBuffer = new BodyStreamBuffer();
109 if (m_state == Errored) { 109 if (m_state == Errored) {
110 m_drainingStreamBuffer->error(exception()); 110 m_drainingStreamBuffer->error(exception());
111 return m_drainingStreamBuffer; 111 return m_drainingStreamBuffer;
112 } 112 }
113 // Take back the data in |m_stream|. 113 // Take back the data in |m_stream|.
114 Deque<std::pair<RefPtr<DOMArrayBuffer>, size_t>> tmp_queue; 114 Deque<std::pair<RefPtr<DOMArrayBuffer>, size_t>> tmp_queue;
115 if (m_stream->state() == ReadableStream::Readable) 115 if (m_stream->stateInternal() == ReadableStream::Readable)
116 m_stream->read(tmp_queue); 116 m_stream->readInternal(tmp_queue);
117 while (!tmp_queue.isEmpty()) { 117 while (!tmp_queue.isEmpty()) {
118 std::pair<RefPtr<DOMArrayBuffer>, size_t> data = tmp_queue.takeFirst (); 118 std::pair<RefPtr<DOMArrayBuffer>, size_t> data = tmp_queue.takeFirst ();
119 m_drainingStreamBuffer->write(data.first); 119 m_drainingStreamBuffer->write(data.first);
120 } 120 }
121 if (m_state == Closed) 121 if (m_state == Closed)
122 m_drainingStreamBuffer->close(); 122 m_drainingStreamBuffer->close();
123 else 123 else
124 m_stream->close(); 124 m_stream->close();
125 return m_drainingStreamBuffer; 125 return m_drainingStreamBuffer;
126 } 126 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 { 356 {
357 // Canceling the load will call didFail which will remove the resolver. 357 // Canceling the load will call didFail which will remove the resolver.
358 if (m_loader) 358 if (m_loader)
359 m_loader->cancel(); 359 m_loader->cancel();
360 } 360 }
361 361
362 bool Body::hasPendingActivity() const 362 bool Body::hasPendingActivity() const
363 { 363 {
364 if (m_resolver) 364 if (m_resolver)
365 return true; 365 return true;
366 if (m_stream && (m_stream->state() == ReadableStream::Readable || m_stream-> state() == ReadableStream::Waiting)) 366 if (m_stream && m_stream->hasPendingActivity())
367 return true; 367 return true;
368 return false; 368 return false;
369 } 369 }
370 370
371 void Body::trace(Visitor* visitor) 371 void Body::trace(Visitor* visitor)
372 { 372 {
373 visitor->trace(m_resolver); 373 visitor->trace(m_resolver);
374 visitor->trace(m_stream); 374 visitor->trace(m_stream);
375 visitor->trace(m_streamSource); 375 visitor->trace(m_streamSource);
376 ActiveDOMObject::trace(visitor); 376 ActiveDOMObject::trace(visitor);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 458
459 void Body::didBlobHandleReceiveError(PassRefPtrWillBeRawPtr<DOMException> except ion) 459 void Body::didBlobHandleReceiveError(PassRefPtrWillBeRawPtr<DOMException> except ion)
460 { 460 {
461 if (!m_resolver) 461 if (!m_resolver)
462 return; 462 return;
463 m_resolver->reject(exception); 463 m_resolver->reject(exception);
464 m_resolver.clear(); 464 m_resolver.clear();
465 } 465 }
466 466
467 } // namespace blink 467 } // namespace blink
OLDNEW
« Source/core/streams/ReadableStream.h ('K') | « Source/core/xmlhttprequest/XMLHttpRequest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698