| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 m_replacesCurrentHistoryItem(false), | 110 m_replacesCurrentHistoryItem(false), |
| 111 m_dataReceived(false), | 111 m_dataReceived(false), |
| 112 m_navigationType(NavigationTypeOther), | 112 m_navigationType(NavigationTypeOther), |
| 113 m_documentLoadTiming(*this), | 113 m_documentLoadTiming(*this), |
| 114 m_timeOfLastDataReceived(0.0), | 114 m_timeOfLastDataReceived(0.0), |
| 115 m_applicationCacheHost(ApplicationCacheHost::create(this)), | 115 m_applicationCacheHost(ApplicationCacheHost::create(this)), |
| 116 m_wasBlockedAfterCSP(false), | 116 m_wasBlockedAfterCSP(false), |
| 117 m_state(NotStarted), | 117 m_state(NotStarted), |
| 118 m_inDataReceived(false), | 118 m_inDataReceived(false), |
| 119 m_dataBuffer(SharedBuffer::create()) { | 119 m_dataBuffer(SharedBuffer::create()) { |
| 120 DCHECK(m_frame); |
| 121 |
| 120 // The document URL needs to be added to the head of the list as that is | 122 // The document URL needs to be added to the head of the list as that is |
| 121 // where the redirects originated. | 123 // where the redirects originated. |
| 122 if (m_isClientRedirect) | 124 if (m_isClientRedirect) |
| 123 appendRedirect(m_frame->document()->url()); | 125 appendRedirect(m_frame->document()->url()); |
| 124 } | 126 } |
| 125 | 127 |
| 126 FrameLoader* DocumentLoader::frameLoader() const { | 128 FrameLoader& DocumentLoader::frameLoader() const { |
| 127 if (!m_frame) | 129 DCHECK(m_frame); |
| 128 return nullptr; | 130 return m_frame->loader(); |
| 129 return &m_frame->loader(); | 131 } |
| 132 |
| 133 FrameLoaderClient& DocumentLoader::frameLoaderClient() const { |
| 134 DCHECK(m_frame); |
| 135 FrameLoaderClient* client = m_frame->client(); |
| 136 // LocalFrame clears its |m_client| only after detaching all DocumentLoaders |
| 137 // (i.e. calls detachFromFrame() which clears |m_frame|) owned by the |
| 138 // LocalFrame's FrameLoader. So, if |m_frame| is non nullptr, |client| is |
| 139 // also non nullptr. |
| 140 DCHECK(client); |
| 141 return *client; |
| 130 } | 142 } |
| 131 | 143 |
| 132 DocumentLoader::~DocumentLoader() { | 144 DocumentLoader::~DocumentLoader() { |
| 133 DCHECK(!m_frame); | 145 DCHECK(!m_frame); |
| 134 DCHECK(!m_mainResource); | 146 DCHECK(!m_mainResource); |
| 135 DCHECK(!m_applicationCacheHost); | 147 DCHECK(!m_applicationCacheHost); |
| 136 DCHECK_EQ(m_state, SentDidFinishLoad); | 148 DCHECK_EQ(m_state, SentDidFinishLoad); |
| 137 } | 149 } |
| 138 | 150 |
| 139 DEFINE_TRACE(DocumentLoader) { | 151 DEFINE_TRACE(DocumentLoader) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 fetcher()->preloadStarted(resource); | 227 fetcher()->preloadStarted(resource); |
| 216 return resource; | 228 return resource; |
| 217 } | 229 } |
| 218 | 230 |
| 219 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) { | 231 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) { |
| 220 timing().addRedirect(oldURL, newURL); | 232 timing().addRedirect(oldURL, newURL); |
| 221 | 233 |
| 222 // If a redirection happens during a back/forward navigation, don't restore | 234 // If a redirection happens during a back/forward navigation, don't restore |
| 223 // any state from the old HistoryItem. There is a provisional history item for | 235 // any state from the old HistoryItem. There is a provisional history item for |
| 224 // back/forward navigation only. In the other case, clearing it is a no-op. | 236 // back/forward navigation only. In the other case, clearing it is a no-op. |
| 225 DCHECK(frameLoader()); | 237 frameLoader().clearProvisionalHistoryItem(); |
| 226 frameLoader()->clearProvisionalHistoryItem(); | |
| 227 } | 238 } |
| 228 | 239 |
| 229 void DocumentLoader::dispatchLinkHeaderPreloads( | 240 void DocumentLoader::dispatchLinkHeaderPreloads( |
| 230 ViewportDescriptionWrapper* viewport, | 241 ViewportDescriptionWrapper* viewport, |
| 231 LinkLoader::MediaPreloadPolicy mediaPolicy) { | 242 LinkLoader::MediaPreloadPolicy mediaPolicy) { |
| 232 LinkLoader::loadLinksFromHeader( | 243 LinkLoader::loadLinksFromHeader( |
| 233 response().httpHeaderField(HTTPNames::Link), response().url(), | 244 response().httpHeaderField(HTTPNames::Link), response().url(), |
| 234 m_frame->document(), NetworkHintsInterfaceImpl(), | 245 m_frame->document(), NetworkHintsInterfaceImpl(), |
| 235 LinkLoader::OnlyLoadResources, mediaPolicy, viewport); | 246 LinkLoader::OnlyLoadResources, mediaPolicy, viewport); |
| 236 } | 247 } |
| 237 | 248 |
| 238 void DocumentLoader::didChangePerformanceTiming() { | 249 void DocumentLoader::didChangePerformanceTiming() { |
| 239 if (frame() && frame()->isMainFrame() && m_state >= Committed) { | 250 if (m_frame && m_frame->isMainFrame() && m_state >= Committed) { |
| 240 frameLoader()->client()->didChangePerformanceTiming(); | 251 frameLoaderClient().didChangePerformanceTiming(); |
| 241 } | 252 } |
| 242 } | 253 } |
| 243 | 254 |
| 244 void DocumentLoader::didObserveLoadingBehavior( | 255 void DocumentLoader::didObserveLoadingBehavior( |
| 245 WebLoadingBehaviorFlag behavior) { | 256 WebLoadingBehaviorFlag behavior) { |
| 246 if (frame() && frame()->isMainFrame()) { | 257 if (m_frame && m_frame->isMainFrame()) { |
| 247 DCHECK_GE(m_state, Committed); | 258 DCHECK_GE(m_state, Committed); |
| 248 frameLoader()->client()->didObserveLoadingBehavior(behavior); | 259 frameLoaderClient().didObserveLoadingBehavior(behavior); |
| 249 } | 260 } |
| 250 } | 261 } |
| 251 | 262 |
| 252 void DocumentLoader::updateForSameDocumentNavigation( | 263 void DocumentLoader::updateForSameDocumentNavigation( |
| 253 const KURL& newURL, | 264 const KURL& newURL, |
| 254 SameDocumentNavigationSource sameDocumentNavigationSource) { | 265 SameDocumentNavigationSource sameDocumentNavigationSource) { |
| 255 KURL oldURL = m_request.url(); | 266 KURL oldURL = m_request.url(); |
| 256 m_originalRequest.setURL(newURL); | 267 m_originalRequest.setURL(newURL); |
| 257 m_request.setURL(newURL); | 268 m_request.setURL(newURL); |
| 258 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { | 269 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { |
| 259 m_request.setHTTPMethod(HTTPNames::GET); | 270 m_request.setHTTPMethod(HTTPNames::GET); |
| 260 m_request.setHTTPBody(nullptr); | 271 m_request.setHTTPBody(nullptr); |
| 261 } | 272 } |
| 262 clearRedirectChain(); | 273 clearRedirectChain(); |
| 263 if (m_isClientRedirect) | 274 if (m_isClientRedirect) |
| 264 appendRedirect(oldURL); | 275 appendRedirect(oldURL); |
| 265 appendRedirect(newURL); | 276 appendRedirect(newURL); |
| 266 } | 277 } |
| 267 | 278 |
| 268 const KURL& DocumentLoader::urlForHistory() const { | 279 const KURL& DocumentLoader::urlForHistory() const { |
| 269 return unreachableURL().isEmpty() ? url() : unreachableURL(); | 280 return unreachableURL().isEmpty() ? url() : unreachableURL(); |
| 270 } | 281 } |
| 271 | 282 |
| 272 void DocumentLoader::commitIfReady() { | 283 void DocumentLoader::commitIfReady() { |
| 273 if (m_state < Committed) { | 284 if (m_state < Committed) { |
| 274 m_state = Committed; | 285 m_state = Committed; |
| 275 frameLoader()->commitProvisionalLoad(); | 286 frameLoader().commitProvisionalLoad(); |
| 276 } | 287 } |
| 277 } | 288 } |
| 278 | 289 |
| 279 void DocumentLoader::notifyFinished(Resource* resource) { | 290 void DocumentLoader::notifyFinished(Resource* resource) { |
| 280 DCHECK_EQ(m_mainResource, resource); | 291 DCHECK_EQ(m_mainResource, resource); |
| 281 DCHECK(m_mainResource); | 292 DCHECK(m_mainResource); |
| 282 | 293 |
| 283 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { | 294 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { |
| 284 finishedLoading(m_mainResource->loadFinishTime()); | 295 finishedLoading(m_mainResource->loadFinishTime()); |
| 285 return; | 296 return; |
| 286 } | 297 } |
| 287 | 298 |
| 288 if (m_applicationCacheHost) | 299 if (m_applicationCacheHost) |
| 289 m_applicationCacheHost->failedLoadingMainResource(); | 300 m_applicationCacheHost->failedLoadingMainResource(); |
| 290 | 301 |
| 291 if (m_mainResource->resourceError().wasBlockedByResponse()) { | 302 if (m_mainResource->resourceError().wasBlockedByResponse()) { |
| 292 InspectorInstrumentation::canceledAfterReceivedResourceResponse( | 303 InspectorInstrumentation::canceledAfterReceivedResourceResponse( |
| 293 m_frame, this, mainResourceIdentifier(), resource->response(), | 304 m_frame, this, mainResourceIdentifier(), resource->response(), |
| 294 m_mainResource.get()); | 305 m_mainResource.get()); |
| 295 } | 306 } |
| 296 | 307 |
| 297 frameLoader()->loadFailed(this, m_mainResource->resourceError()); | 308 frameLoader().loadFailed(this, m_mainResource->resourceError()); |
| 298 clearMainResourceHandle(); | 309 clearMainResourceHandle(); |
| 299 } | 310 } |
| 300 | 311 |
| 301 void DocumentLoader::finishedLoading(double finishTime) { | 312 void DocumentLoader::finishedLoading(double finishTime) { |
| 302 DCHECK(m_frame->loader().stateMachine()->creatingInitialEmptyDocument() || | 313 DCHECK(m_frame->loader().stateMachine()->creatingInitialEmptyDocument() || |
| 303 !m_frame->page()->suspended() || | 314 !m_frame->page()->suspended() || |
| 304 InspectorInstrumentation::isDebuggerPaused(m_frame)); | 315 InspectorInstrumentation::isDebuggerPaused(m_frame)); |
| 305 | 316 |
| 306 double responseEndTime = finishTime; | 317 double responseEndTime = finishTime; |
| 307 if (!responseEndTime) | 318 if (!responseEndTime) |
| 308 responseEndTime = m_timeOfLastDataReceived; | 319 responseEndTime = m_timeOfLastDataReceived; |
| 309 if (!responseEndTime) | 320 if (!responseEndTime) |
| 310 responseEndTime = monotonicallyIncreasingTime(); | 321 responseEndTime = monotonicallyIncreasingTime(); |
| 311 timing().setResponseEnd(responseEndTime); | 322 timing().setResponseEnd(responseEndTime); |
| 312 | 323 |
| 313 commitIfReady(); | 324 commitIfReady(); |
| 314 if (!frameLoader()) | 325 if (!m_frame) |
| 315 return; | 326 return; |
| 316 | 327 |
| 317 if (!maybeCreateArchive()) { | 328 if (!maybeCreateArchive()) { |
| 318 // If this is an empty document, it will not have actually been created yet. | 329 // If this is an empty document, it will not have actually been created yet. |
| 319 // Commit dummy data so that DocumentWriter::begin() gets called and creates | 330 // Commit dummy data so that DocumentWriter::begin() gets called and creates |
| 320 // the Document. | 331 // the Document. |
| 321 if (!m_writer) | 332 if (!m_writer) |
| 322 commitData(0, 0); | 333 commitData(0, 0); |
| 323 } | 334 } |
| 324 | 335 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 340 m_frame, | 351 m_frame, |
| 341 UseCounter:: | 352 UseCounter:: |
| 342 ServiceWorkerRespondToNavigationRequestWithRedirectedResponse); | 353 ServiceWorkerRespondToNavigationRequestWithRedirectedResponse); |
| 343 } | 354 } |
| 344 } | 355 } |
| 345 | 356 |
| 346 bool DocumentLoader::redirectReceived( | 357 bool DocumentLoader::redirectReceived( |
| 347 Resource* resource, | 358 Resource* resource, |
| 348 const ResourceRequest& request, | 359 const ResourceRequest& request, |
| 349 const ResourceResponse& redirectResponse) { | 360 const ResourceResponse& redirectResponse) { |
| 361 DCHECK(m_frame); |
| 350 DCHECK_EQ(resource, m_mainResource); | 362 DCHECK_EQ(resource, m_mainResource); |
| 351 DCHECK(!redirectResponse.isNull()); | 363 DCHECK(!redirectResponse.isNull()); |
| 352 m_request = request; | 364 m_request = request; |
| 353 | 365 |
| 354 // If the redirecting url is not allowed to display content from the target | 366 // If the redirecting url is not allowed to display content from the target |
| 355 // origin, then block the redirect. | 367 // origin, then block the redirect. |
| 356 const KURL& requestURL = m_request.url(); | 368 const KURL& requestURL = m_request.url(); |
| 357 RefPtr<SecurityOrigin> redirectingOrigin = | 369 RefPtr<SecurityOrigin> redirectingOrigin = |
| 358 SecurityOrigin::create(redirectResponse.url()); | 370 SecurityOrigin::create(redirectResponse.url()); |
| 359 if (!redirectingOrigin->canDisplay(requestURL)) { | 371 if (!redirectingOrigin->canDisplay(requestURL)) { |
| 360 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString()); | 372 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString()); |
| 361 m_fetcher->stopFetching(); | 373 m_fetcher->stopFetching(); |
| 362 return false; | 374 return false; |
| 363 } | 375 } |
| 364 if (!frameLoader()->shouldContinueForNavigationPolicy( | 376 if (!frameLoader().shouldContinueForNavigationPolicy( |
| 365 m_request, SubstituteData(), this, CheckContentSecurityPolicy, | 377 m_request, SubstituteData(), this, CheckContentSecurityPolicy, |
| 366 m_navigationType, NavigationPolicyCurrentTab, | 378 m_navigationType, NavigationPolicyCurrentTab, |
| 367 replacesCurrentHistoryItem(), isClientRedirect(), nullptr)) { | 379 replacesCurrentHistoryItem(), isClientRedirect(), nullptr)) { |
| 368 m_fetcher->stopFetching(); | 380 m_fetcher->stopFetching(); |
| 369 return false; | 381 return false; |
| 370 } | 382 } |
| 371 | 383 |
| 372 DCHECK(timing().fetchStart()); | 384 DCHECK(timing().fetchStart()); |
| 373 appendRedirect(requestURL); | 385 appendRedirect(requestURL); |
| 374 didRedirect(redirectResponse.url(), requestURL); | 386 didRedirect(redirectResponse.url(), requestURL); |
| 375 frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad(); | 387 frameLoaderClient().dispatchDidReceiveServerRedirectForProvisionalLoad(); |
| 376 | 388 |
| 377 return true; | 389 return true; |
| 378 } | 390 } |
| 379 | 391 |
| 380 static bool canShowMIMEType(const String& mimeType, LocalFrame* frame) { | 392 static bool canShowMIMEType(const String& mimeType, LocalFrame* frame) { |
| 381 if (MIMETypeRegistry::isSupportedMIMEType(mimeType)) | 393 if (MIMETypeRegistry::isSupportedMIMEType(mimeType)) |
| 382 return true; | 394 return true; |
| 383 PluginData* pluginData = frame->pluginData(); | 395 PluginData* pluginData = frame->pluginData(); |
| 384 return !mimeType.isEmpty() && pluginData && | 396 return !mimeType.isEmpty() && pluginData && |
| 385 pluginData->supportsMimeType(mimeType); | 397 pluginData->supportsMimeType(mimeType); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 444 |
| 433 return; | 445 return; |
| 434 } | 446 } |
| 435 | 447 |
| 436 void DocumentLoader::responseReceived( | 448 void DocumentLoader::responseReceived( |
| 437 Resource* resource, | 449 Resource* resource, |
| 438 const ResourceResponse& response, | 450 const ResourceResponse& response, |
| 439 std::unique_ptr<WebDataConsumerHandle> handle) { | 451 std::unique_ptr<WebDataConsumerHandle> handle) { |
| 440 DCHECK_EQ(m_mainResource, resource); | 452 DCHECK_EQ(m_mainResource, resource); |
| 441 DCHECK(!handle); | 453 DCHECK(!handle); |
| 442 DCHECK(frame()); | 454 DCHECK(m_frame); |
| 443 | 455 |
| 444 m_applicationCacheHost->didReceiveResponseForMainResource(response); | 456 m_applicationCacheHost->didReceiveResponseForMainResource(response); |
| 445 | 457 |
| 446 // The memory cache doesn't understand the application cache or its caching | 458 // The memory cache doesn't understand the application cache or its caching |
| 447 // rules. So if a main resource is served from the application cache, ensure | 459 // rules. So if a main resource is served from the application cache, ensure |
| 448 // we don't save the result for future use. All responses loaded from appcache | 460 // we don't save the result for future use. All responses loaded from appcache |
| 449 // will have a non-zero appCacheID(). | 461 // will have a non-zero appCacheID(). |
| 450 if (response.appCacheID()) | 462 if (response.appCacheID()) |
| 451 memoryCache()->remove(m_mainResource.get()); | 463 memoryCache()->remove(m_mainResource.get()); |
| 452 | 464 |
| 453 m_contentSecurityPolicy = ContentSecurityPolicy::create(); | 465 m_contentSecurityPolicy = ContentSecurityPolicy::create(); |
| 454 m_contentSecurityPolicy->setOverrideURLForSelf(response.url()); | 466 m_contentSecurityPolicy->setOverrideURLForSelf(response.url()); |
| 455 m_contentSecurityPolicy->didReceiveHeaders( | 467 m_contentSecurityPolicy->didReceiveHeaders( |
| 456 ContentSecurityPolicyResponseHeaders(response)); | 468 ContentSecurityPolicyResponseHeaders(response)); |
| 457 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) { | 469 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) { |
| 458 cancelLoadAfterCSPDenied(response); | 470 cancelLoadAfterCSPDenied(response); |
| 459 return; | 471 return; |
| 460 } | 472 } |
| 461 | 473 |
| 462 if (RuntimeEnabledFeatures::embedderCSPEnforcementEnabled() && | 474 if (RuntimeEnabledFeatures::embedderCSPEnforcementEnabled() && |
| 463 !frameLoader()->requiredCSP().isEmpty()) { | 475 !frameLoader().requiredCSP().isEmpty()) { |
| 464 SecurityOrigin* parentSecurityOrigin = | 476 SecurityOrigin* parentSecurityOrigin = |
| 465 frame()->tree().parent()->securityContext()->getSecurityOrigin(); | 477 m_frame->tree().parent()->securityContext()->getSecurityOrigin(); |
| 466 if (ContentSecurityPolicy::shouldEnforceEmbeddersPolicy( | 478 if (ContentSecurityPolicy::shouldEnforceEmbeddersPolicy( |
| 467 response, parentSecurityOrigin)) { | 479 response, parentSecurityOrigin)) { |
| 468 m_contentSecurityPolicy->addPolicyFromHeaderValue( | 480 m_contentSecurityPolicy->addPolicyFromHeaderValue( |
| 469 frameLoader()->requiredCSP(), ContentSecurityPolicyHeaderTypeEnforce, | 481 frameLoader().requiredCSP(), ContentSecurityPolicyHeaderTypeEnforce, |
| 470 ContentSecurityPolicyHeaderSourceHTTP); | 482 ContentSecurityPolicyHeaderSourceHTTP); |
| 471 } else { | 483 } else { |
| 472 ContentSecurityPolicy* embeddingCSP = ContentSecurityPolicy::create(); | 484 ContentSecurityPolicy* embeddingCSP = ContentSecurityPolicy::create(); |
| 473 embeddingCSP->addPolicyFromHeaderValue( | 485 embeddingCSP->addPolicyFromHeaderValue( |
| 474 frameLoader()->requiredCSP(), ContentSecurityPolicyHeaderTypeEnforce, | 486 frameLoader().requiredCSP(), ContentSecurityPolicyHeaderTypeEnforce, |
| 475 ContentSecurityPolicyHeaderSourceHTTP); | 487 ContentSecurityPolicyHeaderSourceHTTP); |
| 476 if (!embeddingCSP->subsumes(*m_contentSecurityPolicy)) { | 488 if (!embeddingCSP->subsumes(*m_contentSecurityPolicy)) { |
| 477 String message = "Refused to display '" + | 489 String message = "Refused to display '" + |
| 478 response.url().elidedString() + | 490 response.url().elidedString() + |
| 479 "' because it has not opted-into the following policy " | 491 "' because it has not opted-into the following policy " |
| 480 "required by its embedder: '" + | 492 "required by its embedder: '" + |
| 481 frameLoader()->requiredCSP() + "'."; | 493 frameLoader().requiredCSP() + "'."; |
| 482 ConsoleMessage* consoleMessage = ConsoleMessage::createForRequest( | 494 ConsoleMessage* consoleMessage = ConsoleMessage::createForRequest( |
| 483 SecurityMessageSource, ErrorMessageLevel, message, response.url(), | 495 SecurityMessageSource, ErrorMessageLevel, message, response.url(), |
| 484 mainResourceIdentifier()); | 496 mainResourceIdentifier()); |
| 485 frame()->document()->addConsoleMessage(consoleMessage); | 497 m_frame->document()->addConsoleMessage(consoleMessage); |
| 486 cancelLoadAfterCSPDenied(response); | 498 cancelLoadAfterCSPDenied(response); |
| 487 return; | 499 return; |
| 488 } | 500 } |
| 489 } | 501 } |
| 490 } | 502 } |
| 491 | 503 |
| 492 DCHECK(!m_frame->page()->suspended()); | 504 DCHECK(!m_frame->page()->suspended()); |
| 493 | 505 |
| 494 m_response = response; | 506 m_response = response; |
| 495 | 507 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 m_dataBuffer->clear(); | 610 m_dataBuffer->clear(); |
| 599 } | 611 } |
| 600 | 612 |
| 601 void DocumentLoader::processData(const char* data, size_t length) { | 613 void DocumentLoader::processData(const char* data, size_t length) { |
| 602 m_applicationCacheHost->mainResourceDataReceived(data, length); | 614 m_applicationCacheHost->mainResourceDataReceived(data, length); |
| 603 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); | 615 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); |
| 604 | 616 |
| 605 if (isArchiveMIMEType(response().mimeType())) | 617 if (isArchiveMIMEType(response().mimeType())) |
| 606 return; | 618 return; |
| 607 commitIfReady(); | 619 commitIfReady(); |
| 608 if (!frameLoader()) | 620 if (!m_frame) |
| 609 return; | 621 return; |
| 610 commitData(data, length); | 622 commitData(data, length); |
| 611 | 623 |
| 612 // If we are sending data to MediaDocument, we should stop here and cancel the | 624 // If we are sending data to MediaDocument, we should stop here and cancel the |
| 613 // request. | 625 // request. |
| 614 if (m_frame && m_frame->document()->isMediaDocument()) | 626 if (m_frame && m_frame->document()->isMediaDocument()) |
| 615 m_fetcher->stopFetching(); | 627 m_fetcher->stopFetching(); |
| 616 } | 628 } |
| 617 | 629 |
| 618 void DocumentLoader::clearRedirectChain() { | 630 void DocumentLoader::clearRedirectChain() { |
| 619 m_redirectChain.clear(); | 631 m_redirectChain.clear(); |
| 620 } | 632 } |
| 621 | 633 |
| 622 void DocumentLoader::appendRedirect(const KURL& url) { | 634 void DocumentLoader::appendRedirect(const KURL& url) { |
| 623 m_redirectChain.push_back(url); | 635 m_redirectChain.push_back(url); |
| 624 } | 636 } |
| 625 | 637 |
| 626 void DocumentLoader::detachFromFrame() { | 638 void DocumentLoader::detachFromFrame() { |
| 627 DCHECK(m_frame); | 639 DCHECK(m_frame); |
| 628 | 640 |
| 629 // It never makes sense to have a document loader that is detached from its | 641 // It never makes sense to have a document loader that is detached from its |
| 630 // frame have any loads active, so go ahead and kill all the loads. | 642 // frame have any loads active, so go ahead and kill all the loads. |
| 631 m_fetcher->stopFetching(); | 643 m_fetcher->stopFetching(); |
| 632 | 644 |
| 633 if (frameLoader() && !sentDidFinishLoad()) | 645 if (m_frame && !sentDidFinishLoad()) |
| 634 frameLoader()->loadFailed(this, ResourceError::cancelledError(url())); | 646 frameLoader().loadFailed(this, ResourceError::cancelledError(url())); |
| 635 | 647 |
| 636 // If that load cancellation triggered another detach, leave. | 648 // If that load cancellation triggered another detach, leave. |
| 637 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.) | 649 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.) |
| 638 if (!m_frame) | 650 if (!m_frame) |
| 639 return; | 651 return; |
| 640 | 652 |
| 641 m_fetcher->clearContext(); | 653 m_fetcher->clearContext(); |
| 642 m_applicationCacheHost->detachFromDocumentLoader(); | 654 m_applicationCacheHost->detachFromDocumentLoader(); |
| 643 m_applicationCacheHost.clear(); | 655 m_applicationCacheHost.clear(); |
| 644 WeakIdentifierMap<DocumentLoader>::notifyObjectDestroyed(this); | 656 WeakIdentifierMap<DocumentLoader>::notifyObjectDestroyed(this); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 | 697 |
| 686 bool DocumentLoader::maybeLoadEmpty() { | 698 bool DocumentLoader::maybeLoadEmpty() { |
| 687 bool shouldLoadEmpty = !m_substituteData.isValid() && | 699 bool shouldLoadEmpty = !m_substituteData.isValid() && |
| 688 (m_request.url().isEmpty() || | 700 (m_request.url().isEmpty() || |
| 689 SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument( | 701 SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument( |
| 690 m_request.url().protocol())); | 702 m_request.url().protocol())); |
| 691 if (!shouldLoadEmpty) | 703 if (!shouldLoadEmpty) |
| 692 return false; | 704 return false; |
| 693 | 705 |
| 694 if (m_request.url().isEmpty() && | 706 if (m_request.url().isEmpty() && |
| 695 !frameLoader()->stateMachine()->creatingInitialEmptyDocument()) | 707 !frameLoader().stateMachine()->creatingInitialEmptyDocument()) |
| 696 m_request.setURL(blankURL()); | 708 m_request.setURL(blankURL()); |
| 697 m_response = | 709 m_response = |
| 698 ResourceResponse(m_request.url(), "text/html", 0, nullAtom, String()); | 710 ResourceResponse(m_request.url(), "text/html", 0, nullAtom, String()); |
| 699 finishedLoading(monotonicallyIncreasingTime()); | 711 finishedLoading(monotonicallyIncreasingTime()); |
| 700 return true; | 712 return true; |
| 701 } | 713 } |
| 702 | 714 |
| 703 void DocumentLoader::startLoadingMainResource() { | 715 void DocumentLoader::startLoadingMainResource() { |
| 704 timing().markNavigationStart(); | 716 timing().markNavigationStart(); |
| 705 DCHECK(!m_mainResource); | 717 DCHECK(!m_mainResource); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 m_writer ? m_writer->encoding() : emptyAtom, true, | 813 m_writer ? m_writer->encoding() : emptyAtom, true, |
| 802 ForceSynchronousParsing); | 814 ForceSynchronousParsing); |
| 803 if (!source.isNull()) | 815 if (!source.isNull()) |
| 804 m_writer->appendReplacingData(source); | 816 m_writer->appendReplacingData(source); |
| 805 endWriting(); | 817 endWriting(); |
| 806 } | 818 } |
| 807 | 819 |
| 808 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); | 820 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); |
| 809 | 821 |
| 810 } // namespace blink | 822 } // namespace blink |
| OLD | NEW |