| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |