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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/BlobBytesConsumer.cpp

Issue 2564503002: Fix BlobBytesConsumer state assumption on cancellation (Closed)
Patch Set: fix Created 4 years 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 | « no previous file | 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 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 "modules/fetch/BlobBytesConsumer.h" 5 #include "modules/fetch/BlobBytesConsumer.h"
6 6
7 #include "core/fetch/FetchInitiatorTypeNames.h" 7 #include "core/fetch/FetchInitiatorTypeNames.h"
8 #include "core/loader/ThreadableLoader.h" 8 #include "core/loader/ThreadableLoader.h"
9 #include "modules/fetch/BytesConsumerForDataConsumerHandle.h" 9 #include "modules/fetch/BytesConsumerForDataConsumerHandle.h"
10 #include "platform/blob/BlobData.h" 10 #include "platform/blob/BlobData.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 return; 224 return;
225 DCHECK(!isClean()); 225 DCHECK(!isClean());
226 BytesConsumer::Client* client = m_client; 226 BytesConsumer::Client* client = m_client;
227 close(); 227 close();
228 if (client) 228 if (client)
229 client->onStateChange(); 229 client->onStateChange();
230 } 230 }
231 231
232 void BlobBytesConsumer::didFail(const ResourceError& e) { 232 void BlobBytesConsumer::didFail(const ResourceError& e) {
233 if (e.isCancellation()) { 233 if (e.isCancellation()) {
234 DCHECK_EQ(PublicState::Closed, m_state); 234 // |m_loader| can be canceled when
235 return; 235 // - this object explicitly cancels it, or
236 // - the global context is shutting down.
237 // In the first case, |m_state| should be Closed.
238 if (getExecutionContext() && !getExecutionContext()->isContextDestroyed())
239 DCHECK_EQ(PublicState::Closed, m_state);
240 if (m_state == PublicState::Closed)
241 return;
236 } 242 }
237 DCHECK_EQ(PublicState::ReadableOrWaiting, m_state); 243 DCHECK_EQ(PublicState::ReadableOrWaiting, m_state);
238 m_loader = nullptr; 244 m_loader = nullptr;
239 BytesConsumer::Client* client = m_client; 245 BytesConsumer::Client* client = m_client;
240 error(); 246 error();
241 if (isClean()) { 247 if (isClean()) {
242 // This function is called synchronously in ThreadableLoader::start. 248 // This function is called synchronously in ThreadableLoader::start.
243 return; 249 return;
244 } 250 }
245 if (client) { 251 if (client) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void BlobBytesConsumer::clear() { 304 void BlobBytesConsumer::clear() {
299 DCHECK_NE(m_state, PublicState::ReadableOrWaiting); 305 DCHECK_NE(m_state, PublicState::ReadableOrWaiting);
300 if (m_loader) { 306 if (m_loader) {
301 m_loader->cancel(); 307 m_loader->cancel();
302 m_loader = nullptr; 308 m_loader = nullptr;
303 } 309 }
304 m_client = nullptr; 310 m_client = nullptr;
305 } 311 }
306 312
307 } // namespace blink 313 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698