| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 FrameLoader* DocumentLoader::frameLoader() const { | 125 FrameLoader* DocumentLoader::frameLoader() const { |
| 126 if (!m_frame) | 126 if (!m_frame) |
| 127 return nullptr; | 127 return nullptr; |
| 128 return &m_frame->loader(); | 128 return &m_frame->loader(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 DocumentLoader::~DocumentLoader() { | 131 DocumentLoader::~DocumentLoader() { |
| 132 DCHECK(!m_frame); | 132 DCHECK(!m_frame); |
| 133 DCHECK(!m_mainResource); | 133 DCHECK(!m_mainResource); |
| 134 DCHECK(!m_applicationCacheHost); | 134 DCHECK(!m_applicationCacheHost); |
| 135 DCHECK_EQ(m_state, SentDidFinishLoad); |
| 135 } | 136 } |
| 136 | 137 |
| 137 DEFINE_TRACE(DocumentLoader) { | 138 DEFINE_TRACE(DocumentLoader) { |
| 138 visitor->trace(m_frame); | 139 visitor->trace(m_frame); |
| 139 visitor->trace(m_fetcher); | 140 visitor->trace(m_fetcher); |
| 140 visitor->trace(m_mainResource); | 141 visitor->trace(m_mainResource); |
| 141 visitor->trace(m_writer); | 142 visitor->trace(m_writer); |
| 142 visitor->trace(m_documentLoadTiming); | 143 visitor->trace(m_documentLoadTiming); |
| 143 visitor->trace(m_applicationCacheHost); | 144 visitor->trace(m_applicationCacheHost); |
| 144 visitor->trace(m_contentSecurityPolicy); | 145 visitor->trace(m_contentSecurityPolicy); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 DCHECK_EQ(m_mainResource, resource); | 279 DCHECK_EQ(m_mainResource, resource); |
| 279 DCHECK(m_mainResource); | 280 DCHECK(m_mainResource); |
| 280 | 281 |
| 281 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { | 282 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { |
| 282 finishedLoading(m_mainResource->loadFinishTime()); | 283 finishedLoading(m_mainResource->loadFinishTime()); |
| 283 return; | 284 return; |
| 284 } | 285 } |
| 285 | 286 |
| 286 if (m_applicationCacheHost) | 287 if (m_applicationCacheHost) |
| 287 m_applicationCacheHost->failedLoadingMainResource(); | 288 m_applicationCacheHost->failedLoadingMainResource(); |
| 288 m_state = MainResourceDone; | |
| 289 | 289 |
| 290 if (m_mainResource->resourceError().wasBlockedByResponse()) { | 290 if (m_mainResource->resourceError().wasBlockedByResponse()) { |
| 291 InspectorInstrumentation::canceledAfterReceivedResourceResponse( | 291 InspectorInstrumentation::canceledAfterReceivedResourceResponse( |
| 292 m_frame, this, mainResourceIdentifier(), resource->response(), | 292 m_frame, this, mainResourceIdentifier(), resource->response(), |
| 293 m_mainResource.get()); | 293 m_mainResource.get()); |
| 294 } | 294 } |
| 295 | 295 |
| 296 frameLoader()->loadFailed(this, m_mainResource->resourceError()); | 296 frameLoader()->loadFailed(this, m_mainResource->resourceError()); |
| 297 clearMainResourceHandle(); | 297 clearMainResourceHandle(); |
| 298 } | 298 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 319 // the Document. | 319 // the Document. |
| 320 if (!m_writer) | 320 if (!m_writer) |
| 321 commitData(0, 0); | 321 commitData(0, 0); |
| 322 } | 322 } |
| 323 | 323 |
| 324 if (!m_frame) | 324 if (!m_frame) |
| 325 return; | 325 return; |
| 326 | 326 |
| 327 m_applicationCacheHost->finishedLoadingMainResource(); | 327 m_applicationCacheHost->finishedLoadingMainResource(); |
| 328 endWriting(); | 328 endWriting(); |
| 329 if (m_state < MainResourceDone) | |
| 330 m_state = MainResourceDone; | |
| 331 clearMainResourceHandle(); | 329 clearMainResourceHandle(); |
| 332 | 330 |
| 333 // Shows the deprecation message and measures the impact of the new security | 331 // Shows the deprecation message and measures the impact of the new security |
| 334 // restriction which disallows responding to navigation requests with | 332 // restriction which disallows responding to navigation requests with |
| 335 // redirected responses in the service worker. | 333 // redirected responses in the service worker. |
| 336 // TODO(horo): Remove this when we actually introduce the restriction in | 334 // TODO(horo): Remove this when we actually introduce the restriction in |
| 337 // RespondWithObserver. | 335 // RespondWithObserver. |
| 338 if (m_response.wasFetchedViaServiceWorker() && | 336 if (m_response.wasFetchedViaServiceWorker() && |
| 339 m_response.urlListViaServiceWorker().size() > 1) { | 337 m_response.urlListViaServiceWorker().size() > 1) { |
| 340 Deprecation::countDeprecation( | 338 Deprecation::countDeprecation( |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 542 |
| 545 m_writer = createWriterFor(init, mimeType, encoding, false, parsingPolicy, | 543 m_writer = createWriterFor(init, mimeType, encoding, false, parsingPolicy, |
| 546 overridingURL); | 544 overridingURL); |
| 547 m_writer->setDocumentWasLoadedAsPartOfNavigation(); | 545 m_writer->setDocumentWasLoadedAsPartOfNavigation(); |
| 548 m_frame->document()->maybeHandleHttpRefresh( | 546 m_frame->document()->maybeHandleHttpRefresh( |
| 549 m_response.httpHeaderField(HTTPNames::Refresh), | 547 m_response.httpHeaderField(HTTPNames::Refresh), |
| 550 Document::HttpRefreshFromHeader); | 548 Document::HttpRefreshFromHeader); |
| 551 } | 549 } |
| 552 | 550 |
| 553 void DocumentLoader::commitData(const char* bytes, size_t length) { | 551 void DocumentLoader::commitData(const char* bytes, size_t length) { |
| 554 DCHECK_LT(m_state, MainResourceDone); | 552 DCHECK_EQ(m_state, Committed); |
| 555 ensureWriter(m_response.mimeType()); | 553 ensureWriter(m_response.mimeType()); |
| 556 | 554 |
| 557 // This can happen if document.close() is called by an event handler while | 555 // This can happen if document.close() is called by an event handler while |
| 558 // there's still pending incoming data. | 556 // there's still pending incoming data. |
| 559 if (m_frame && !m_frame->document()->parsing()) | 557 if (m_frame && !m_frame->document()->parsing()) |
| 560 return; | 558 return; |
| 561 | 559 |
| 562 if (length) | 560 if (length) |
| 563 m_dataReceived = true; | 561 m_dataReceived = true; |
| 564 | 562 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 m_redirectChain.append(url); | 624 m_redirectChain.append(url); |
| 627 } | 625 } |
| 628 | 626 |
| 629 void DocumentLoader::detachFromFrame() { | 627 void DocumentLoader::detachFromFrame() { |
| 630 DCHECK(m_frame); | 628 DCHECK(m_frame); |
| 631 | 629 |
| 632 // It never makes sense to have a document loader that is detached from its | 630 // It never makes sense to have a document loader that is detached from its |
| 633 // frame have any loads active, so go ahead and kill all the loads. | 631 // frame have any loads active, so go ahead and kill all the loads. |
| 634 m_fetcher->stopFetching(); | 632 m_fetcher->stopFetching(); |
| 635 | 633 |
| 634 if (frameLoader() && !sentDidFinishLoad()) |
| 635 frameLoader()->loadFailed(this, ResourceError::cancelledError(url())); |
| 636 |
| 636 // If that load cancellation triggered another detach, leave. | 637 // If that load cancellation triggered another detach, leave. |
| 637 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.) | 638 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.) |
| 638 if (!m_frame) | 639 if (!m_frame) |
| 639 return; | 640 return; |
| 640 | 641 |
| 641 m_fetcher->clearContext(); | 642 m_fetcher->clearContext(); |
| 642 m_applicationCacheHost->detachFromDocumentLoader(); | 643 m_applicationCacheHost->detachFromDocumentLoader(); |
| 643 m_applicationCacheHost.clear(); | 644 m_applicationCacheHost.clear(); |
| 644 WeakIdentifierMap<DocumentLoader>::notifyObjectDestroyed(this); | 645 WeakIdentifierMap<DocumentLoader>::notifyObjectDestroyed(this); |
| 645 clearMainResourceHandle(); | 646 clearMainResourceHandle(); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 m_writer ? m_writer->encoding() : emptyAtom, true, | 801 m_writer ? m_writer->encoding() : emptyAtom, true, |
| 801 ForceSynchronousParsing); | 802 ForceSynchronousParsing); |
| 802 if (!source.isNull()) | 803 if (!source.isNull()) |
| 803 m_writer->appendReplacingData(source); | 804 m_writer->appendReplacingData(source); |
| 804 endWriting(); | 805 endWriting(); |
| 805 } | 806 } |
| 806 | 807 |
| 807 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); | 808 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); |
| 808 | 809 |
| 809 } // namespace blink | 810 } // namespace blink |
| OLD | NEW |