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

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

Issue 901013002: Revert of 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
« no previous file with comments | « Source/core/xmlhttprequest/XMLHttpRequest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ASSERT(m_state != BodyUsed); 106 ASSERT(m_state != BodyUsed);
107 ASSERT(m_stream); 107 ASSERT(m_stream);
108 ASSERT(dataLost); 108 ASSERT(dataLost);
109 m_drainingStreamBuffer = new BodyStreamBuffer(); 109 m_drainingStreamBuffer = new BodyStreamBuffer();
110 if (m_state == Errored) { 110 if (m_state == Errored) {
111 m_drainingStreamBuffer->error(exception()); 111 m_drainingStreamBuffer->error(exception());
112 return m_drainingStreamBuffer; 112 return m_drainingStreamBuffer;
113 } 113 }
114 // Take back the data in |m_stream|. 114 // Take back the data in |m_stream|.
115 Deque<std::pair<RefPtr<DOMArrayBuffer>, size_t>> tmp_queue; 115 Deque<std::pair<RefPtr<DOMArrayBuffer>, size_t>> tmp_queue;
116 if (m_stream->stateInternal() == ReadableStream::Readable) 116 if (m_stream->state() == ReadableStream::Readable)
117 m_stream->readInternal(tmp_queue); 117 m_stream->read(tmp_queue);
118 *dataLost = m_queueCount != tmp_queue.size(); 118 *dataLost = m_queueCount != tmp_queue.size();
119 while (!tmp_queue.isEmpty()) { 119 while (!tmp_queue.isEmpty()) {
120 std::pair<RefPtr<DOMArrayBuffer>, size_t> data = tmp_queue.takeFirst (); 120 std::pair<RefPtr<DOMArrayBuffer>, size_t> data = tmp_queue.takeFirst ();
121 m_drainingStreamBuffer->write(data.first); 121 m_drainingStreamBuffer->write(data.first);
122 } 122 }
123 if (m_state == Closed) 123 if (m_state == Closed)
124 m_drainingStreamBuffer->close(); 124 m_drainingStreamBuffer->close();
125 else 125 else
126 m_stream->close(); 126 m_stream->close();
127 return m_drainingStreamBuffer; 127 return m_drainingStreamBuffer;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 { 372 {
373 // Canceling the load will call didFail which will remove the resolver. 373 // Canceling the load will call didFail which will remove the resolver.
374 if (m_loader) 374 if (m_loader)
375 m_loader->cancel(); 375 m_loader->cancel();
376 } 376 }
377 377
378 bool Body::hasPendingActivity() const 378 bool Body::hasPendingActivity() const
379 { 379 {
380 if (m_resolver) 380 if (m_resolver)
381 return true; 381 return true;
382 if (m_stream && m_stream->hasPendingActivity()) 382 if (m_stream && (m_stream->state() == ReadableStream::Readable || m_stream-> state() == ReadableStream::Waiting))
383 return true; 383 return true;
384 return false; 384 return false;
385 } 385 }
386 386
387 void Body::trace(Visitor* visitor) 387 void Body::trace(Visitor* visitor)
388 { 388 {
389 visitor->trace(m_resolver); 389 visitor->trace(m_resolver);
390 visitor->trace(m_stream); 390 visitor->trace(m_stream);
391 visitor->trace(m_streamSource); 391 visitor->trace(m_streamSource);
392 ActiveDOMObject::trace(visitor); 392 ActiveDOMObject::trace(visitor);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 void Body::didBlobHandleReceiveError(PassRefPtrWillBeRawPtr<DOMException> except ion) 475 void Body::didBlobHandleReceiveError(PassRefPtrWillBeRawPtr<DOMException> except ion)
476 { 476 {
477 if (!m_resolver) 477 if (!m_resolver)
478 return; 478 return;
479 m_resolver->reject(exception); 479 m_resolver->reject(exception);
480 m_resolver.clear(); 480 m_resolver.clear();
481 } 481 }
482 482
483 } // namespace blink 483 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/xmlhttprequest/XMLHttpRequest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698