Changeset 145734 in webkit
- Timestamp:
- Mar 13, 2013, 12:11:35 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r145728 r145734 1 2013-03-13 Nate Chapin <japhet@chromium.org> 2 3 Merge MainResourceLoader's didFinishLoading and dataReceived into DocumentLoader 4 https://bugs.webkit.org/show_bug.cgi?id=109952 5 6 Reviewed by Antti Koivisto. 7 8 No new tests, refactor only. 9 10 * loader/DocumentLoader.cpp: 11 (WebCore::DocumentLoader::DocumentLoader): 12 (WebCore::DocumentLoader::finishedLoading): 13 (WebCore::DocumentLoader::responseReceived): 14 (WebCore::DocumentLoader::receivedData): 15 (WebCore::DocumentLoader::maybeLoadEmpty): 16 * loader/DocumentLoader.h: 17 * loader/MainResourceLoader.cpp: 18 (WebCore::MainResourceLoader::responseReceived): Move content filtering to 19 DocumentLoader. 20 (WebCore::MainResourceLoader::dataReceived): Mostly moved to DocumentLoader. 21 (WebCore::MainResourceLoader::didFinishLoading): Mostly moved to DocumentLoader. 22 * loader/MainResourceLoader.h: Expose some variables that haven't been moved 23 to DocumentLoader yet. 24 1 25 2013-03-13 Andrei Bucur <abucur@adobe.com> 2 26 -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r144413 r145734 48 48 #include "Logging.h" 49 49 #include "MainResourceLoader.h" 50 #include "MemoryCache.h" 50 51 #include "Page.h" 51 52 #include "ResourceBuffer.h" … … 64 65 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML) 65 66 #include "ArchiveFactory.h" 67 #endif 68 69 #if USE(CONTENT_FILTERING) 70 #include "ContentFilter.h" 66 71 #endif 67 72 … … 104 109 , m_substituteResourceDeliveryTimer(this, &DocumentLoader::substituteResourceDeliveryTimerFired) 105 110 , m_didCreateGlobalHistoryEntry(false) 111 , m_timeOfLastDataReceived(0.0) 106 112 , m_applicationCacheHost(adoptPtr(new ApplicationCacheHost(this))) 107 113 { … … 298 304 } 299 305 300 void DocumentLoader::finishedLoading() 301 { 306 void DocumentLoader::finishedLoading(double finishTime) 307 { 308 // There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred. 309 // See <rdar://problem/6304600> for more details. 310 #if !USE(CF) 311 ASSERT(!m_frame->page()->defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_frame)); 312 #endif 313 314 if (mainResourceLoader() && mainResourceLoader()->identifierForLoadWithoutResourceLoader()) { 315 frameLoader()->notifier()->dispatchDidFinishLoading(this, mainResourceLoader()->identifier(), finishTime); 316 mainResourceLoader()->clearIdentifierForLoadWithoutResourceLoader(); 317 } 318 319 #if USE(CONTENT_FILTERING) 320 if (m_contentFilter && m_contentFilter->needsMoreData()) { 321 m_contentFilter->finishedAddingData(); 322 int length; 323 const char* data = m_contentFilter->getReplacementData(length); 324 if (data) 325 receivedData(data, length); 326 } 327 #endif 328 329 maybeFinishLoadingMultipartContent(); 330 331 double responseEndTime = finishTime; 332 if (!responseEndTime) 333 responseEndTime = m_timeOfLastDataReceived; 334 if (!responseEndTime) 335 responseEndTime = monotonicallyIncreasingTime(); 336 timing()->setResponseEnd(responseEndTime); 337 302 338 commitIfReady(); 303 339 if (!frameLoader()) … … 318 354 if (!frameLoader()->stateMachine()->creatingInitialEmptyDocument()) 319 355 frameLoader()->checkLoadComplete(); 356 357 // If the document specified an application cache manifest, it violates the author's intent if we store it in the memory cache 358 // and deny the appcache the chance to intercept it in the future, so remove from the memory cache. 359 if (frame() && mainResourceLoader()) { 360 if (mainResourceLoader()->cachedMainResource() && frame()->document()->hasManifest()) 361 memoryCache()->remove(mainResourceLoader()->cachedMainResource()); 362 } 363 m_applicationCacheHost->finishedLoadingMainResource(); 364 } 365 366 void DocumentLoader::responseReceived(const ResourceResponse& response) 367 { 368 setResponse(response); 369 370 #if USE(CONTENT_FILTERING) 371 if (response.url().protocolIs("https") && ContentFilter::isEnabled()) 372 m_contentFilter = ContentFilter::create(response); 373 #endif 374 320 375 } 321 376 … … 413 468 void DocumentLoader::receivedData(const char* data, int length) 414 469 { 470 ASSERT(data); 471 ASSERT(length); 472 ASSERT(!m_response.isNull()); 473 474 #if USE(CFNETWORK) || PLATFORM(MAC) 475 // Workaround for <rdar://problem/6060782> 476 if (m_response.isNull()) 477 setResponse(ResourceResponse(KURL(), "text/html", 0, String(), String())); 478 #endif 479 480 // There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred. 481 // See <rdar://problem/6304600> for more details. 482 #if !USE(CF) 483 ASSERT(!m_frame->page()->defersLoading()); 484 #endif 485 486 #if USE(CONTENT_FILTERING) 487 bool loadWasBlockedBeforeFinishing = false; 488 if (m_contentFilter && m_contentFilter->needsMoreData()) { 489 m_contentFilter->addData(data, length); 490 491 if (m_contentFilter->needsMoreData()) { 492 // Since the filter still needs more data to make a decision, 493 // transition back to the committed state so that we don't partially 494 // load content that might later be blocked. 495 commitLoad(0, 0); 496 return; 497 } 498 499 data = m_contentFilter->getReplacementData(length); 500 loadWasBlockedBeforeFinishing = m_contentFilter->didBlockData(); 501 } 502 #endif 503 504 if (mainResourceLoader()->identifierForLoadWithoutResourceLoader()) 505 frameLoader()->notifier()->dispatchDidReceiveData(this, mainResourceLoader()->identifier(), data, length, -1); 506 507 m_applicationCacheHost->mainResourceDataReceived(data, length, -1, false); 508 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); 509 415 510 if (!isMultipartReplacingLoad()) 416 511 commitLoad(data, length); 512 513 #if USE(CONTENT_FILTERING) 514 if (loadWasBlockedBeforeFinishing) 515 cancelMainResourceLoad(ResourceError()); 516 #endif 417 517 } 418 518 … … 900 1000 String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client()->generatedMIMETypeForURLScheme(m_request.url().protocol()); 901 1001 setResponse(ResourceResponse(m_request.url(), mimeType, 0, String(), String())); 902 finishedLoading( );1002 finishedLoading(monotonicallyIncreasingTime()); 903 1003 return true; 904 1004 } -
trunk/Source/WebCore/loader/DocumentLoader.h
r145592 r145734 57 57 class ArchiveResourceCollection; 58 58 class CachedResourceLoader; 59 class ContentFilter; 59 60 class Frame; 60 61 class FrameLoader; … … 121 122 void receivedData(const char*, int); 122 123 void setupForReplace(); 123 void finishedLoading( );124 void finishedLoading(double finishTime); 124 125 const ResourceResponse& response() const { return m_response; } 125 126 const ResourceError& mainDocumentError() const { return m_mainDocumentError; } … … 244 245 void resetTiming() { m_documentLoadTiming = DocumentLoadTiming(); } 245 246 247 void responseReceived(const ResourceResponse&); 248 246 249 // The WebKit layer calls this function when it's ready for the data to 247 250 // actually be added to the document. … … 354 357 355 358 DocumentLoadTiming m_documentLoadTiming; 359 360 double m_timeOfLastDataReceived; 356 361 357 362 RefPtr<IconLoadDecisionCallback> m_iconLoadDecisionCallback; … … 360 365 friend class ApplicationCacheHost; // for substitute resource delivery 361 366 OwnPtr<ApplicationCacheHost> m_applicationCacheHost; 367 368 #if USE(CONTENT_FILTERING) 369 RefPtr<ContentFilter> m_contentFilter; 370 #endif 362 371 }; 363 372 -
trunk/Source/WebCore/loader/MainResourceLoader.cpp
r144949 r145734 65 65 #endif 66 66 67 #if USE(CONTENT_FILTERING)68 #include "ContentFilter.h"69 #endif70 71 67 namespace WebCore { 72 68 … … 76 72 , m_loadingMultipartContent(false) 77 73 , m_waitingForContentPolicy(false) 78 , m_timeOfLastDataReceived(0.0)79 74 , m_identifierForLoadWithoutResourceLoader(0) 80 75 { … … 439 434 RefPtr<MainResourceLoader> protect(this); 440 435 441 m_documentLoader-> setResponse(r);436 m_documentLoader->responseReceived(r); 442 437 443 438 m_response = r; … … 465 460 #endif 466 461 467 #if USE(CONTENT_FILTERING)468 if (r.url().protocolIs("https") && ContentFilter::isEnabled())469 m_contentFilter = ContentFilter::create(r);470 #endif471 472 462 frameLoader()->policyChecker()->checkContentPolicy(m_response, callContinueAfterContentPolicy, this); 473 463 } … … 475 465 void MainResourceLoader::dataReceived(CachedResource* resource, const char* data, int length) 476 466 { 477 ASSERT(data);478 ASSERT(length != 0);479 467 ASSERT_UNUSED(resource, resource == m_resource); 480 ASSERT(!m_response.isNull());481 482 #if USE(CFNETWORK) || PLATFORM(MAC)483 // Workaround for <rdar://problem/6060782>484 if (m_response.isNull()) {485 m_response = ResourceResponse(KURL(), "text/html", 0, String(), String());486 if (DocumentLoader* documentLoader = m_documentLoader.get())487 documentLoader->setResponse(m_response);488 }489 #endif490 491 // There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred.492 // See <rdar://problem/6304600> for more details.493 #if !USE(CF)494 ASSERT(!defersLoading());495 #endif496 497 #if USE(CONTENT_FILTERING)498 bool loadWasBlockedBeforeFinishing = false;499 if (m_contentFilter && m_contentFilter->needsMoreData()) {500 m_contentFilter->addData(data, length);501 502 if (m_contentFilter->needsMoreData()) {503 // Since the filter still needs more data to make a decision,504 // transition back to the committed state so that we don't partially505 // load content that might later be blocked.506 documentLoader()->receivedData(0, 0);507 return;508 }509 510 data = m_contentFilter->getReplacementData(length);511 loadWasBlockedBeforeFinishing = m_contentFilter->didBlockData();512 }513 #endif514 515 if (m_identifierForLoadWithoutResourceLoader)516 frameLoader()->notifier()->dispatchDidReceiveData(documentLoader(), identifier(), data, length, -1);517 518 documentLoader()->applicationCacheHost()->mainResourceDataReceived(data, length, -1, false);519 520 // The additional processing can do anything including possibly removing the last521 // reference to this object; one example of this is 3266216.522 RefPtr<MainResourceLoader> protect(this);523 524 m_timeOfLastDataReceived = monotonicallyIncreasingTime();525 526 468 documentLoader()->receivedData(data, length); 527 528 #if USE(CONTENT_FILTERING)529 if (loadWasBlockedBeforeFinishing)530 cancel();531 #endif532 469 } 533 470 534 471 void MainResourceLoader::didFinishLoading(double finishTime) 535 472 { 536 // There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred.537 // See <rdar://problem/6304600> for more details.538 #if !USE(CF)539 ASSERT(!defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_documentLoader->frame()));540 #endif541 542 473 // The additional processing can do anything including possibly removing the last 543 474 // reference to this object. 544 475 RefPtr<MainResourceLoader> protect(this); 545 RefPtr<DocumentLoader> dl = documentLoader(); 546 547 if (m_identifierForLoadWithoutResourceLoader) { 548 frameLoader()->notifier()->dispatchDidFinishLoading(documentLoader(), identifier(), finishTime); 549 m_identifierForLoadWithoutResourceLoader = 0; 550 } 551 552 #if USE(CONTENT_FILTERING) 553 if (m_contentFilter && m_contentFilter->needsMoreData()) { 554 m_contentFilter->finishedAddingData(); 555 556 int length; 557 const char* data = m_contentFilter->getReplacementData(length); 558 if (data) 559 dataReceived(m_resource.get(), data, length); 560 } 561 #endif 562 563 if (m_loadingMultipartContent) 564 dl->maybeFinishLoadingMultipartContent(); 565 566 documentLoader()->timing()->setResponseEnd(finishTime ? finishTime : (m_timeOfLastDataReceived ? m_timeOfLastDataReceived : monotonicallyIncreasingTime())); 567 documentLoader()->finishedLoading(); 568 569 // If the document specified an application cache manifest, it violates the author's intent if we store it in the memory cache 570 // and deny the appcache the chance to intercept it in the future, so remove from the memory cache. 571 if (Frame* frame = documentLoader()->frame()) { 572 if (m_resource && frame->document()->hasManifest()) 573 memoryCache()->remove(m_resource.get()); 574 } 575 576 dl->applicationCacheHost()->finishedLoadingMainResource(); 476 documentLoader()->finishedLoading(finishTime); 577 477 } 578 478 -
trunk/Source/WebCore/loader/MainResourceLoader.h
r145592 r145734 47 47 class FormState; 48 48 class ResourceRequest; 49 50 #if USE(CONTENT_FILTERING)51 class ContentFilter;52 #endif53 49 54 50 class MainResourceLoader : public RefCounted<MainResourceLoader>, public CachedRawResourceClient { … … 72 68 typedef Timer<MainResourceLoader> MainResourceLoaderTimer; 73 69 #endif 70 71 CachedRawResource* cachedMainResource() { return m_resource.get(); } 72 unsigned long identifierForLoadWithoutResourceLoader() const { return m_identifierForLoadWithoutResourceLoader; } 73 void clearIdentifierForLoadWithoutResourceLoader() { m_identifierForLoadWithoutResourceLoader = 0; } 74 74 75 75 unsigned long identifier() const; … … 128 128 bool m_loadingMultipartContent; 129 129 bool m_waitingForContentPolicy; 130 double m_timeOfLastDataReceived;131 130 unsigned long m_identifierForLoadWithoutResourceLoader; 132 133 #if USE(CONTENT_FILTERING)134 RefPtr<ContentFilter> m_contentFilter;135 #endif136 131 }; 137 132
Note:
See TracChangeset
for help on using the changeset viewer.