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

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

Issue 2327643003: Replace ASSERT*() with DCHECK*() in core/fetch/ and core/loader/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 3 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
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 FrameLoader* DocumentLoader::frameLoader() const 119 FrameLoader* DocumentLoader::frameLoader() const
120 { 120 {
121 if (!m_frame) 121 if (!m_frame)
122 return nullptr; 122 return nullptr;
123 return &m_frame->loader(); 123 return &m_frame->loader();
124 } 124 }
125 125
126 DocumentLoader::~DocumentLoader() 126 DocumentLoader::~DocumentLoader()
127 { 127 {
128 ASSERT(!m_frame); 128 DCHECK(!m_frame);
129 ASSERT(!m_mainResource); 129 DCHECK(!m_mainResource);
130 ASSERT(!m_applicationCacheHost); 130 DCHECK(!m_applicationCacheHost);
131 } 131 }
132 132
133 DEFINE_TRACE(DocumentLoader) 133 DEFINE_TRACE(DocumentLoader)
134 { 134 {
135 visitor->trace(m_frame); 135 visitor->trace(m_frame);
136 visitor->trace(m_fetcher); 136 visitor->trace(m_fetcher);
137 visitor->trace(m_mainResource); 137 visitor->trace(m_mainResource);
138 visitor->trace(m_writer); 138 visitor->trace(m_writer);
139 visitor->trace(m_documentLoadTiming); 139 visitor->trace(m_documentLoadTiming);
140 visitor->trace(m_applicationCacheHost); 140 visitor->trace(m_applicationCacheHost);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 case Resource::TextTrack: 189 case Resource::TextTrack:
190 resource = RawResource::fetchTextTrack(request, fetcher()); 190 resource = RawResource::fetchTextTrack(request, fetcher());
191 break; 191 break;
192 case Resource::ImportResource: 192 case Resource::ImportResource:
193 resource = RawResource::fetchImport(request, fetcher()); 193 resource = RawResource::fetchImport(request, fetcher());
194 break; 194 break;
195 case Resource::Raw: 195 case Resource::Raw:
196 resource = RawResource::fetch(request, fetcher()); 196 resource = RawResource::fetch(request, fetcher());
197 break; 197 break;
198 default: 198 default:
199 ASSERT_NOT_REACHED(); 199 NOTREACHED();
200 } 200 }
201 201
202 if (resource) 202 if (resource)
203 fetcher()->preloadStarted(resource); 203 fetcher()->preloadStarted(resource);
204 return resource; 204 return resource;
205 } 205 }
206 206
207 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) 207 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL)
208 { 208 {
209 timing().addRedirect(oldURL, newURL); 209 timing().addRedirect(oldURL, newURL);
(...skipping 14 matching lines...) Expand all
224 void DocumentLoader::didChangePerformanceTiming() 224 void DocumentLoader::didChangePerformanceTiming()
225 { 225 {
226 if (frame() && frame()->isMainFrame() && m_state >= Committed) { 226 if (frame() && frame()->isMainFrame() && m_state >= Committed) {
227 frameLoader()->client()->didChangePerformanceTiming(); 227 frameLoader()->client()->didChangePerformanceTiming();
228 } 228 }
229 } 229 }
230 230
231 void DocumentLoader::didObserveLoadingBehavior(WebLoadingBehaviorFlag behavior) 231 void DocumentLoader::didObserveLoadingBehavior(WebLoadingBehaviorFlag behavior)
232 { 232 {
233 if (frame() && frame()->isMainFrame()) { 233 if (frame() && frame()->isMainFrame()) {
234 ASSERT(m_state >= Committed); 234 DCHECK_GE(m_state, Committed);
235 frameLoader()->client()->didObserveLoadingBehavior(behavior); 235 frameLoader()->client()->didObserveLoadingBehavior(behavior);
236 } 236 }
237 } 237 }
238 238
239 void DocumentLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDoc umentNavigationSource sameDocumentNavigationSource) 239 void DocumentLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDoc umentNavigationSource sameDocumentNavigationSource)
240 { 240 {
241 KURL oldURL = m_request.url(); 241 KURL oldURL = m_request.url();
242 m_originalRequest.setURL(newURL); 242 m_originalRequest.setURL(newURL);
243 m_request.setURL(newURL); 243 m_request.setURL(newURL);
244 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { 244 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) {
(...skipping 14 matching lines...) Expand all
259 void DocumentLoader::commitIfReady() 259 void DocumentLoader::commitIfReady()
260 { 260 {
261 if (m_state < Committed) { 261 if (m_state < Committed) {
262 m_state = Committed; 262 m_state = Committed;
263 frameLoader()->commitProvisionalLoad(); 263 frameLoader()->commitProvisionalLoad();
264 } 264 }
265 } 265 }
266 266
267 void DocumentLoader::notifyFinished(Resource* resource) 267 void DocumentLoader::notifyFinished(Resource* resource)
268 { 268 {
269 ASSERT_UNUSED(resource, m_mainResource == resource); 269 DCHECK_EQ(m_mainResource, resource);
270 ASSERT(m_mainResource); 270 DCHECK(m_mainResource);
271 271
272 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { 272 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
273 finishedLoading(m_mainResource->loadFinishTime()); 273 finishedLoading(m_mainResource->loadFinishTime());
274 return; 274 return;
275 } 275 }
276 276
277 if (m_applicationCacheHost) 277 if (m_applicationCacheHost)
278 m_applicationCacheHost->failedLoadingMainResource(); 278 m_applicationCacheHost->failedLoadingMainResource();
279 m_state = MainResourceDone; 279 m_state = MainResourceDone;
280 frameLoader()->loadFailed(this, m_mainResource->resourceError()); 280 frameLoader()->loadFailed(this, m_mainResource->resourceError());
(...skipping 29 matching lines...) Expand all
310 310
311 m_applicationCacheHost->finishedLoadingMainResource(); 311 m_applicationCacheHost->finishedLoadingMainResource();
312 endWriting(m_writer.get()); 312 endWriting(m_writer.get());
313 if (m_state < MainResourceDone) 313 if (m_state < MainResourceDone)
314 m_state = MainResourceDone; 314 m_state = MainResourceDone;
315 clearMainResourceHandle(); 315 clearMainResourceHandle();
316 } 316 }
317 317
318 void DocumentLoader::redirectReceived(Resource* resource, ResourceRequest& reque st, const ResourceResponse& redirectResponse) 318 void DocumentLoader::redirectReceived(Resource* resource, ResourceRequest& reque st, const ResourceResponse& redirectResponse)
319 { 319 {
320 ASSERT_UNUSED(resource, resource == m_mainResource); 320 DCHECK_EQ(resource, m_mainResource);
321 ASSERT(!redirectResponse.isNull()); 321 DCHECK(!redirectResponse.isNull());
322 m_request = request; 322 m_request = request;
323 323
324 // If the redirecting url is not allowed to display content from the target origin, 324 // If the redirecting url is not allowed to display content from the target origin,
325 // then block the redirect. 325 // then block the redirect.
326 const KURL& requestURL = m_request.url(); 326 const KURL& requestURL = m_request.url();
327 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectRe sponse.url()); 327 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectRe sponse.url());
328 if (!redirectingOrigin->canDisplay(requestURL)) { 328 if (!redirectingOrigin->canDisplay(requestURL)) {
329 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString()); 329 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString());
330 m_fetcher->stopFetching(); 330 m_fetcher->stopFetching();
331 return; 331 return;
332 } 332 }
333 if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteD ata(), this, CheckContentSecurityPolicy, m_navigationType, NavigationPolicyCurre ntTab, replacesCurrentHistoryItem(), isClientRedirect())) { 333 if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteD ata(), this, CheckContentSecurityPolicy, m_navigationType, NavigationPolicyCurre ntTab, replacesCurrentHistoryItem(), isClientRedirect())) {
334 m_fetcher->stopFetching(); 334 m_fetcher->stopFetching();
335 return; 335 return;
336 } 336 }
337 337
338 ASSERT(timing().fetchStart()); 338 DCHECK(timing().fetchStart());
339 appendRedirect(requestURL); 339 appendRedirect(requestURL);
340 didRedirect(redirectResponse.url(), requestURL); 340 didRedirect(redirectResponse.url(), requestURL);
341 frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad( ); 341 frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad( );
342 } 342 }
343 343
344 static bool canShowMIMEType(const String& mimeType, LocalFrame* frame) 344 static bool canShowMIMEType(const String& mimeType, LocalFrame* frame)
345 { 345 {
346 if (Platform::current()->mimeRegistry()->supportsMIMEType(mimeType) == WebMi meRegistry::IsSupported) 346 if (Platform::current()->mimeRegistry()->supportsMIMEType(mimeType) == WebMi meRegistry::IsSupported)
347 return true; 347 return true;
348 PluginData* pluginData = frame->pluginData(); 348 PluginData* pluginData = frame->pluginData();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 m_redirectChain.removeLast(); 390 m_redirectChain.removeLast();
391 appendRedirect(blockedURL); 391 appendRedirect(blockedURL);
392 m_response = ResourceResponse(blockedURL, "text/html", 0, nullAtom, String() ); 392 m_response = ResourceResponse(blockedURL, "text/html", 0, nullAtom, String() );
393 finishedLoading(monotonicallyIncreasingTime()); 393 finishedLoading(monotonicallyIncreasingTime());
394 394
395 return; 395 return;
396 } 396 }
397 397
398 void DocumentLoader::responseReceived(Resource* resource, const ResourceResponse & response, std::unique_ptr<WebDataConsumerHandle> handle) 398 void DocumentLoader::responseReceived(Resource* resource, const ResourceResponse & response, std::unique_ptr<WebDataConsumerHandle> handle)
399 { 399 {
400 ASSERT_UNUSED(resource, m_mainResource == resource); 400 DCHECK_EQ(m_mainResource, resource);
401 ASSERT_UNUSED(handle, !handle); 401 DCHECK(!handle);
402 ASSERT(frame()); 402 DCHECK(frame());
403 403
404 m_applicationCacheHost->didReceiveResponseForMainResource(response); 404 m_applicationCacheHost->didReceiveResponseForMainResource(response);
405 405
406 // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served 406 // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served
407 // from the application cache, ensure we don't save the result for future us e. All responses loaded 407 // from the application cache, ensure we don't save the result for future us e. All responses loaded
408 // from appcache will have a non-zero appCacheID(). 408 // from appcache will have a non-zero appCacheID().
409 if (response.appCacheID()) 409 if (response.appCacheID())
410 memoryCache()->remove(m_mainResource.get()); 410 memoryCache()->remove(m_mainResource.get());
411 411
412 m_contentSecurityPolicy = ContentSecurityPolicy::create(); 412 m_contentSecurityPolicy = ContentSecurityPolicy::create();
(...skipping 13 matching lines...) Expand all
426 String message = "Refused to display '" + response.url().elidedS tring() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'."; 426 String message = "Refused to display '" + response.url().elidedS tring() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
427 ConsoleMessage* consoleMessage = ConsoleMessage::createForReques t(SecurityMessageSource, ErrorMessageLevel, message, response.url(), mainResourc eIdentifier()); 427 ConsoleMessage* consoleMessage = ConsoleMessage::createForReques t(SecurityMessageSource, ErrorMessageLevel, message, response.url(), mainResourc eIdentifier());
428 frame()->document()->addConsoleMessage(consoleMessage); 428 frame()->document()->addConsoleMessage(consoleMessage);
429 429
430 cancelLoadAfterXFrameOptionsOrCSPDenied(response); 430 cancelLoadAfterXFrameOptionsOrCSPDenied(response);
431 return; 431 return;
432 } 432 }
433 } 433 }
434 } 434 }
435 435
436 ASSERT(!m_frame->page()->defersLoading()); 436 DCHECK(!m_frame->page()->defersLoading());
437 437
438 m_response = response; 438 m_response = response;
439 439
440 if (isArchiveMIMEType(m_response.mimeType()) && m_mainResource->getDataBuffe ringPolicy() != BufferData) 440 if (isArchiveMIMEType(m_response.mimeType()) && m_mainResource->getDataBuffe ringPolicy() != BufferData)
441 m_mainResource->setDataBufferingPolicy(BufferData); 441 m_mainResource->setDataBufferingPolicy(BufferData);
442 442
443 if (!shouldContinueForResponse()) { 443 if (!shouldContinueForResponse()) {
444 InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, m_main Resource->identifier(), m_response, m_mainResource.get()); 444 InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, m_main Resource->identifier(), m_response, m_mainResource.get());
445 m_fetcher->stopFetching(); 445 m_fetcher->stopFetching();
446 return; 446 return;
(...skipping 21 matching lines...) Expand all
468 if (shouldInheritSecurityOriginFromOwner(url())) { 468 if (shouldInheritSecurityOriginFromOwner(url())) {
469 Frame* ownerFrame = m_frame->tree().parent(); 469 Frame* ownerFrame = m_frame->tree().parent();
470 if (!ownerFrame) 470 if (!ownerFrame)
471 ownerFrame = m_frame->loader().opener(); 471 ownerFrame = m_frame->loader().opener();
472 if (ownerFrame && ownerFrame->isLocalFrame()) 472 if (ownerFrame && ownerFrame->isLocalFrame())
473 owner = toLocalFrame(ownerFrame)->document(); 473 owner = toLocalFrame(ownerFrame)->document();
474 } 474 }
475 DocumentInit init(owner, url(), m_frame); 475 DocumentInit init(owner, url(), m_frame);
476 init.withNewRegistrationContext(); 476 init.withNewRegistrationContext();
477 m_frame->loader().clear(); 477 m_frame->loader().clear();
478 ASSERT(m_frame->page()); 478 DCHECK(m_frame->page());
479 479
480 ParserSynchronizationPolicy parsingPolicy = AllowAsynchronousParsing; 480 ParserSynchronizationPolicy parsingPolicy = AllowAsynchronousParsing;
481 if ((m_substituteData.isValid() && m_substituteData.forceSynchronousLoad()) || !Document::threadedParsingEnabledForTesting()) 481 if ((m_substituteData.isValid() && m_substituteData.forceSynchronousLoad()) || !Document::threadedParsingEnabledForTesting())
482 parsingPolicy = ForceSynchronousParsing; 482 parsingPolicy = ForceSynchronousParsing;
483 483
484 m_writer = createWriterFor(init, mimeType, encoding, false, parsingPolicy, o verridingURL); 484 m_writer = createWriterFor(init, mimeType, encoding, false, parsingPolicy, o verridingURL);
485 m_writer->setDocumentWasLoadedAsPartOfNavigation(); 485 m_writer->setDocumentWasLoadedAsPartOfNavigation();
486 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField(HTTPN ames::Refresh), Document::HttpRefreshFromHeader); 486 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField(HTTPN ames::Refresh), Document::HttpRefreshFromHeader);
487 } 487 }
488 488
489 void DocumentLoader::commitData(const char* bytes, size_t length) 489 void DocumentLoader::commitData(const char* bytes, size_t length)
490 { 490 {
491 ASSERT(m_state < MainResourceDone); 491 DCHECK_LT(m_state, MainResourceDone);
492 ensureWriter(m_response.mimeType()); 492 ensureWriter(m_response.mimeType());
493 493
494 // This can happen if document.close() is called by an event handler while 494 // This can happen if document.close() is called by an event handler while
495 // there's still pending incoming data. 495 // there's still pending incoming data.
496 if (m_frame && !m_frame->document()->parsing()) 496 if (m_frame && !m_frame->document()->parsing())
497 return; 497 return;
498 498
499 if (length) 499 if (length)
500 m_dataReceived = true; 500 m_dataReceived = true;
501 501
502 m_writer->addData(bytes, length); 502 m_writer->addData(bytes, length);
503 } 503 }
504 504
505 void DocumentLoader::dataReceived(Resource* resource, const char* data, size_t l ength) 505 void DocumentLoader::dataReceived(Resource* resource, const char* data, size_t l ength)
506 { 506 {
507 ASSERT(data); 507 DCHECK(data);
508 ASSERT(length); 508 DCHECK(length);
509 ASSERT_UNUSED(resource, resource == m_mainResource); 509 DCHECK_EQ(resource, m_mainResource);
510 ASSERT(!m_response.isNull()); 510 DCHECK(!m_response.isNull());
511 ASSERT(!m_frame->page()->defersLoading()); 511 DCHECK(!m_frame->page()->defersLoading());
512 512
513 if (m_inDataReceived) { 513 if (m_inDataReceived) {
514 // If this function is reentered, defer processing of the additional 514 // If this function is reentered, defer processing of the additional
515 // data to the top-level invocation. Reentrant calls can occur because 515 // data to the top-level invocation. Reentrant calls can occur because
516 // of web platform (mis-)features that require running a nested message 516 // of web platform (mis-)features that require running a nested message
517 // loop: 517 // loop:
518 // - alert(), confirm(), prompt() 518 // - alert(), confirm(), prompt()
519 // - Detach of plugin elements. 519 // - Detach of plugin elements.
520 // - Synchronous XMLHTTPRequest 520 // - Synchronous XMLHTTPRequest
521 m_dataBuffer->append(data, length); 521 m_dataBuffer->append(data, length);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 m_redirectChain.clear(); 561 m_redirectChain.clear();
562 } 562 }
563 563
564 void DocumentLoader::appendRedirect(const KURL& url) 564 void DocumentLoader::appendRedirect(const KURL& url)
565 { 565 {
566 m_redirectChain.append(url); 566 m_redirectChain.append(url);
567 } 567 }
568 568
569 void DocumentLoader::detachFromFrame() 569 void DocumentLoader::detachFromFrame()
570 { 570 {
571 ASSERT(m_frame); 571 DCHECK(m_frame);
572 572
573 // It never makes sense to have a document loader that is detached from its 573 // It never makes sense to have a document loader that is detached from its
574 // frame have any loads active, so go ahead and kill all the loads. 574 // frame have any loads active, so go ahead and kill all the loads.
575 m_fetcher->stopFetching(); 575 m_fetcher->stopFetching();
576 576
577 // If that load cancellation triggered another detach, leave. 577 // If that load cancellation triggered another detach, leave.
578 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.) 578 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.)
579 if (!m_frame) 579 if (!m_frame)
580 return; 580 return;
581 581
(...skipping 12 matching lines...) Expand all
594 m_mainResource->removeClient(this); 594 m_mainResource->removeClient(this);
595 m_mainResource = nullptr; 595 m_mainResource = nullptr;
596 } 596 }
597 597
598 bool DocumentLoader::maybeCreateArchive() 598 bool DocumentLoader::maybeCreateArchive()
599 { 599 {
600 // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. 600 // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0.
601 if (!isArchiveMIMEType(m_response.mimeType())) 601 if (!isArchiveMIMEType(m_response.mimeType()))
602 return false; 602 return false;
603 603
604 ASSERT(m_mainResource); 604 DCHECK(m_mainResource);
605 ArchiveResource* mainResource = m_fetcher->createArchive(m_mainResource.get( )); 605 ArchiveResource* mainResource = m_fetcher->createArchive(m_mainResource.get( ));
606 if (!mainResource) 606 if (!mainResource)
607 return false; 607 return false;
608 // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so 608 // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so
609 // relative URLs are resolved properly. 609 // relative URLs are resolved properly.
610 ensureWriter(mainResource->mimeType(), mainResource->url()); 610 ensureWriter(mainResource->mimeType(), mainResource->url());
611 611
612 // The Document has now been created. 612 // The Document has now been created.
613 m_frame->document()->enforceSandboxFlags(SandboxAll); 613 m_frame->document()->enforceSandboxFlags(SandboxAll);
614 614
(...skipping 20 matching lines...) Expand all
635 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument()) 635 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument())
636 m_request.setURL(blankURL()); 636 m_request.setURL(blankURL());
637 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing()); 637 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing());
638 finishedLoading(monotonicallyIncreasingTime()); 638 finishedLoading(monotonicallyIncreasingTime());
639 return true; 639 return true;
640 } 640 }
641 641
642 void DocumentLoader::startLoadingMainResource() 642 void DocumentLoader::startLoadingMainResource()
643 { 643 {
644 timing().markNavigationStart(); 644 timing().markNavigationStart();
645 ASSERT(!m_mainResource); 645 DCHECK(!m_mainResource);
646 ASSERT(m_state == NotStarted); 646 DCHECK_EQ(m_state, NotStarted);
647 m_state = Provisional; 647 m_state = Provisional;
648 648
649 if (maybeLoadEmpty()) 649 if (maybeLoadEmpty())
650 return; 650 return;
651 651
652 ASSERT(timing().navigationStart()); 652 DCHECK(timing().navigationStart());
653 653
654 // PlzNavigate: 654 // PlzNavigate:
655 // The fetch has already started in the browser. Don't mark it again. 655 // The fetch has already started in the browser. Don't mark it again.
656 if (!m_frame->settings()->browserSideNavigationEnabled()) { 656 if (!m_frame->settings()->browserSideNavigationEnabled()) {
657 DCHECK(!timing().fetchStart()); 657 DCHECK(!timing().fetchStart());
658 timing().markFetchStart(); 658 timing().markFetchStart();
659 } 659 }
660 660
661 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, 661 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
662 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext)); 662 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext));
663 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main ResourceLoadOptions); 663 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main ResourceLoadOptions);
664 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s ubstituteData); 664 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s ubstituteData);
665 if (!m_mainResource) { 665 if (!m_mainResource) {
666 m_request = ResourceRequest(blankURL()); 666 m_request = ResourceRequest(blankURL());
667 maybeLoadEmpty(); 667 maybeLoadEmpty();
668 return; 668 return;
669 } 669 }
670 // A bunch of headers are set when the underlying resource load begins, and m_request needs to include those. 670 // A bunch of headers are set when the underlying resource load begins, and m_request needs to include those.
671 // Even when using a cached resource, we may make some modification to the r equest, e.g. adding the referer header. 671 // Even when using a cached resource, we may make some modification to the r equest, e.g. adding the referer header.
672 m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest() : fetchRequest.resourceRequest(); 672 m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest() : fetchRequest.resourceRequest();
673 m_mainResource->addClient(this); 673 m_mainResource->addClient(this);
674 } 674 }
675 675
676 void DocumentLoader::endWriting(DocumentWriter* writer) 676 void DocumentLoader::endWriting(DocumentWriter* writer)
677 { 677 {
678 ASSERT_UNUSED(writer, m_writer == writer); 678 DCHECK_EQ(m_writer, writer);
679 m_writer->end(); 679 m_writer->end();
680 m_writer.clear(); 680 m_writer.clear();
681 } 681 }
682 682
683 DocumentWriter* DocumentLoader::createWriterFor(const DocumentInit& init, const AtomicString& mimeType, const AtomicString& encoding, bool dispatchWindowObjectA vailable, ParserSynchronizationPolicy parsingPolicy, const KURL& overridingURL) 683 DocumentWriter* DocumentLoader::createWriterFor(const DocumentInit& init, const AtomicString& mimeType, const AtomicString& encoding, bool dispatchWindowObjectA vailable, ParserSynchronizationPolicy parsingPolicy, const KURL& overridingURL)
684 { 684 {
685 LocalFrame* frame = init.frame(); 685 LocalFrame* frame = init.frame();
686 686
687 ASSERT(!frame->document() || !frame->document()->isActive()); 687 DCHECK(!frame->document() || !frame->document()->isActive());
688 ASSERT(frame->tree().childCount() == 0); 688 DCHECK_EQ(frame->tree().childCount(), 0u);
689 689
690 if (!init.shouldReuseDefaultView()) 690 if (!init.shouldReuseDefaultView())
691 frame->setDOMWindow(LocalDOMWindow::create(*frame)); 691 frame->setDOMWindow(LocalDOMWindow::create(*frame));
692 692
693 Document* document = frame->localDOMWindow()->installNewDocument(mimeType, i nit); 693 Document* document = frame->localDOMWindow()->installNewDocument(mimeType, i nit);
694 694
695 // This should be set before receivedFirstData(). 695 // This should be set before receivedFirstData().
696 if (!overridingURL.isEmpty()) 696 if (!overridingURL.isEmpty())
697 frame->document()->setBaseURLOverride(overridingURL); 697 frame->document()->setBaseURLOverride(overridingURL);
698 698
(...skipping 21 matching lines...) Expand all
720 { 720 {
721 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing); 721 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing);
722 if (!source.isNull()) 722 if (!source.isNull())
723 m_writer->appendReplacingData(source); 723 m_writer->appendReplacingData(source);
724 endWriting(m_writer.get()); 724 endWriting(m_writer.get());
725 } 725 }
726 726
727 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 727 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
728 728
729 } // namespace blink 729 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698