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

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

Issue 2572683002: Fix BlobBytesConsumer state assumption on cancellation (Closed)
Patch Set: 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 // |m_loader| can be canceled when 234 if (m_state != PublicState::ReadableOrWaiting)
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; 235 return;
242 } 236 }
243 DCHECK_EQ(PublicState::ReadableOrWaiting, m_state); 237 DCHECK_EQ(PublicState::ReadableOrWaiting, m_state);
244 m_loader = nullptr; 238 m_loader = nullptr;
245 BytesConsumer::Client* client = m_client; 239 BytesConsumer::Client* client = m_client;
246 error(); 240 error();
247 if (isClean()) { 241 if (isClean()) {
248 // This function is called synchronously in ThreadableLoader::start. 242 // This function is called synchronously in ThreadableLoader::start.
249 return; 243 return;
250 } 244 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 void BlobBytesConsumer::clear() { 298 void BlobBytesConsumer::clear() {
305 DCHECK_NE(m_state, PublicState::ReadableOrWaiting); 299 DCHECK_NE(m_state, PublicState::ReadableOrWaiting);
306 if (m_loader) { 300 if (m_loader) {
307 m_loader->cancel(); 301 m_loader->cancel();
308 m_loader = nullptr; 302 m_loader = nullptr;
309 } 303 }
310 m_client = nullptr; 304 m_client = nullptr;
311 } 305 }
312 306
313 } // namespace blink 307 } // 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