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

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

Issue 16848005: Remove support for multipart/x-mixed-replace (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 , m_cachedResourceLoader(CachedResourceLoader::create(this)) 93 , m_cachedResourceLoader(CachedResourceLoader::create(this))
94 , m_writer(m_frame) 94 , m_writer(m_frame)
95 , m_originalRequest(req) 95 , m_originalRequest(req)
96 , m_substituteData(substituteData) 96 , m_substituteData(substituteData)
97 , m_originalRequestCopy(req) 97 , m_originalRequestCopy(req)
98 , m_request(req) 98 , m_request(req)
99 , m_committed(false) 99 , m_committed(false)
100 , m_isStopping(false) 100 , m_isStopping(false)
101 , m_gotFirstByte(false) 101 , m_gotFirstByte(false)
102 , m_isClientRedirect(false) 102 , m_isClientRedirect(false)
103 , m_isLoadingMultipartContent(false)
104 , m_wasOnloadHandled(false) 103 , m_wasOnloadHandled(false)
105 , m_loadingMainResource(false) 104 , m_loadingMainResource(false)
106 , m_timeOfLastDataReceived(0.0) 105 , m_timeOfLastDataReceived(0.0)
107 , m_identifierForLoadWithoutResourceLoader(0) 106 , m_identifierForLoadWithoutResourceLoader(0)
108 , m_dataLoadTimer(this, &DocumentLoader::handleSubstituteDataLoadNow) 107 , m_dataLoadTimer(this, &DocumentLoader::handleSubstituteDataLoadNow)
109 , m_applicationCacheHost(adoptPtr(new ApplicationCacheHost(this))) 108 , m_applicationCacheHost(adoptPtr(new ApplicationCacheHost(this)))
110 { 109 {
111 } 110 }
112 111
113 FrameLoader* DocumentLoader::frameLoader() const 112 FrameLoader* DocumentLoader::frameLoader() const
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 { 323 {
325 ASSERT(!m_frame->page()->defersLoading() || InspectorInstrumentation::isDebu ggerPaused(m_frame)); 324 ASSERT(!m_frame->page()->defersLoading() || InspectorInstrumentation::isDebu ggerPaused(m_frame));
326 325
327 RefPtr<DocumentLoader> protect(this); 326 RefPtr<DocumentLoader> protect(this);
328 327
329 if (m_identifierForLoadWithoutResourceLoader) { 328 if (m_identifierForLoadWithoutResourceLoader) {
330 frameLoader()->notifier()->dispatchDidFinishLoading(this, m_identifierFo rLoadWithoutResourceLoader, finishTime); 329 frameLoader()->notifier()->dispatchDidFinishLoading(this, m_identifierFo rLoadWithoutResourceLoader, finishTime);
331 m_identifierForLoadWithoutResourceLoader = 0; 330 m_identifierForLoadWithoutResourceLoader = 0;
332 } 331 }
333 332
334 maybeFinishLoadingMultipartContent();
335
336 double responseEndTime = finishTime; 333 double responseEndTime = finishTime;
337 if (!responseEndTime) 334 if (!responseEndTime)
338 responseEndTime = m_timeOfLastDataReceived; 335 responseEndTime = m_timeOfLastDataReceived;
339 if (!responseEndTime) 336 if (!responseEndTime)
340 responseEndTime = monotonicallyIncreasingTime(); 337 responseEndTime = monotonicallyIncreasingTime();
341 timing()->setResponseEnd(responseEndTime); 338 timing()->setResponseEnd(responseEndTime);
342 339
343 commitIfReady(); 340 commitIfReady();
344 if (!frameLoader()) 341 if (!frameLoader())
345 return; 342 return;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 554
558 // The load event might have detached this frame. In that case, the load will already have been cancelled during detach. 555 // The load event might have detached this frame. In that case, the load will already have been cancelled during detach.
559 if (frameLoader()) 556 if (frameLoader())
560 cancelMainResourceLoad(frameLoader()->cancelledError(m_request)) ; 557 cancelMainResourceLoad(frameLoader()->cancelledError(m_request)) ;
561 return; 558 return;
562 } 559 }
563 } 560 }
564 561
565 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); 562 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading());
566 563
567 if (m_isLoadingMultipartContent) {
568 setupForReplace();
569 m_mainResource->clear();
570 } else if (response.isMultipart()) {
571 UseCounter::count(m_frame->document(), UseCounter::MultipartMainResource );
572 m_isLoadingMultipartContent = true;
573 }
574
575 m_response = response; 564 m_response = response;
576 565
577 if (m_identifierForLoadWithoutResourceLoader) 566 if (m_identifierForLoadWithoutResourceLoader)
578 frameLoader()->notifier()->dispatchDidReceiveResponse(this, m_identifier ForLoadWithoutResourceLoader, m_response, 0); 567 frameLoader()->notifier()->dispatchDidReceiveResponse(this, m_identifier ForLoadWithoutResourceLoader, m_response, 0);
579 568
580 if (!shouldContinueForResponse()) { 569 if (!shouldContinueForResponse()) {
581 InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, m_main Resource->identifier(), m_response); 570 InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, m_main Resource->identifier(), m_response);
582 stopLoadingForPolicyChange(); 571 stopLoadingForPolicyChange();
583 return; 572 return;
584 } 573 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 m_writer.setDocumentWasLoadedAsPartOfNavigation(); 635 m_writer.setDocumentWasLoadedAsPartOfNavigation();
647 636
648 if (frameLoader()->stateMachine()->creatingInitialEmptyDocument()) 637 if (frameLoader()->stateMachine()->creatingInitialEmptyDocument())
649 return; 638 return;
650 639
651 // The origin is the MHTML file, we need to set the base URL to the docu ment encoded in the MHTML so 640 // The origin is the MHTML file, we need to set the base URL to the docu ment encoded in the MHTML so
652 // relative URLs are resolved properly. 641 // relative URLs are resolved properly.
653 if (m_archive) 642 if (m_archive)
654 m_frame->document()->setBaseURLOverride(m_archive->mainResource()->u rl()); 643 m_frame->document()->setBaseURLOverride(m_archive->mainResource()->u rl());
655 644
656 // Call receivedFirstData() exactly once per load. We should only reach this point multiple times 645 // Call receivedFirstData() exactly once per load.
657 // for multipart loads, and FrameLoader::isReplacing() will be true afte r the first time. 646 frameLoader()->receivedFirstData();
658 if (!isMultipartReplacingLoad())
659 frameLoader()->receivedFirstData();
660 647
661 bool userChosen = true; 648 bool userChosen = true;
662 String encoding = overrideEncoding(); 649 String encoding = overrideEncoding();
663 if (encoding.isNull()) { 650 if (encoding.isNull()) {
664 userChosen = false; 651 userChosen = false;
665 encoding = response().textEncodingName(); 652 encoding = response().textEncodingName();
666 } 653 }
667 m_writer.setEncoding(encoding, userChosen); 654 m_writer.setEncoding(encoding, userChosen);
668 } 655 }
669 ASSERT(m_frame->document()->parsing()); 656 ASSERT(m_frame->document()->parsing());
(...skipping 27 matching lines...) Expand all
697 ASSERT_UNUSED(resource, resource == m_mainResource); 684 ASSERT_UNUSED(resource, resource == m_mainResource);
698 ASSERT(!m_response.isNull()); 685 ASSERT(!m_response.isNull());
699 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); 686 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading());
700 687
701 if (m_identifierForLoadWithoutResourceLoader) 688 if (m_identifierForLoadWithoutResourceLoader)
702 frameLoader()->notifier()->dispatchDidReceiveData(this, m_identifierForL oadWithoutResourceLoader, data, length, -1); 689 frameLoader()->notifier()->dispatchDidReceiveData(this, m_identifierForL oadWithoutResourceLoader, data, length, -1);
703 690
704 m_applicationCacheHost->mainResourceDataReceived(data, length); 691 m_applicationCacheHost->mainResourceDataReceived(data, length);
705 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); 692 m_timeOfLastDataReceived = monotonicallyIncreasingTime();
706 693
707 if (!isMultipartReplacingLoad()) 694 commitLoad(data, length);
708 commitLoad(data, length);
709 }
710
711 void DocumentLoader::setupForReplace()
712 {
713 if (!mainResourceData())
714 return;
715
716 maybeFinishLoadingMultipartContent();
717 maybeCreateArchive();
718 m_writer.end();
719 frameLoader()->setReplacing();
720 m_gotFirstByte = false;
721
722 stopLoadingSubresources();
723 clearArchiveResources();
724 } 695 }
725 696
726 void DocumentLoader::checkLoadComplete() 697 void DocumentLoader::checkLoadComplete()
727 { 698 {
728 if (!m_frame || isLoading()) 699 if (!m_frame || isLoading())
729 return; 700 return;
730 // FIXME: This ASSERT is always triggered. 701 // FIXME: This ASSERT is always triggered.
731 // See https://bugs.webkit.org/show_bug.cgi?id=110937 702 // See https://bugs.webkit.org/show_bug.cgi?id=110937
732 // ASSERT(this == frameLoader()->activeDocumentLoader()) 703 // ASSERT(this == frameLoader()->activeDocumentLoader())
733 m_frame->document()->domWindow()->finishedLoading(); 704 m_frame->document()->domWindow()->finishedLoading();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 void DocumentLoader::removeResourceLoader(ResourceLoader* loader) 909 void DocumentLoader::removeResourceLoader(ResourceLoader* loader)
939 { 910 {
940 if (!m_resourceLoaders.contains(loader)) 911 if (!m_resourceLoaders.contains(loader))
941 return; 912 return;
942 m_resourceLoaders.remove(loader); 913 m_resourceLoaders.remove(loader);
943 checkLoadComplete(); 914 checkLoadComplete();
944 if (Frame* frame = m_frame) 915 if (Frame* frame = m_frame)
945 frame->loader()->checkLoadComplete(); 916 frame->loader()->checkLoadComplete();
946 } 917 }
947 918
948 bool DocumentLoader::isMultipartReplacingLoad() const
949 {
950 return isLoadingMultipartContent() && frameLoader()->isReplacing();
951 }
952
953 bool DocumentLoader::maybeLoadEmpty() 919 bool DocumentLoader::maybeLoadEmpty()
954 { 920 {
955 bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmp ty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().proto col())); 921 bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmp ty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().proto col()));
956 if (!shouldLoadEmpty) 922 if (!shouldLoadEmpty)
957 return false; 923 return false;
958 924
959 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument()) 925 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument())
960 m_request.setURL(blankURL()); 926 m_request.setURL(blankURL());
961 String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client()->g eneratedMIMETypeForURLScheme(m_request.url().protocol()); 927 String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client()->g eneratedMIMETypeForURLScheme(m_request.url().protocol());
962 m_response = ResourceResponse(m_request.url(), mimeType, 0, String(), String ()); 928 m_response = ResourceResponse(m_request.url(), mimeType, 0, String(), String ());
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 1000
1035 void DocumentLoader::subresourceLoaderFinishedLoadingOnePart(ResourceLoader* loa der) 1001 void DocumentLoader::subresourceLoaderFinishedLoadingOnePart(ResourceLoader* loa der)
1036 { 1002 {
1037 m_multipartResourceLoaders.add(loader); 1003 m_multipartResourceLoaders.add(loader);
1038 m_resourceLoaders.remove(loader); 1004 m_resourceLoaders.remove(loader);
1039 checkLoadComplete(); 1005 checkLoadComplete();
1040 if (Frame* frame = m_frame) 1006 if (Frame* frame = m_frame)
1041 frame->loader()->checkLoadComplete(); 1007 frame->loader()->checkLoadComplete();
1042 } 1008 }
1043 1009
1044 void DocumentLoader::maybeFinishLoadingMultipartContent()
1045 {
1046 if (!isMultipartReplacingLoad())
1047 return;
1048
1049 frameLoader()->setupForReplace();
1050 m_committed = false;
1051 RefPtr<SharedBuffer> resourceData = mainResourceData();
1052 commitLoad(resourceData->data(), resourceData->size());
1053 }
1054
1055 void DocumentLoader::handledOnloadEvents() 1010 void DocumentLoader::handledOnloadEvents()
1056 { 1011 {
1057 m_wasOnloadHandled = true; 1012 m_wasOnloadHandled = true;
1058 applicationCacheHost()->stopDeferringEvents(); 1013 applicationCacheHost()->stopDeferringEvents();
1059 } 1014 }
1060 1015
1061 } // namespace WebCore 1016 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698