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

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

Issue 2556053002: Clarify when DocumentLoader's FrameLoader/FrameLoaderClient accessors can be used (Closed)
Patch Set: Rebase and comment fix Created 4 years 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 m_replacesCurrentHistoryItem(false), 108 m_replacesCurrentHistoryItem(false),
109 m_dataReceived(false), 109 m_dataReceived(false),
110 m_navigationType(NavigationTypeOther), 110 m_navigationType(NavigationTypeOther),
111 m_documentLoadTiming(*this), 111 m_documentLoadTiming(*this),
112 m_timeOfLastDataReceived(0.0), 112 m_timeOfLastDataReceived(0.0),
113 m_applicationCacheHost(ApplicationCacheHost::create(this)), 113 m_applicationCacheHost(ApplicationCacheHost::create(this)),
114 m_wasBlockedAfterXFrameOptionsOrCSP(false), 114 m_wasBlockedAfterXFrameOptionsOrCSP(false),
115 m_state(NotStarted), 115 m_state(NotStarted),
116 m_inDataReceived(false), 116 m_inDataReceived(false),
117 m_dataBuffer(SharedBuffer::create()) { 117 m_dataBuffer(SharedBuffer::create()) {
118 DCHECK(m_frame);
119
118 // The document URL needs to be added to the head of the list as that is 120 // The document URL needs to be added to the head of the list as that is
119 // where the redirects originated. 121 // where the redirects originated.
120 if (m_isClientRedirect) 122 if (m_isClientRedirect)
121 appendRedirect(m_frame->document()->url()); 123 appendRedirect(m_frame->document()->url());
122 } 124 }
123 125
124 FrameLoader* DocumentLoader::frameLoader() const { 126 FrameLoader& DocumentLoader::frameLoader() const {
125 if (!m_frame) 127 DCHECK(m_frame);
126 return nullptr; 128 return m_frame->loader();
127 return &m_frame->loader(); 129 }
130
131 FrameLoaderClient* DocumentLoader::frameLoaderClient() const {
132 DCHECK(m_frame);
133 FrameLoaderClient* client = m_frame->client();
134 // LocalFrame clears its |m_client| only after detaching all DocumentLoaders
135 // (i.e. calls detachFromFrame() which clears |m_frame|) owned by the
136 // LocalFrame's FrameLoader. So, if |m_frame| is non nullptr, |client| is
137 // also non nullptr.
138 DCHECK(client);
139 return client;
128 } 140 }
129 141
130 DocumentLoader::~DocumentLoader() { 142 DocumentLoader::~DocumentLoader() {
131 DCHECK(!m_frame); 143 DCHECK(!m_frame);
132 DCHECK(!m_mainResource); 144 DCHECK(!m_mainResource);
133 DCHECK(!m_applicationCacheHost); 145 DCHECK(!m_applicationCacheHost);
134 } 146 }
135 147
136 DEFINE_TRACE(DocumentLoader) { 148 DEFINE_TRACE(DocumentLoader) {
137 visitor->trace(m_frame); 149 visitor->trace(m_frame);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 fetcher()->preloadStarted(resource); 224 fetcher()->preloadStarted(resource);
213 return resource; 225 return resource;
214 } 226 }
215 227
216 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) { 228 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) {
217 timing().addRedirect(oldURL, newURL); 229 timing().addRedirect(oldURL, newURL);
218 230
219 // If a redirection happens during a back/forward navigation, don't restore 231 // If a redirection happens during a back/forward navigation, don't restore
220 // any state from the old HistoryItem. There is a provisional history item for 232 // any state from the old HistoryItem. There is a provisional history item for
221 // back/forward navigation only. In the other case, clearing it is a no-op. 233 // back/forward navigation only. In the other case, clearing it is a no-op.
222 DCHECK(frameLoader()); 234 frameLoader().clearProvisionalHistoryItem();
223 frameLoader()->clearProvisionalHistoryItem();
224 } 235 }
225 236
226 void DocumentLoader::dispatchLinkHeaderPreloads( 237 void DocumentLoader::dispatchLinkHeaderPreloads(
227 ViewportDescriptionWrapper* viewport, 238 ViewportDescriptionWrapper* viewport,
228 LinkLoader::MediaPreloadPolicy mediaPolicy) { 239 LinkLoader::MediaPreloadPolicy mediaPolicy) {
229 LinkLoader::loadLinksFromHeader( 240 LinkLoader::loadLinksFromHeader(
230 response().httpHeaderField(HTTPNames::Link), response().url(), 241 response().httpHeaderField(HTTPNames::Link), response().url(),
231 m_frame->document(), NetworkHintsInterfaceImpl(), 242 m_frame->document(), NetworkHintsInterfaceImpl(),
232 LinkLoader::OnlyLoadResources, mediaPolicy, viewport); 243 LinkLoader::OnlyLoadResources, mediaPolicy, viewport);
233 } 244 }
234 245
235 void DocumentLoader::didChangePerformanceTiming() { 246 void DocumentLoader::didChangePerformanceTiming() {
236 if (frame() && frame()->isMainFrame() && m_state >= Committed) { 247 if (m_frame && m_frame->isMainFrame() && m_state >= Committed) {
237 frameLoader()->client()->didChangePerformanceTiming(); 248 frameLoaderClient()->didChangePerformanceTiming();
238 } 249 }
239 } 250 }
240 251
241 void DocumentLoader::didObserveLoadingBehavior( 252 void DocumentLoader::didObserveLoadingBehavior(
242 WebLoadingBehaviorFlag behavior) { 253 WebLoadingBehaviorFlag behavior) {
243 if (frame() && frame()->isMainFrame()) { 254 if (m_frame && m_frame->isMainFrame()) {
244 DCHECK_GE(m_state, Committed); 255 DCHECK_GE(m_state, Committed);
245 frameLoader()->client()->didObserveLoadingBehavior(behavior); 256 frameLoaderClient()->didObserveLoadingBehavior(behavior);
246 } 257 }
247 } 258 }
248 259
249 void DocumentLoader::updateForSameDocumentNavigation( 260 void DocumentLoader::updateForSameDocumentNavigation(
250 const KURL& newURL, 261 const KURL& newURL,
251 SameDocumentNavigationSource sameDocumentNavigationSource) { 262 SameDocumentNavigationSource sameDocumentNavigationSource) {
252 KURL oldURL = m_request.url(); 263 KURL oldURL = m_request.url();
253 m_originalRequest.setURL(newURL); 264 m_originalRequest.setURL(newURL);
254 m_request.setURL(newURL); 265 m_request.setURL(newURL);
255 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { 266 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) {
256 m_request.setHTTPMethod(HTTPNames::GET); 267 m_request.setHTTPMethod(HTTPNames::GET);
257 m_request.setHTTPBody(nullptr); 268 m_request.setHTTPBody(nullptr);
258 } 269 }
259 clearRedirectChain(); 270 clearRedirectChain();
260 if (m_isClientRedirect) 271 if (m_isClientRedirect)
261 appendRedirect(oldURL); 272 appendRedirect(oldURL);
262 appendRedirect(newURL); 273 appendRedirect(newURL);
263 } 274 }
264 275
265 const KURL& DocumentLoader::urlForHistory() const { 276 const KURL& DocumentLoader::urlForHistory() const {
266 return unreachableURL().isEmpty() ? url() : unreachableURL(); 277 return unreachableURL().isEmpty() ? url() : unreachableURL();
267 } 278 }
268 279
269 void DocumentLoader::commitIfReady() { 280 void DocumentLoader::commitIfReady() {
270 if (m_state < Committed) { 281 if (m_state < Committed) {
271 m_state = Committed; 282 m_state = Committed;
272 frameLoader()->commitProvisionalLoad(); 283 frameLoader().commitProvisionalLoad();
273 } 284 }
274 } 285 }
275 286
276 void DocumentLoader::notifyFinished(Resource* resource) { 287 void DocumentLoader::notifyFinished(Resource* resource) {
277 DCHECK_EQ(m_mainResource, resource); 288 DCHECK_EQ(m_mainResource, resource);
278 DCHECK(m_mainResource); 289 DCHECK(m_mainResource);
279 290
280 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { 291 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
281 finishedLoading(m_mainResource->loadFinishTime()); 292 finishedLoading(m_mainResource->loadFinishTime());
282 return; 293 return;
283 } 294 }
284 295
285 if (m_applicationCacheHost) 296 if (m_applicationCacheHost)
286 m_applicationCacheHost->failedLoadingMainResource(); 297 m_applicationCacheHost->failedLoadingMainResource();
287 m_state = MainResourceDone; 298 m_state = MainResourceDone;
288 frameLoader()->loadFailed(this, m_mainResource->resourceError()); 299 frameLoader().loadFailed(this, m_mainResource->resourceError());
289 clearMainResourceHandle(); 300 clearMainResourceHandle();
290 } 301 }
291 302
292 void DocumentLoader::finishedLoading(double finishTime) { 303 void DocumentLoader::finishedLoading(double finishTime) {
293 DCHECK(m_frame->loader().stateMachine()->creatingInitialEmptyDocument() || 304 DCHECK(m_frame->loader().stateMachine()->creatingInitialEmptyDocument() ||
294 !m_frame->page()->suspended() || 305 !m_frame->page()->suspended() ||
295 InspectorInstrumentation::isDebuggerPaused(m_frame)); 306 InspectorInstrumentation::isDebuggerPaused(m_frame));
296 307
297 double responseEndTime = finishTime; 308 double responseEndTime = finishTime;
298 if (!responseEndTime) 309 if (!responseEndTime)
299 responseEndTime = m_timeOfLastDataReceived; 310 responseEndTime = m_timeOfLastDataReceived;
300 if (!responseEndTime) 311 if (!responseEndTime)
301 responseEndTime = monotonicallyIncreasingTime(); 312 responseEndTime = monotonicallyIncreasingTime();
302 timing().setResponseEnd(responseEndTime); 313 timing().setResponseEnd(responseEndTime);
303 314
304 commitIfReady(); 315 commitIfReady();
305 if (!frameLoader()) 316 if (!m_frame)
306 return; 317 return;
307 318
308 if (!maybeCreateArchive()) { 319 if (!maybeCreateArchive()) {
309 // If this is an empty document, it will not have actually been created yet. 320 // If this is an empty document, it will not have actually been created yet.
310 // Commit dummy data so that DocumentWriter::begin() gets called and creates 321 // Commit dummy data so that DocumentWriter::begin() gets called and creates
311 // the Document. 322 // the Document.
312 if (!m_writer) 323 if (!m_writer)
313 commitData(0, 0); 324 commitData(0, 0);
314 } 325 }
315 326
316 if (!m_frame) 327 if (!m_frame)
317 return; 328 return;
318 329
319 m_applicationCacheHost->finishedLoadingMainResource(); 330 m_applicationCacheHost->finishedLoadingMainResource();
320 endWriting(); 331 endWriting();
321 if (m_state < MainResourceDone) 332 if (m_state < MainResourceDone)
322 m_state = MainResourceDone; 333 m_state = MainResourceDone;
323 clearMainResourceHandle(); 334 clearMainResourceHandle();
324 } 335 }
325 336
326 bool DocumentLoader::redirectReceived( 337 bool DocumentLoader::redirectReceived(
327 Resource* resource, 338 Resource* resource,
328 const ResourceRequest& request, 339 const ResourceRequest& request,
329 const ResourceResponse& redirectResponse) { 340 const ResourceResponse& redirectResponse) {
341 DCHECK(m_frame);
330 DCHECK_EQ(resource, m_mainResource); 342 DCHECK_EQ(resource, m_mainResource);
331 DCHECK(!redirectResponse.isNull()); 343 DCHECK(!redirectResponse.isNull());
332 m_request = request; 344 m_request = request;
333 345
334 // If the redirecting url is not allowed to display content from the target 346 // If the redirecting url is not allowed to display content from the target
335 // origin, then block the redirect. 347 // origin, then block the redirect.
336 const KURL& requestURL = m_request.url(); 348 const KURL& requestURL = m_request.url();
337 RefPtr<SecurityOrigin> redirectingOrigin = 349 RefPtr<SecurityOrigin> redirectingOrigin =
338 SecurityOrigin::create(redirectResponse.url()); 350 SecurityOrigin::create(redirectResponse.url());
339 if (!redirectingOrigin->canDisplay(requestURL)) { 351 if (!redirectingOrigin->canDisplay(requestURL)) {
340 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString()); 352 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString());
341 m_fetcher->stopFetching(); 353 m_fetcher->stopFetching();
342 return false; 354 return false;
343 } 355 }
344 if (!frameLoader()->shouldContinueForNavigationPolicy( 356 if (!frameLoader().shouldContinueForNavigationPolicy(
345 m_request, SubstituteData(), this, CheckContentSecurityPolicy, 357 m_request, SubstituteData(), this, CheckContentSecurityPolicy,
346 m_navigationType, NavigationPolicyCurrentTab, 358 m_navigationType, NavigationPolicyCurrentTab,
347 replacesCurrentHistoryItem(), isClientRedirect(), nullptr)) { 359 replacesCurrentHistoryItem(), isClientRedirect(), nullptr)) {
348 m_fetcher->stopFetching(); 360 m_fetcher->stopFetching();
349 return false; 361 return false;
350 } 362 }
351 363
352 DCHECK(timing().fetchStart()); 364 DCHECK(timing().fetchStart());
353 appendRedirect(requestURL); 365 appendRedirect(requestURL);
354 didRedirect(redirectResponse.url(), requestURL); 366 didRedirect(redirectResponse.url(), requestURL);
355 frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad(); 367 frameLoaderClient()->dispatchDidReceiveServerRedirectForProvisionalLoad();
356 368
357 return true; 369 return true;
358 } 370 }
359 371
360 static bool canShowMIMEType(const String& mimeType, LocalFrame* frame) { 372 static bool canShowMIMEType(const String& mimeType, LocalFrame* frame) {
361 if (MIMETypeRegistry::isSupportedMIMEType(mimeType)) 373 if (MIMETypeRegistry::isSupportedMIMEType(mimeType))
362 return true; 374 return true;
363 PluginData* pluginData = frame->pluginData(); 375 PluginData* pluginData = frame->pluginData();
364 return !mimeType.isEmpty() && pluginData && 376 return !mimeType.isEmpty() && pluginData &&
365 pluginData->supportsMimeType(mimeType); 377 pluginData->supportsMimeType(mimeType);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 424
413 return; 425 return;
414 } 426 }
415 427
416 void DocumentLoader::responseReceived( 428 void DocumentLoader::responseReceived(
417 Resource* resource, 429 Resource* resource,
418 const ResourceResponse& response, 430 const ResourceResponse& response,
419 std::unique_ptr<WebDataConsumerHandle> handle) { 431 std::unique_ptr<WebDataConsumerHandle> handle) {
420 DCHECK_EQ(m_mainResource, resource); 432 DCHECK_EQ(m_mainResource, resource);
421 DCHECK(!handle); 433 DCHECK(!handle);
422 DCHECK(frame()); 434 DCHECK(m_frame);
423 435
424 m_applicationCacheHost->didReceiveResponseForMainResource(response); 436 m_applicationCacheHost->didReceiveResponseForMainResource(response);
425 437
426 // The memory cache doesn't understand the application cache or its caching 438 // The memory cache doesn't understand the application cache or its caching
427 // rules. So if a main resource is served from the application cache, ensure 439 // rules. So if a main resource is served from the application cache, ensure
428 // we don't save the result for future use. All responses loaded from appcache 440 // we don't save the result for future use. All responses loaded from appcache
429 // will have a non-zero appCacheID(). 441 // will have a non-zero appCacheID().
430 if (response.appCacheID()) 442 if (response.appCacheID())
431 memoryCache()->remove(m_mainResource.get()); 443 memoryCache()->remove(m_mainResource.get());
432 444
433 m_contentSecurityPolicy = ContentSecurityPolicy::create(); 445 m_contentSecurityPolicy = ContentSecurityPolicy::create();
434 m_contentSecurityPolicy->setOverrideURLForSelf(response.url()); 446 m_contentSecurityPolicy->setOverrideURLForSelf(response.url());
435 m_contentSecurityPolicy->didReceiveHeaders( 447 m_contentSecurityPolicy->didReceiveHeaders(
436 ContentSecurityPolicyResponseHeaders(response)); 448 ContentSecurityPolicyResponseHeaders(response));
437 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) { 449 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) {
438 cancelLoadAfterXFrameOptionsOrCSPDenied(response); 450 cancelLoadAfterXFrameOptionsOrCSPDenied(response);
439 return; 451 return;
440 } 452 }
441 453
442 // 'frame-ancestors' obviates 'x-frame-options': 454 // 'frame-ancestors' obviates 'x-frame-options':
443 // https://w3c.github.io/webappsec/specs/content-security-policy/#frame-ancest ors-and-frame-options 455 // https://w3c.github.io/webappsec/specs/content-security-policy/#frame-ancest ors-and-frame-options
444 if (!m_contentSecurityPolicy->isFrameAncestorsEnforced()) { 456 if (!m_contentSecurityPolicy->isFrameAncestorsEnforced()) {
445 HTTPHeaderMap::const_iterator it = 457 HTTPHeaderMap::const_iterator it =
446 response.httpHeaderFields().find(HTTPNames::X_Frame_Options); 458 response.httpHeaderFields().find(HTTPNames::X_Frame_Options);
447 if (it != response.httpHeaderFields().end()) { 459 if (it != response.httpHeaderFields().end()) {
448 String content = it->value; 460 String content = it->value;
449 if (frameLoader()->shouldInterruptLoadForXFrameOptions( 461 if (frameLoader().shouldInterruptLoadForXFrameOptions(
450 content, response.url(), mainResourceIdentifier())) { 462 content, response.url(), mainResourceIdentifier())) {
451 String message = "Refused to display '" + 463 String message = "Refused to display '" +
452 response.url().elidedString() + 464 response.url().elidedString() +
453 "' in a frame because it set 'X-Frame-Options' to '" + 465 "' in a frame because it set 'X-Frame-Options' to '" +
454 content + "'."; 466 content + "'.";
455 ConsoleMessage* consoleMessage = ConsoleMessage::createForRequest( 467 ConsoleMessage* consoleMessage = ConsoleMessage::createForRequest(
456 SecurityMessageSource, ErrorMessageLevel, message, response.url(), 468 SecurityMessageSource, ErrorMessageLevel, message, response.url(),
457 mainResourceIdentifier()); 469 mainResourceIdentifier());
458 frame()->document()->addConsoleMessage(consoleMessage); 470 m_frame->document()->addConsoleMessage(consoleMessage);
459 471
460 cancelLoadAfterXFrameOptionsOrCSPDenied(response); 472 cancelLoadAfterXFrameOptionsOrCSPDenied(response);
461 return; 473 return;
462 } 474 }
463 } 475 }
464 } 476 }
465 477
466 if (RuntimeEnabledFeatures::embedderCSPEnforcementEnabled() && 478 if (RuntimeEnabledFeatures::embedderCSPEnforcementEnabled() &&
467 !frameLoader()->requiredCSP().isEmpty()) { 479 !frameLoader().requiredCSP().isEmpty()) {
468 SecurityOrigin* parentSecurityOrigin = 480 SecurityOrigin* parentSecurityOrigin =
469 frame()->tree().parent()->securityContext()->getSecurityOrigin(); 481 m_frame->tree().parent()->securityContext()->getSecurityOrigin();
470 if (ContentSecurityPolicy::shouldEnforceEmbeddersPolicy( 482 if (ContentSecurityPolicy::shouldEnforceEmbeddersPolicy(
471 response, parentSecurityOrigin)) { 483 response, parentSecurityOrigin)) {
472 m_contentSecurityPolicy->addPolicyFromHeaderValue( 484 m_contentSecurityPolicy->addPolicyFromHeaderValue(
473 frameLoader()->requiredCSP(), ContentSecurityPolicyHeaderTypeEnforce, 485 frameLoader().requiredCSP(), ContentSecurityPolicyHeaderTypeEnforce,
474 ContentSecurityPolicyHeaderSourceHTTP); 486 ContentSecurityPolicyHeaderSourceHTTP);
475 } else { 487 } else {
476 ContentSecurityPolicy* embeddingCSP = ContentSecurityPolicy::create(); 488 ContentSecurityPolicy* embeddingCSP = ContentSecurityPolicy::create();
477 embeddingCSP->addPolicyFromHeaderValue( 489 embeddingCSP->addPolicyFromHeaderValue(
478 frameLoader()->requiredCSP(), ContentSecurityPolicyHeaderTypeEnforce, 490 frameLoader().requiredCSP(), ContentSecurityPolicyHeaderTypeEnforce,
479 ContentSecurityPolicyHeaderSourceHTTP); 491 ContentSecurityPolicyHeaderSourceHTTP);
480 if (!embeddingCSP->subsumes(*m_contentSecurityPolicy)) { 492 if (!embeddingCSP->subsumes(*m_contentSecurityPolicy)) {
481 String message = "Refused to display '" + 493 String message = "Refused to display '" +
482 response.url().elidedString() + 494 response.url().elidedString() +
483 "' because it has not opted-into the following policy " 495 "' because it has not opted-into the following policy "
484 "required by its embedder: '" + 496 "required by its embedder: '" +
485 frameLoader()->requiredCSP() + "'."; 497 frameLoader().requiredCSP() + "'.";
486 ConsoleMessage* consoleMessage = ConsoleMessage::createForRequest( 498 ConsoleMessage* consoleMessage = ConsoleMessage::createForRequest(
487 SecurityMessageSource, ErrorMessageLevel, message, response.url(), 499 SecurityMessageSource, ErrorMessageLevel, message, response.url(),
488 mainResourceIdentifier()); 500 mainResourceIdentifier());
489 frame()->document()->addConsoleMessage(consoleMessage); 501 m_frame->document()->addConsoleMessage(consoleMessage);
490 cancelLoadAfterXFrameOptionsOrCSPDenied(response); 502 cancelLoadAfterXFrameOptionsOrCSPDenied(response);
491 return; 503 return;
492 } 504 }
493 } 505 }
494 } 506 }
495 507
496 DCHECK(!m_frame->page()->suspended()); 508 DCHECK(!m_frame->page()->suspended());
497 509
498 m_response = response; 510 m_response = response;
499 511
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 m_dataBuffer->clear(); 616 m_dataBuffer->clear();
605 } 617 }
606 618
607 void DocumentLoader::processData(const char* data, size_t length) { 619 void DocumentLoader::processData(const char* data, size_t length) {
608 m_applicationCacheHost->mainResourceDataReceived(data, length); 620 m_applicationCacheHost->mainResourceDataReceived(data, length);
609 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); 621 m_timeOfLastDataReceived = monotonicallyIncreasingTime();
610 622
611 if (isArchiveMIMEType(response().mimeType())) 623 if (isArchiveMIMEType(response().mimeType()))
612 return; 624 return;
613 commitIfReady(); 625 commitIfReady();
614 if (!frameLoader()) 626 if (!m_frame)
615 return; 627 return;
616 commitData(data, length); 628 commitData(data, length);
617 629
618 // If we are sending data to MediaDocument, we should stop here and cancel the 630 // If we are sending data to MediaDocument, we should stop here and cancel the
619 // request. 631 // request.
620 if (m_frame && m_frame->document()->isMediaDocument()) 632 if (m_frame && m_frame->document()->isMediaDocument())
621 m_fetcher->stopFetching(); 633 m_fetcher->stopFetching();
622 } 634 }
623 635
624 void DocumentLoader::clearRedirectChain() { 636 void DocumentLoader::clearRedirectChain() {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 700
689 bool DocumentLoader::maybeLoadEmpty() { 701 bool DocumentLoader::maybeLoadEmpty() {
690 bool shouldLoadEmpty = !m_substituteData.isValid() && 702 bool shouldLoadEmpty = !m_substituteData.isValid() &&
691 (m_request.url().isEmpty() || 703 (m_request.url().isEmpty() ||
692 SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument( 704 SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(
693 m_request.url().protocol())); 705 m_request.url().protocol()));
694 if (!shouldLoadEmpty) 706 if (!shouldLoadEmpty)
695 return false; 707 return false;
696 708
697 if (m_request.url().isEmpty() && 709 if (m_request.url().isEmpty() &&
698 !frameLoader()->stateMachine()->creatingInitialEmptyDocument()) 710 !frameLoader().stateMachine()->creatingInitialEmptyDocument())
699 m_request.setURL(blankURL()); 711 m_request.setURL(blankURL());
700 m_response = 712 m_response =
701 ResourceResponse(m_request.url(), "text/html", 0, nullAtom, String()); 713 ResourceResponse(m_request.url(), "text/html", 0, nullAtom, String());
702 finishedLoading(monotonicallyIncreasingTime()); 714 finishedLoading(monotonicallyIncreasingTime());
703 return true; 715 return true;
704 } 716 }
705 717
706 void DocumentLoader::startLoadingMainResource() { 718 void DocumentLoader::startLoadingMainResource() {
707 timing().markNavigationStart(); 719 timing().markNavigationStart();
708 DCHECK(!m_mainResource); 720 DCHECK(!m_mainResource);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 m_writer ? m_writer->encoding() : emptyAtom, true, 816 m_writer ? m_writer->encoding() : emptyAtom, true,
805 ForceSynchronousParsing); 817 ForceSynchronousParsing);
806 if (!source.isNull()) 818 if (!source.isNull())
807 m_writer->appendReplacingData(source); 819 m_writer->appendReplacingData(source);
808 endWriting(); 820 endWriting();
809 } 821 }
810 822
811 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 823 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
812 824
813 } // namespace blink 825 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698