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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 return &m_frame->loader(); | 124 return &m_frame->loader(); |
125 } | 125 } |
126 | 126 |
127 ResourceLoader* DocumentLoader::mainResourceLoader() const | 127 ResourceLoader* DocumentLoader::mainResourceLoader() const |
128 { | 128 { |
129 return m_mainResource ? m_mainResource->loader() : nullptr; | 129 return m_mainResource ? m_mainResource->loader() : nullptr; |
130 } | 130 } |
131 | 131 |
132 DocumentLoader::~DocumentLoader() | 132 DocumentLoader::~DocumentLoader() |
133 { | 133 { |
134 ASSERT(!m_frame); | 134 DCHECK(!m_frame); |
135 ASSERT(!m_mainResource); | 135 DCHECK(!m_mainResource); |
136 ASSERT(!m_applicationCacheHost); | 136 DCHECK(!m_applicationCacheHost); |
137 } | 137 } |
138 | 138 |
139 DEFINE_TRACE(DocumentLoader) | 139 DEFINE_TRACE(DocumentLoader) |
140 { | 140 { |
141 visitor->trace(m_frame); | 141 visitor->trace(m_frame); |
142 visitor->trace(m_fetcher); | 142 visitor->trace(m_fetcher); |
143 visitor->trace(m_mainResource); | 143 visitor->trace(m_mainResource); |
144 visitor->trace(m_writer); | 144 visitor->trace(m_writer); |
145 visitor->trace(m_documentLoadTiming); | 145 visitor->trace(m_documentLoadTiming); |
146 visitor->trace(m_applicationCacheHost); | 146 visitor->trace(m_applicationCacheHost); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 case Resource::TextTrack: | 195 case Resource::TextTrack: |
196 resource = RawResource::fetchTextTrack(request, fetcher()); | 196 resource = RawResource::fetchTextTrack(request, fetcher()); |
197 break; | 197 break; |
198 case Resource::ImportResource: | 198 case Resource::ImportResource: |
199 resource = RawResource::fetchImport(request, fetcher()); | 199 resource = RawResource::fetchImport(request, fetcher()); |
200 break; | 200 break; |
201 case Resource::Raw: | 201 case Resource::Raw: |
202 resource = RawResource::fetch(request, fetcher()); | 202 resource = RawResource::fetch(request, fetcher()); |
203 break; | 203 break; |
204 default: | 204 default: |
205 ASSERT_NOT_REACHED(); | 205 NOTREACHED(); |
206 } | 206 } |
207 | 207 |
208 if (resource) | 208 if (resource) |
209 fetcher()->preloadStarted(resource); | 209 fetcher()->preloadStarted(resource); |
210 return resource; | 210 return resource; |
211 } | 211 } |
212 | 212 |
213 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) | 213 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) |
214 { | 214 { |
215 timing().addRedirect(oldURL, newURL); | 215 timing().addRedirect(oldURL, newURL); |
(...skipping 14 matching lines...) Expand all Loading... | |
230 void DocumentLoader::didChangePerformanceTiming() | 230 void DocumentLoader::didChangePerformanceTiming() |
231 { | 231 { |
232 if (frame() && frame()->isMainFrame() && m_state >= Committed) { | 232 if (frame() && frame()->isMainFrame() && m_state >= Committed) { |
233 frameLoader()->client()->didChangePerformanceTiming(); | 233 frameLoader()->client()->didChangePerformanceTiming(); |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 void DocumentLoader::didObserveLoadingBehavior(WebLoadingBehaviorFlag behavior) | 237 void DocumentLoader::didObserveLoadingBehavior(WebLoadingBehaviorFlag behavior) |
238 { | 238 { |
239 if (frame() && frame()->isMainFrame()) { | 239 if (frame() && frame()->isMainFrame()) { |
240 ASSERT(m_state >= Committed); | 240 DCHECK(m_state >= Committed); |
yhirano
2016/09/12 04:33:12
DCHECK_GE
hiroshige
2016/09/13 08:43:19
Done.
| |
241 frameLoader()->client()->didObserveLoadingBehavior(behavior); | 241 frameLoader()->client()->didObserveLoadingBehavior(behavior); |
242 } | 242 } |
243 } | 243 } |
244 | 244 |
245 void DocumentLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDoc umentNavigationSource sameDocumentNavigationSource) | 245 void DocumentLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDoc umentNavigationSource sameDocumentNavigationSource) |
246 { | 246 { |
247 KURL oldURL = m_request.url(); | 247 KURL oldURL = m_request.url(); |
248 m_originalRequest.setURL(newURL); | 248 m_originalRequest.setURL(newURL); |
249 m_request.setURL(newURL); | 249 m_request.setURL(newURL); |
250 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { | 250 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { |
(...skipping 14 matching lines...) Expand all Loading... | |
265 void DocumentLoader::commitIfReady() | 265 void DocumentLoader::commitIfReady() |
266 { | 266 { |
267 if (m_state < Committed) { | 267 if (m_state < Committed) { |
268 m_state = Committed; | 268 m_state = Committed; |
269 frameLoader()->commitProvisionalLoad(); | 269 frameLoader()->commitProvisionalLoad(); |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 void DocumentLoader::notifyFinished(Resource* resource) | 273 void DocumentLoader::notifyFinished(Resource* resource) |
274 { | 274 { |
275 ASSERT_UNUSED(resource, m_mainResource == resource); | 275 ALLOW_UNUSED_LOCAL(resource); |
yhirano
2016/09/12 04:33:12
ditto as Resource::cancelTimerFired.
hiroshige
2016/09/13 08:43:20
Done.
| |
276 ASSERT(m_mainResource); | 276 DCHECK(m_mainResource == resource); |
yhirano
2016/09/12 04:33:12
DCHECK_EQ
hiroshige
2016/09/13 08:43:19
Done.
| |
277 DCHECK(m_mainResource); | |
277 | 278 |
278 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { | 279 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { |
279 finishedLoading(m_mainResource->loadFinishTime()); | 280 finishedLoading(m_mainResource->loadFinishTime()); |
280 return; | 281 return; |
281 } | 282 } |
282 | 283 |
283 if (m_applicationCacheHost) | 284 if (m_applicationCacheHost) |
284 m_applicationCacheHost->failedLoadingMainResource(); | 285 m_applicationCacheHost->failedLoadingMainResource(); |
285 m_state = MainResourceDone; | 286 m_state = MainResourceDone; |
286 frameLoader()->loadFailed(this, m_mainResource->resourceError()); | 287 frameLoader()->loadFailed(this, m_mainResource->resourceError()); |
(...skipping 29 matching lines...) Expand all Loading... | |
316 | 317 |
317 m_applicationCacheHost->finishedLoadingMainResource(); | 318 m_applicationCacheHost->finishedLoadingMainResource(); |
318 endWriting(m_writer.get()); | 319 endWriting(m_writer.get()); |
319 if (m_state < MainResourceDone) | 320 if (m_state < MainResourceDone) |
320 m_state = MainResourceDone; | 321 m_state = MainResourceDone; |
321 clearMainResourceHandle(); | 322 clearMainResourceHandle(); |
322 } | 323 } |
323 | 324 |
324 void DocumentLoader::redirectReceived(Resource* resource, ResourceRequest& reque st, const ResourceResponse& redirectResponse) | 325 void DocumentLoader::redirectReceived(Resource* resource, ResourceRequest& reque st, const ResourceResponse& redirectResponse) |
325 { | 326 { |
326 ASSERT_UNUSED(resource, resource == m_mainResource); | 327 ALLOW_UNUSED_LOCAL(resource); |
yhirano
2016/09/12 04:33:12
ditto as Resource::cancelTimerFired.
hiroshige
2016/09/13 08:43:19
Done.
| |
327 ASSERT(!redirectResponse.isNull()); | 328 DCHECK(resource == m_mainResource); |
yhirano
2016/09/12 04:33:12
DCHECK_EQ
hiroshige
2016/09/13 08:43:20
Done.
| |
329 DCHECK(!redirectResponse.isNull()); | |
328 m_request = request; | 330 m_request = request; |
329 | 331 |
330 // If the redirecting url is not allowed to display content from the target origin, | 332 // If the redirecting url is not allowed to display content from the target origin, |
331 // then block the redirect. | 333 // then block the redirect. |
332 const KURL& requestURL = m_request.url(); | 334 const KURL& requestURL = m_request.url(); |
333 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectRe sponse.url()); | 335 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectRe sponse.url()); |
334 if (!redirectingOrigin->canDisplay(requestURL)) { | 336 if (!redirectingOrigin->canDisplay(requestURL)) { |
335 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString()); | 337 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString()); |
336 m_fetcher->stopFetching(); | 338 m_fetcher->stopFetching(); |
337 return; | 339 return; |
338 } | 340 } |
339 if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteD ata(), this, CheckContentSecurityPolicy, m_navigationType, NavigationPolicyCurre ntTab, replacesCurrentHistoryItem(), isClientRedirect())) { | 341 if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteD ata(), this, CheckContentSecurityPolicy, m_navigationType, NavigationPolicyCurre ntTab, replacesCurrentHistoryItem(), isClientRedirect())) { |
340 m_fetcher->stopFetching(); | 342 m_fetcher->stopFetching(); |
341 return; | 343 return; |
342 } | 344 } |
343 | 345 |
344 ASSERT(timing().fetchStart()); | 346 DCHECK(timing().fetchStart()); |
345 appendRedirect(requestURL); | 347 appendRedirect(requestURL); |
346 didRedirect(redirectResponse.url(), requestURL); | 348 didRedirect(redirectResponse.url(), requestURL); |
347 frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad( ); | 349 frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad( ); |
348 } | 350 } |
349 | 351 |
350 static bool canShowMIMEType(const String& mimeType, LocalFrame* frame) | 352 static bool canShowMIMEType(const String& mimeType, LocalFrame* frame) |
351 { | 353 { |
352 if (Platform::current()->mimeRegistry()->supportsMIMEType(mimeType) == WebMi meRegistry::IsSupported) | 354 if (Platform::current()->mimeRegistry()->supportsMIMEType(mimeType) == WebMi meRegistry::IsSupported) |
353 return true; | 355 return true; |
354 PluginData* pluginData = frame->pluginData(); | 356 PluginData* pluginData = frame->pluginData(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 m_redirectChain.removeLast(); | 398 m_redirectChain.removeLast(); |
397 appendRedirect(blockedURL); | 399 appendRedirect(blockedURL); |
398 m_response = ResourceResponse(blockedURL, "text/html", 0, nullAtom, String() ); | 400 m_response = ResourceResponse(blockedURL, "text/html", 0, nullAtom, String() ); |
399 finishedLoading(monotonicallyIncreasingTime()); | 401 finishedLoading(monotonicallyIncreasingTime()); |
400 | 402 |
401 return; | 403 return; |
402 } | 404 } |
403 | 405 |
404 void DocumentLoader::responseReceived(Resource* resource, const ResourceResponse & response, std::unique_ptr<WebDataConsumerHandle> handle) | 406 void DocumentLoader::responseReceived(Resource* resource, const ResourceResponse & response, std::unique_ptr<WebDataConsumerHandle> handle) |
405 { | 407 { |
406 ASSERT_UNUSED(resource, m_mainResource == resource); | 408 ALLOW_UNUSED_LOCAL(resource); |
yhirano
2016/09/12 04:33:12
ditto as Resource::cancelTimerFired.
hiroshige
2016/09/13 08:43:19
Done.
| |
407 ASSERT_UNUSED(handle, !handle); | 409 DCHECK(m_mainResource == resource); |
yhirano
2016/09/12 04:33:12
DCHECK_EQ
hiroshige
2016/09/13 08:43:19
Done.
| |
408 ASSERT(frame()); | 410 ALLOW_UNUSED_LOCAL(handle); |
yhirano
2016/09/12 04:33:12
ditto as Resource::cancelTimerFired.
hiroshige
2016/09/13 08:43:19
Done.
| |
411 DCHECK(!handle); | |
412 DCHECK(frame()); | |
409 | 413 |
410 m_applicationCacheHost->didReceiveResponseForMainResource(response); | 414 m_applicationCacheHost->didReceiveResponseForMainResource(response); |
411 | 415 |
412 // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served | 416 // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served |
413 // from the application cache, ensure we don't save the result for future us e. All responses loaded | 417 // from the application cache, ensure we don't save the result for future us e. All responses loaded |
414 // from appcache will have a non-zero appCacheID(). | 418 // from appcache will have a non-zero appCacheID(). |
415 if (response.appCacheID()) | 419 if (response.appCacheID()) |
416 memoryCache()->remove(m_mainResource.get()); | 420 memoryCache()->remove(m_mainResource.get()); |
417 | 421 |
418 m_contentSecurityPolicy = ContentSecurityPolicy::create(); | 422 m_contentSecurityPolicy = ContentSecurityPolicy::create(); |
(...skipping 13 matching lines...) Expand all Loading... | |
432 String message = "Refused to display '" + response.url().elidedS tring() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'."; | 436 String message = "Refused to display '" + response.url().elidedS tring() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'."; |
433 ConsoleMessage* consoleMessage = ConsoleMessage::createForReques t(SecurityMessageSource, ErrorMessageLevel, message, response.url(), mainResourc eIdentifier()); | 437 ConsoleMessage* consoleMessage = ConsoleMessage::createForReques t(SecurityMessageSource, ErrorMessageLevel, message, response.url(), mainResourc eIdentifier()); |
434 frame()->document()->addConsoleMessage(consoleMessage); | 438 frame()->document()->addConsoleMessage(consoleMessage); |
435 | 439 |
436 cancelLoadAfterXFrameOptionsOrCSPDenied(response); | 440 cancelLoadAfterXFrameOptionsOrCSPDenied(response); |
437 return; | 441 return; |
438 } | 442 } |
439 } | 443 } |
440 } | 444 } |
441 | 445 |
442 ASSERT(!m_frame->page()->defersLoading()); | 446 DCHECK(!m_frame->page()->defersLoading()); |
443 | 447 |
444 m_response = response; | 448 m_response = response; |
445 | 449 |
446 if (isArchiveMIMEType(m_response.mimeType()) && m_mainResource->getDataBuffe ringPolicy() != BufferData) | 450 if (isArchiveMIMEType(m_response.mimeType()) && m_mainResource->getDataBuffe ringPolicy() != BufferData) |
447 m_mainResource->setDataBufferingPolicy(BufferData); | 451 m_mainResource->setDataBufferingPolicy(BufferData); |
448 | 452 |
449 if (!shouldContinueForResponse()) { | 453 if (!shouldContinueForResponse()) { |
450 InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, m_main Resource->identifier(), m_response, m_mainResource.get()); | 454 InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, m_main Resource->identifier(), m_response, m_mainResource.get()); |
451 m_fetcher->stopFetching(); | 455 m_fetcher->stopFetching(); |
452 return; | 456 return; |
(...skipping 21 matching lines...) Expand all Loading... | |
474 if (shouldInheritSecurityOriginFromOwner(url())) { | 478 if (shouldInheritSecurityOriginFromOwner(url())) { |
475 Frame* ownerFrame = m_frame->tree().parent(); | 479 Frame* ownerFrame = m_frame->tree().parent(); |
476 if (!ownerFrame) | 480 if (!ownerFrame) |
477 ownerFrame = m_frame->loader().opener(); | 481 ownerFrame = m_frame->loader().opener(); |
478 if (ownerFrame && ownerFrame->isLocalFrame()) | 482 if (ownerFrame && ownerFrame->isLocalFrame()) |
479 owner = toLocalFrame(ownerFrame)->document(); | 483 owner = toLocalFrame(ownerFrame)->document(); |
480 } | 484 } |
481 DocumentInit init(owner, url(), m_frame); | 485 DocumentInit init(owner, url(), m_frame); |
482 init.withNewRegistrationContext(); | 486 init.withNewRegistrationContext(); |
483 m_frame->loader().clear(); | 487 m_frame->loader().clear(); |
484 ASSERT(m_frame->page()); | 488 DCHECK(m_frame->page()); |
485 | 489 |
486 ParserSynchronizationPolicy parsingPolicy = AllowAsynchronousParsing; | 490 ParserSynchronizationPolicy parsingPolicy = AllowAsynchronousParsing; |
487 if ((m_substituteData.isValid() && m_substituteData.forceSynchronousLoad()) || !Document::threadedParsingEnabledForTesting()) | 491 if ((m_substituteData.isValid() && m_substituteData.forceSynchronousLoad()) || !Document::threadedParsingEnabledForTesting()) |
488 parsingPolicy = ForceSynchronousParsing; | 492 parsingPolicy = ForceSynchronousParsing; |
489 | 493 |
490 m_writer = createWriterFor(init, mimeType, encoding, false, parsingPolicy, o verridingURL); | 494 m_writer = createWriterFor(init, mimeType, encoding, false, parsingPolicy, o verridingURL); |
491 m_writer->setDocumentWasLoadedAsPartOfNavigation(); | 495 m_writer->setDocumentWasLoadedAsPartOfNavigation(); |
492 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField(HTTPN ames::Refresh), Document::HttpRefreshFromHeader); | 496 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField(HTTPN ames::Refresh), Document::HttpRefreshFromHeader); |
493 } | 497 } |
494 | 498 |
495 void DocumentLoader::commitData(const char* bytes, size_t length) | 499 void DocumentLoader::commitData(const char* bytes, size_t length) |
496 { | 500 { |
497 ASSERT(m_state < MainResourceDone); | 501 DCHECK(m_state < MainResourceDone); |
yhirano
2016/09/12 04:33:12
DCHECK_LT
hiroshige
2016/09/13 08:43:19
Done.
| |
498 ensureWriter(m_response.mimeType()); | 502 ensureWriter(m_response.mimeType()); |
499 | 503 |
500 // This can happen if document.close() is called by an event handler while | 504 // This can happen if document.close() is called by an event handler while |
501 // there's still pending incoming data. | 505 // there's still pending incoming data. |
502 if (m_frame && !m_frame->document()->parsing()) | 506 if (m_frame && !m_frame->document()->parsing()) |
503 return; | 507 return; |
504 | 508 |
505 if (length) | 509 if (length) |
506 m_dataReceived = true; | 510 m_dataReceived = true; |
507 | 511 |
508 m_writer->addData(bytes, length); | 512 m_writer->addData(bytes, length); |
509 } | 513 } |
510 | 514 |
511 void DocumentLoader::dataReceived(Resource* resource, const char* data, size_t l ength) | 515 void DocumentLoader::dataReceived(Resource* resource, const char* data, size_t l ength) |
512 { | 516 { |
513 ASSERT(data); | 517 DCHECK(data); |
514 ASSERT(length); | 518 DCHECK(length); |
515 ASSERT_UNUSED(resource, resource == m_mainResource); | 519 ALLOW_UNUSED_LOCAL(resource); |
yhirano
2016/09/12 04:33:12
ditto as Resource::cancelTimerFired.
hiroshige
2016/09/13 08:43:19
Done.
| |
516 ASSERT(!m_response.isNull()); | 520 DCHECK(resource == m_mainResource); |
yhirano
2016/09/12 04:33:12
DCHECK_EQ
hiroshige
2016/09/13 08:43:20
Done.
| |
517 ASSERT(!m_frame->page()->defersLoading()); | 521 DCHECK(!m_response.isNull()); |
522 DCHECK(!m_frame->page()->defersLoading()); | |
518 | 523 |
519 if (m_inDataReceived) { | 524 if (m_inDataReceived) { |
520 // If this function is reentered, defer processing of the additional | 525 // If this function is reentered, defer processing of the additional |
521 // data to the top-level invocation. Reentrant calls can occur because | 526 // data to the top-level invocation. Reentrant calls can occur because |
522 // of web platform (mis-)features that require running a nested message | 527 // of web platform (mis-)features that require running a nested message |
523 // loop: | 528 // loop: |
524 // - alert(), confirm(), prompt() | 529 // - alert(), confirm(), prompt() |
525 // - Detach of plugin elements. | 530 // - Detach of plugin elements. |
526 // - Synchronous XMLHTTPRequest | 531 // - Synchronous XMLHTTPRequest |
527 m_dataBuffer->append(data, length); | 532 m_dataBuffer->append(data, length); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 m_redirectChain.clear(); | 572 m_redirectChain.clear(); |
568 } | 573 } |
569 | 574 |
570 void DocumentLoader::appendRedirect(const KURL& url) | 575 void DocumentLoader::appendRedirect(const KURL& url) |
571 { | 576 { |
572 m_redirectChain.append(url); | 577 m_redirectChain.append(url); |
573 } | 578 } |
574 | 579 |
575 void DocumentLoader::detachFromFrame() | 580 void DocumentLoader::detachFromFrame() |
576 { | 581 { |
577 ASSERT(m_frame); | 582 DCHECK(m_frame); |
578 | 583 |
579 // It never makes sense to have a document loader that is detached from its | 584 // It never makes sense to have a document loader that is detached from its |
580 // frame have any loads active, so go ahead and kill all the loads. | 585 // frame have any loads active, so go ahead and kill all the loads. |
581 m_fetcher->stopFetching(); | 586 m_fetcher->stopFetching(); |
582 | 587 |
583 // If that load cancellation triggered another detach, leave. | 588 // If that load cancellation triggered another detach, leave. |
584 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.) | 589 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.) |
585 if (!m_frame) | 590 if (!m_frame) |
586 return; | 591 return; |
587 | 592 |
(...skipping 12 matching lines...) Expand all Loading... | |
600 m_mainResource->removeClient(this); | 605 m_mainResource->removeClient(this); |
601 m_mainResource = nullptr; | 606 m_mainResource = nullptr; |
602 } | 607 } |
603 | 608 |
604 bool DocumentLoader::maybeCreateArchive() | 609 bool DocumentLoader::maybeCreateArchive() |
605 { | 610 { |
606 // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. | 611 // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. |
607 if (!isArchiveMIMEType(m_response.mimeType())) | 612 if (!isArchiveMIMEType(m_response.mimeType())) |
608 return false; | 613 return false; |
609 | 614 |
610 ASSERT(m_mainResource); | 615 DCHECK(m_mainResource); |
611 ArchiveResource* mainResource = m_fetcher->createArchive(m_mainResource.get( )); | 616 ArchiveResource* mainResource = m_fetcher->createArchive(m_mainResource.get( )); |
612 if (!mainResource) | 617 if (!mainResource) |
613 return false; | 618 return false; |
614 // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so | 619 // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so |
615 // relative URLs are resolved properly. | 620 // relative URLs are resolved properly. |
616 ensureWriter(mainResource->mimeType(), mainResource->url()); | 621 ensureWriter(mainResource->mimeType(), mainResource->url()); |
617 | 622 |
618 // The Document has now been created. | 623 // The Document has now been created. |
619 m_frame->document()->enforceSandboxFlags(SandboxAll); | 624 m_frame->document()->enforceSandboxFlags(SandboxAll); |
620 | 625 |
(...skipping 25 matching lines...) Expand all Loading... | |
646 } | 651 } |
647 | 652 |
648 void DocumentLoader::upgradeInsecureRequest() | 653 void DocumentLoader::upgradeInsecureRequest() |
649 { | 654 { |
650 fetcher()->context().upgradeInsecureRequest(m_request); | 655 fetcher()->context().upgradeInsecureRequest(m_request); |
651 } | 656 } |
652 | 657 |
653 void DocumentLoader::startLoadingMainResource() | 658 void DocumentLoader::startLoadingMainResource() |
654 { | 659 { |
655 timing().markNavigationStart(); | 660 timing().markNavigationStart(); |
656 ASSERT(!m_mainResource); | 661 DCHECK(!m_mainResource); |
657 ASSERT(m_state == NotStarted); | 662 DCHECK(m_state == NotStarted); |
yhirano
2016/09/12 04:33:12
DCHECK_EQ
hiroshige
2016/09/13 08:43:19
Done.
| |
658 m_state = Provisional; | 663 m_state = Provisional; |
659 | 664 |
660 if (maybeLoadEmpty()) | 665 if (maybeLoadEmpty()) |
661 return; | 666 return; |
662 | 667 |
663 ASSERT(timing().navigationStart()); | 668 DCHECK(timing().navigationStart()); |
664 | 669 |
665 // PlzNavigate: | 670 // PlzNavigate: |
666 // The fetch has already started in the browser. Don't mark it again. | 671 // The fetch has already started in the browser. Don't mark it again. |
667 if (!m_frame->settings()->browserSideNavigationEnabled()) { | 672 if (!m_frame->settings()->browserSideNavigationEnabled()) { |
668 DCHECK(!timing().fetchStart()); | 673 DCHECK(!timing().fetchStart()); |
669 timing().markFetchStart(); | 674 timing().markFetchStart(); |
670 } | 675 } |
671 | 676 |
672 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, | 677 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, |
673 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext)); | 678 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext)); |
674 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main ResourceLoadOptions); | 679 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main ResourceLoadOptions); |
675 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s ubstituteData); | 680 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s ubstituteData); |
676 if (!m_mainResource) { | 681 if (!m_mainResource) { |
677 m_request = ResourceRequest(blankURL()); | 682 m_request = ResourceRequest(blankURL()); |
678 maybeLoadEmpty(); | 683 maybeLoadEmpty(); |
679 return; | 684 return; |
680 } | 685 } |
681 // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those. | 686 // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those. |
682 // Even when using a cached resource, we may make some modification to the r equest, e.g. adding the referer header. | 687 // Even when using a cached resource, we may make some modification to the r equest, e.g. adding the referer header. |
683 m_request = mainResourceLoader() ? m_mainResource->resourceRequest() : fetch Request.resourceRequest(); | 688 m_request = mainResourceLoader() ? m_mainResource->resourceRequest() : fetch Request.resourceRequest(); |
684 m_mainResource->addClient(this); | 689 m_mainResource->addClient(this); |
685 } | 690 } |
686 | 691 |
687 void DocumentLoader::endWriting(DocumentWriter* writer) | 692 void DocumentLoader::endWriting(DocumentWriter* writer) |
688 { | 693 { |
689 ASSERT_UNUSED(writer, m_writer == writer); | 694 ALLOW_UNUSED_LOCAL(writer); |
yhirano
2016/09/12 04:33:12
ditto as Resource::cancelTimerFired.
hiroshige
2016/09/13 08:43:19
Done.
| |
695 DCHECK(m_writer == writer); | |
yhirano
2016/09/12 04:33:12
DCHECK_EQ
hiroshige
2016/09/13 08:43:20
Done.
| |
690 m_writer->end(); | 696 m_writer->end(); |
691 m_writer.clear(); | 697 m_writer.clear(); |
692 } | 698 } |
693 | 699 |
694 DocumentWriter* DocumentLoader::createWriterFor(const DocumentInit& init, const AtomicString& mimeType, const AtomicString& encoding, bool dispatchWindowObjectA vailable, ParserSynchronizationPolicy parsingPolicy, const KURL& overridingURL) | 700 DocumentWriter* DocumentLoader::createWriterFor(const DocumentInit& init, const AtomicString& mimeType, const AtomicString& encoding, bool dispatchWindowObjectA vailable, ParserSynchronizationPolicy parsingPolicy, const KURL& overridingURL) |
695 { | 701 { |
696 LocalFrame* frame = init.frame(); | 702 LocalFrame* frame = init.frame(); |
697 | 703 |
698 ASSERT(!frame->document() || !frame->document()->isActive()); | 704 DCHECK(!frame->document() || !frame->document()->isActive()); |
699 ASSERT(frame->tree().childCount() == 0); | 705 DCHECK_EQ(frame->tree().childCount(), 0u); |
700 | 706 |
701 if (!init.shouldReuseDefaultView()) | 707 if (!init.shouldReuseDefaultView()) |
702 frame->setDOMWindow(LocalDOMWindow::create(*frame)); | 708 frame->setDOMWindow(LocalDOMWindow::create(*frame)); |
703 | 709 |
704 Document* document = frame->localDOMWindow()->installNewDocument(mimeType, i nit); | 710 Document* document = frame->localDOMWindow()->installNewDocument(mimeType, i nit); |
705 | 711 |
706 // This should be set before receivedFirstData(). | 712 // This should be set before receivedFirstData(). |
707 if (!overridingURL.isEmpty()) | 713 if (!overridingURL.isEmpty()) |
708 frame->document()->setBaseURLOverride(overridingURL); | 714 frame->document()->setBaseURLOverride(overridingURL); |
709 | 715 |
(...skipping 21 matching lines...) Expand all Loading... | |
731 { | 737 { |
732 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing); | 738 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing); |
733 if (!source.isNull()) | 739 if (!source.isNull()) |
734 m_writer->appendReplacingData(source); | 740 m_writer->appendReplacingData(source); |
735 endWriting(m_writer.get()); | 741 endWriting(m_writer.get()); |
736 } | 742 } |
737 | 743 |
738 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); | 744 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); |
739 | 745 |
740 } // namespace blink | 746 } // namespace blink |
OLD | NEW |