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

Side by Side Diff: Source/core/loader/DocumentLoader.cpp

Issue 1124153003: [Oilpan] [Reland] Migrate classes under core/fetch to Oilpan heap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix webkit_tests Created 5 years, 6 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/loader/DocumentLoader.h ('k') | Source/core/loader/FrameFetchContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 // Cancels the data source's pending loads. Conceptually, a data source only lo ads 213 // Cancels the data source's pending loads. Conceptually, a data source only lo ads
214 // one document at a time, but one document may have many related resources. 214 // one document at a time, but one document may have many related resources.
215 // stopLoading will stop all loads initiated by the data source, 215 // stopLoading will stop all loads initiated by the data source,
216 // but not loads initiated by child frames' data sources -- that's the WebFrame' s job. 216 // but not loads initiated by child frames' data sources -- that's the WebFrame' s job.
217 void DocumentLoader::stopLoading() 217 void DocumentLoader::stopLoading()
218 { 218 {
219 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame.get()); 219 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame.get());
220 RefPtrWillBeRawPtr<DocumentLoader> protectLoader(this); 220 RefPtrWillBeRawPtr<DocumentLoader> protectLoader(this);
221 221
222 m_fetcher->stopFetching(); 222 if (m_fetcher)
223 m_fetcher->stopFetching();
223 if (isLoading()) 224 if (isLoading())
224 cancelMainResourceLoad(ResourceError::cancelledError(m_request.url())); 225 cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()));
225 } 226 }
226 227
227 void DocumentLoader::commitIfReady() 228 void DocumentLoader::commitIfReady()
228 { 229 {
229 if (!m_committed) { 230 if (!m_committed) {
230 m_committed = true; 231 m_committed = true;
231 frameLoader()->commitProvisionalLoad(); 232 frameLoader()->commitProvisionalLoad();
232 } 233 }
233 } 234 }
234 235
235 bool DocumentLoader::isLoading() const 236 bool DocumentLoader::isLoading() const
236 { 237 {
237 if (document() && document()->hasActiveParser()) 238 if (document() && document()->hasActiveParser())
238 return true; 239 return true;
239 240
240 return m_loadingMainResource || m_fetcher->isFetching(); 241 return m_loadingMainResource || (m_fetcher && m_fetcher->isFetching());
241 } 242 }
242 243
243 void DocumentLoader::notifyFinished(Resource* resource) 244 void DocumentLoader::notifyFinished(Resource* resource)
244 { 245 {
245 ASSERT_UNUSED(resource, m_mainResource == resource); 246 ASSERT_UNUSED(resource, m_mainResource == resource);
246 ASSERT(m_mainResource); 247 ASSERT(m_mainResource);
247 248
248 RefPtrWillBeRawPtr<DocumentLoader> protect(this); 249 RefPtrWillBeRawPtr<DocumentLoader> protect(this);
249 250
250 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { 251 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 595
595 // It never makes sense to have a document loader that is detached from its 596 // It never makes sense to have a document loader that is detached from its
596 // frame have any loads active, so go ahead and kill all the loads. 597 // frame have any loads active, so go ahead and kill all the loads.
597 stopLoading(); 598 stopLoading();
598 599
599 // If that load cancellation triggered another detach, leave. 600 // If that load cancellation triggered another detach, leave.
600 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.) 601 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.)
601 if (!m_frame) 602 if (!m_frame)
602 return; 603 return;
603 604
604 m_fetcher->clearContext(); 605 if (m_fetcher)
606 m_fetcher->clearContext();
607 m_fetcher.clear();
608
605 m_applicationCacheHost->detachFromDocumentLoader(); 609 m_applicationCacheHost->detachFromDocumentLoader();
606 m_applicationCacheHost.clear(); 610 m_applicationCacheHost.clear();
607 WeakIdentifierMap<DocumentLoader>::notifyObjectDestroyed(this); 611 WeakIdentifierMap<DocumentLoader>::notifyObjectDestroyed(this);
608 clearMainResourceHandle(); 612 clearMainResourceHandle();
609 m_frame = nullptr; 613 m_frame = nullptr;
610 } 614 }
611 615
612 void DocumentLoader::clearMainResourceLoader() 616 void DocumentLoader::clearMainResourceLoader()
613 { 617 {
614 m_loadingMainResource = false; 618 m_loadingMainResource = false;
(...skipping 18 matching lines...) Expand all
633 return false; 637 return false;
634 638
635 ASSERT(m_mainResource); 639 ASSERT(m_mainResource);
636 m_archive = MHTMLArchive::create(m_response.url(), m_mainResource->resourceB uffer()); 640 m_archive = MHTMLArchive::create(m_response.url(), m_mainResource->resourceB uffer());
637 // Invalid MHTML. 641 // Invalid MHTML.
638 if (!m_archive || !m_archive->mainResource()) { 642 if (!m_archive || !m_archive->mainResource()) {
639 m_archive.clear(); 643 m_archive.clear();
640 return false; 644 return false;
641 } 645 }
642 646
643 m_fetcher->addAllArchiveResources(m_archive.get()); 647 if (m_fetcher)
sof 2015/06/26 07:21:45 Trying to understand; could you explain why the m_
peria 2015/06/26 07:31:43 No theoretical backgroud. :( I'm just looking if t
sof 2015/06/29 13:29:29 I can't see much going wrong when I revert those c
sof 2015/06/29 15:00:47 Having looked at that test failure some, I'm wonde
peria 2015/06/30 07:14:39 Yes, we need this check in Document::finishedParsi
648 m_fetcher->addAllArchiveResources(m_archive.get());
644 ArchiveResource* mainResource = m_archive->mainResource(); 649 ArchiveResource* mainResource = m_archive->mainResource();
645 650
646 // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so 651 // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so
647 // relative URLs are resolved properly. 652 // relative URLs are resolved properly.
648 ensureWriter(mainResource->mimeType(), m_archive->mainResource()->url()); 653 ensureWriter(mainResource->mimeType(), m_archive->mainResource()->url());
649 654
650 // The Document has now been created. 655 // The Document has now been created.
651 document()->enforceSandboxFlags(SandboxAll); 656 document()->enforceSandboxFlags(SandboxAll);
652 657
653 commitData(mainResource->data()->data(), mainResource->data()->size()); 658 commitData(mainResource->data()->data(), mainResource->data()->size());
654 return true; 659 return true;
655 } 660 }
656 661
657 void DocumentLoader::prepareSubframeArchiveLoadIfNeeded() 662 void DocumentLoader::prepareSubframeArchiveLoadIfNeeded()
658 { 663 {
659 if (!m_frame->tree().parent() || !m_frame->tree().parent()->isLocalFrame()) 664 if (!m_frame->tree().parent() || !m_frame->tree().parent()->isLocalFrame())
660 return; 665 return;
661 666
662 ArchiveResourceCollection* parentCollection = toLocalFrame(m_frame->tree().p arent())->loader().documentLoader()->fetcher()->archiveResourceCollection(); 667 ArchiveResourceCollection* parentCollection = toLocalFrame(m_frame->tree().p arent())->loader().documentLoader()->fetcher()->archiveResourceCollection();
663 if (!parentCollection) 668 if (!parentCollection)
664 return; 669 return;
665 670
666 m_archive = parentCollection->popSubframeArchive(m_frame->tree().uniqueName( ), m_request.url()); 671 m_archive = parentCollection->popSubframeArchive(m_frame->tree().uniqueName( ), m_request.url());
667 672
668 if (!m_archive) 673 if (!m_archive)
669 return; 674 return;
670 m_fetcher->addAllArchiveResources(m_archive.get()); 675 if (m_fetcher)
676 m_fetcher->addAllArchiveResources(m_archive.get());
671 677
672 ArchiveResource* mainResource = m_archive->mainResource(); 678 ArchiveResource* mainResource = m_archive->mainResource();
673 m_substituteData = SubstituteData(mainResource->data(), mainResource->mimeTy pe(), mainResource->textEncoding(), KURL()); 679 m_substituteData = SubstituteData(mainResource->data(), mainResource->mimeTy pe(), mainResource->textEncoding(), KURL());
674 } 680 }
675 681
676 const AtomicString& DocumentLoader::responseMIMEType() const 682 const AtomicString& DocumentLoader::responseMIMEType() const
677 { 683 {
678 return m_response.mimeType(); 684 return m_response.mimeType();
679 } 685 }
680 686
681 const KURL& DocumentLoader::unreachableURL() const 687 const KURL& DocumentLoader::unreachableURL() const
682 { 688 {
683 return m_substituteData.failingURL(); 689 return m_substituteData.failingURL();
684 } 690 }
685 691
686 void DocumentLoader::setDefersLoading(bool defers) 692 void DocumentLoader::setDefersLoading(bool defers)
687 { 693 {
688 // Multiple frames may be loading the same main resource simultaneously. If deferral state changes, 694 // Multiple frames may be loading the same main resource simultaneously. If deferral state changes,
689 // each frame's DocumentLoader will try to send a setDefersLoading() to the same underlying ResourceLoader. Ensure only 695 // each frame's DocumentLoader will try to send a setDefersLoading() to the same underlying ResourceLoader. Ensure only
690 // the "owning" DocumentLoader does so, as setDefersLoading() is not resilie nt to setting the same value repeatedly. 696 // the "owning" DocumentLoader does so, as setDefersLoading() is not resilie nt to setting the same value repeatedly.
691 if (mainResourceLoader() && mainResourceLoader()->isLoadedBy(m_fetcher.get() )) 697 if (mainResourceLoader() && mainResourceLoader()->isLoadedBy(m_fetcher.get() ))
692 mainResourceLoader()->setDefersLoading(defers); 698 mainResourceLoader()->setDefersLoading(defers);
693 699
694 m_fetcher->setDefersLoading(defers); 700 if (m_fetcher)
701 m_fetcher->setDefersLoading(defers);
695 } 702 }
696 703
697 bool DocumentLoader::maybeLoadEmpty() 704 bool DocumentLoader::maybeLoadEmpty()
698 { 705 {
699 bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmp ty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().proto col())); 706 bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmp ty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().proto col()));
700 if (!shouldLoadEmpty) 707 if (!shouldLoadEmpty)
701 return false; 708 return false;
702 709
703 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument()) 710 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument())
704 m_request.setURL(blankURL()); 711 m_request.setURL(blankURL());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 } 778 }
772 779
773 void DocumentLoader::attachThreadedDataReceiver(PassRefPtrWillBeRawPtr<ThreadedD ataReceiver> threadedDataReceiver) 780 void DocumentLoader::attachThreadedDataReceiver(PassRefPtrWillBeRawPtr<ThreadedD ataReceiver> threadedDataReceiver)
774 { 781 {
775 if (mainResourceLoader()) 782 if (mainResourceLoader())
776 mainResourceLoader()->attachThreadedDataReceiver(threadedDataReceiver); 783 mainResourceLoader()->attachThreadedDataReceiver(threadedDataReceiver);
777 } 784 }
778 785
779 void DocumentLoader::acceptDataFromThreadedReceiver(const char* data, int dataLe ngth, int encodedDataLength) 786 void DocumentLoader::acceptDataFromThreadedReceiver(const char* data, int dataLe ngth, int encodedDataLength)
780 { 787 {
781 m_fetcher->acceptDataFromThreadedReceiver(mainResourceIdentifier(), data, da taLength, encodedDataLength); 788 if (m_fetcher)
789 m_fetcher->acceptDataFromThreadedReceiver(mainResourceIdentifier(), data , dataLength, encodedDataLength);
782 } 790 }
783 791
784 void DocumentLoader::endWriting(DocumentWriter* writer) 792 void DocumentLoader::endWriting(DocumentWriter* writer)
785 { 793 {
786 ASSERT_UNUSED(writer, m_writer == writer); 794 ASSERT_UNUSED(writer, m_writer == writer);
787 m_writer->end(); 795 m_writer->end();
788 m_writer.clear(); 796 m_writer.clear();
789 } 797 }
790 798
791 PassRefPtrWillBeRawPtr<DocumentWriter> DocumentLoader::createWriterFor(const Doc ument* ownerDocument, const DocumentInit& init, const AtomicString& mimeType, co nst AtomicString& encoding, bool dispatch, ParserSynchronizationPolicy parsingPo licy) 799 PassRefPtrWillBeRawPtr<DocumentWriter> DocumentLoader::createWriterFor(const Doc ument* ownerDocument, const DocumentInit& init, const AtomicString& mimeType, co nst AtomicString& encoding, bool dispatch, ParserSynchronizationPolicy parsingPo licy)
(...skipping 27 matching lines...) Expand all
819 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR L() 827 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR L()
820 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn it& init, const String& source, Document* ownerDocument) 828 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn it& init, const String& source, Document* ownerDocument)
821 { 829 {
822 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri ter->encoding() : emptyAtom, true, ForceSynchronousParsing); 830 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri ter->encoding() : emptyAtom, true, ForceSynchronousParsing);
823 if (!source.isNull()) 831 if (!source.isNull())
824 m_writer->appendReplacingData(source); 832 m_writer->appendReplacingData(source);
825 endWriting(m_writer.get()); 833 endWriting(m_writer.get());
826 } 834 }
827 835
828 } // namespace blink 836 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/DocumentLoader.h ('k') | Source/core/loader/FrameFetchContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698