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

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

Issue 1853743005: Oilpan: Remove WillBe types (part 13) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return m_request; 159 return m_request;
160 } 160 }
161 161
162 const KURL& DocumentLoader::url() const 162 const KURL& DocumentLoader::url() const
163 { 163 {
164 return m_request.url(); 164 return m_request.url();
165 } 165 }
166 166
167 Resource* DocumentLoader::startPreload(Resource::Type type, FetchRequest& reques t) 167 Resource* DocumentLoader::startPreload(Resource::Type type, FetchRequest& reques t)
168 { 168 {
169 RefPtrWillBeRawPtr<Resource> resource = nullptr; 169 RawPtr<Resource> resource = nullptr;
170 switch (type) { 170 switch (type) {
171 case Resource::Image: 171 case Resource::Image:
172 resource = ImageResource::fetch(request, fetcher()); 172 resource = ImageResource::fetch(request, fetcher());
173 break; 173 break;
174 case Resource::Script: 174 case Resource::Script:
175 resource = ScriptResource::fetch(request, fetcher()); 175 resource = ScriptResource::fetch(request, fetcher());
176 break; 176 break;
177 case Resource::CSSStyleSheet: 177 case Resource::CSSStyleSheet:
178 resource = CSSStyleSheetResource::fetch(request, fetcher()); 178 resource = CSSStyleSheetResource::fetch(request, fetcher());
179 break; 179 break;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 m_state = Committed; 236 m_state = Committed;
237 frameLoader()->commitProvisionalLoad(); 237 frameLoader()->commitProvisionalLoad();
238 } 238 }
239 } 239 }
240 240
241 void DocumentLoader::notifyFinished(Resource* resource) 241 void DocumentLoader::notifyFinished(Resource* resource)
242 { 242 {
243 ASSERT_UNUSED(resource, m_mainResource == resource); 243 ASSERT_UNUSED(resource, m_mainResource == resource);
244 ASSERT(m_mainResource); 244 ASSERT(m_mainResource);
245 245
246 RefPtrWillBeRawPtr<DocumentLoader> protect(this); 246 RawPtr<DocumentLoader> protect(this);
247 247
248 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { 248 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
249 finishedLoading(m_mainResource->loadFinishTime()); 249 finishedLoading(m_mainResource->loadFinishTime());
250 return; 250 return;
251 } 251 }
252 252
253 if (m_applicationCacheHost) 253 if (m_applicationCacheHost)
254 m_applicationCacheHost->failedLoadingMainResource(); 254 m_applicationCacheHost->failedLoadingMainResource();
255 m_state = MainResourceDone; 255 m_state = MainResourceDone;
256 frameLoader()->loadFailed(this, m_mainResource->resourceError()); 256 frameLoader()->loadFailed(this, m_mainResource->resourceError());
257 clearMainResourceHandle(); 257 clearMainResourceHandle();
258 } 258 }
259 259
260 void DocumentLoader::finishedLoading(double finishTime) 260 void DocumentLoader::finishedLoading(double finishTime)
261 { 261 {
262 ASSERT(!m_frame->page()->defersLoading() || InspectorInstrumentation::isDebu ggerPaused(m_frame)); 262 ASSERT(!m_frame->page()->defersLoading() || InspectorInstrumentation::isDebu ggerPaused(m_frame));
263 263
264 RefPtrWillBeRawPtr<DocumentLoader> protect(this); 264 RawPtr<DocumentLoader> protect(this);
265 265
266 double responseEndTime = finishTime; 266 double responseEndTime = finishTime;
267 if (!responseEndTime) 267 if (!responseEndTime)
268 responseEndTime = m_timeOfLastDataReceived; 268 responseEndTime = m_timeOfLastDataReceived;
269 if (!responseEndTime) 269 if (!responseEndTime)
270 responseEndTime = monotonicallyIncreasingTime(); 270 responseEndTime = monotonicallyIncreasingTime();
271 timing().setResponseEnd(responseEndTime); 271 timing().setResponseEnd(responseEndTime);
272 272
273 commitIfReady(); 273 commitIfReady();
274 if (!frameLoader()) 274 if (!frameLoader())
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 m_response = ResourceResponse(blankURL(), "text/html", 0, nullAtom, String() ); 359 m_response = ResourceResponse(blankURL(), "text/html", 0, nullAtom, String() );
360 finishedLoading(monotonicallyIncreasingTime()); 360 finishedLoading(monotonicallyIncreasingTime());
361 361
362 return; 362 return;
363 } 363 }
364 364
365 void DocumentLoader::responseReceived(Resource* resource, const ResourceResponse & response, PassOwnPtr<WebDataConsumerHandle> handle) 365 void DocumentLoader::responseReceived(Resource* resource, const ResourceResponse & response, PassOwnPtr<WebDataConsumerHandle> handle)
366 { 366 {
367 ASSERT_UNUSED(resource, m_mainResource == resource); 367 ASSERT_UNUSED(resource, m_mainResource == resource);
368 ASSERT_UNUSED(handle, !handle); 368 ASSERT_UNUSED(handle, !handle);
369 RefPtrWillBeRawPtr<DocumentLoader> protect(this); 369 RawPtr<DocumentLoader> protect(this);
370 ASSERT(frame()); 370 ASSERT(frame());
371 371
372 m_applicationCacheHost->didReceiveResponseForMainResource(response); 372 m_applicationCacheHost->didReceiveResponseForMainResource(response);
373 373
374 // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served 374 // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served
375 // from the application cache, ensure we don't save the result for future us e. All responses loaded 375 // from the application cache, ensure we don't save the result for future us e. All responses loaded
376 // from appcache will have a non-zero appCacheID(). 376 // from appcache will have a non-zero appCacheID().
377 if (response.appCacheID()) 377 if (response.appCacheID())
378 memoryCache()->remove(m_mainResource.get()); 378 memoryCache()->remove(m_mainResource.get());
379 379
380 m_contentSecurityPolicy = ContentSecurityPolicy::create(); 380 m_contentSecurityPolicy = ContentSecurityPolicy::create();
381 m_contentSecurityPolicy->setOverrideURLForSelf(response.url()); 381 m_contentSecurityPolicy->setOverrideURLForSelf(response.url());
382 m_contentSecurityPolicy->didReceiveHeaders(ContentSecurityPolicyResponseHead ers(response)); 382 m_contentSecurityPolicy->didReceiveHeaders(ContentSecurityPolicyResponseHead ers(response));
383 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) { 383 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) {
384 cancelLoadAfterXFrameOptionsOrCSPDenied(response); 384 cancelLoadAfterXFrameOptionsOrCSPDenied(response);
385 return; 385 return;
386 } 386 }
387 387
388 // 'frame-ancestors' obviates 'x-frame-options': https://w3c.github.io/webap psec/specs/content-security-policy/#frame-ancestors-and-frame-options 388 // 'frame-ancestors' obviates 'x-frame-options': https://w3c.github.io/webap psec/specs/content-security-policy/#frame-ancestors-and-frame-options
389 if (!m_contentSecurityPolicy->isFrameAncestorsEnforced()) { 389 if (!m_contentSecurityPolicy->isFrameAncestorsEnforced()) {
390 HTTPHeaderMap::const_iterator it = response.httpHeaderFields().find(HTTP Names::X_Frame_Options); 390 HTTPHeaderMap::const_iterator it = response.httpHeaderFields().find(HTTP Names::X_Frame_Options);
391 if (it != response.httpHeaderFields().end()) { 391 if (it != response.httpHeaderFields().end()) {
392 String content = it->value; 392 String content = it->value;
393 if (frameLoader()->shouldInterruptLoadForXFrameOptions(content, resp onse.url(), mainResourceIdentifier())) { 393 if (frameLoader()->shouldInterruptLoadForXFrameOptions(content, resp onse.url(), mainResourceIdentifier())) {
394 String message = "Refused to display '" + response.url().elidedS tring() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'."; 394 String message = "Refused to display '" + response.url().elidedS tring() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
395 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessa ge::create(SecurityMessageSource, ErrorMessageLevel, message); 395 RawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(S ecurityMessageSource, ErrorMessageLevel, message);
396 consoleMessage->setRequestIdentifier(mainResourceIdentifier()); 396 consoleMessage->setRequestIdentifier(mainResourceIdentifier());
397 frame()->document()->addConsoleMessage(consoleMessage.release()) ; 397 frame()->document()->addConsoleMessage(consoleMessage.release()) ;
398 398
399 cancelLoadAfterXFrameOptionsOrCSPDenied(response); 399 cancelLoadAfterXFrameOptionsOrCSPDenied(response);
400 return; 400 return;
401 } 401 }
402 } 402 }
403 } 403 }
404 404
405 ASSERT(!m_frame->page()->defersLoading()); 405 ASSERT(!m_frame->page()->defersLoading());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 // loop: 493 // loop:
494 // - alert(), confirm(), prompt() 494 // - alert(), confirm(), prompt()
495 // - Detach of plugin elements. 495 // - Detach of plugin elements.
496 // - Synchronous XMLHTTPRequest 496 // - Synchronous XMLHTTPRequest
497 m_dataBuffer->append(data, length); 497 m_dataBuffer->append(data, length);
498 return; 498 return;
499 } 499 }
500 500
501 // Both unloading the old page and parsing the new page may execute JavaScri pt which destroys the datasource 501 // Both unloading the old page and parsing the new page may execute JavaScri pt which destroys the datasource
502 // by starting a new load, so retain temporarily. 502 // by starting a new load, so retain temporarily.
503 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame.get()); 503 RawPtr<LocalFrame> protectFrame(m_frame.get());
504 RefPtrWillBeRawPtr<DocumentLoader> protectLoader(this); 504 RawPtr<DocumentLoader> protectLoader(this);
505 505
506 TemporaryChange<bool> reentrancyProtector(m_inDataReceived, true); 506 TemporaryChange<bool> reentrancyProtector(m_inDataReceived, true);
507 processData(data, length); 507 processData(data, length);
508 508
509 // Process data received in reentrant invocations. Note that the 509 // Process data received in reentrant invocations. Note that the
510 // invocations of processData() may queue more data in reentrant 510 // invocations of processData() may queue more data in reentrant
511 // invocations, so iterate until it's empty. 511 // invocations, so iterate until it's empty.
512 const char* segment; 512 const char* segment;
513 size_t pos = 0; 513 size_t pos = 0;
514 while (size_t length = m_dataBuffer->getSomeData(segment, pos)) { 514 while (size_t length = m_dataBuffer->getSomeData(segment, pos)) {
(...skipping 28 matching lines...) Expand all
543 } 543 }
544 544
545 void DocumentLoader::appendRedirect(const KURL& url) 545 void DocumentLoader::appendRedirect(const KURL& url)
546 { 546 {
547 m_redirectChain.append(url); 547 m_redirectChain.append(url);
548 } 548 }
549 549
550 void DocumentLoader::detachFromFrame() 550 void DocumentLoader::detachFromFrame()
551 { 551 {
552 ASSERT(m_frame); 552 ASSERT(m_frame);
553 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame.get()); 553 RawPtr<LocalFrame> protectFrame(m_frame.get());
554 RefPtrWillBeRawPtr<DocumentLoader> protectLoader(this); 554 RawPtr<DocumentLoader> protectLoader(this);
555 555
556 // It never makes sense to have a document loader that is detached from its 556 // It never makes sense to have a document loader that is detached from its
557 // frame have any loads active, so go ahead and kill all the loads. 557 // frame have any loads active, so go ahead and kill all the loads.
558 m_fetcher->stopFetching(); 558 m_fetcher->stopFetching();
559 559
560 // If that load cancellation triggered another detach, leave. 560 // If that load cancellation triggered another detach, leave.
561 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.) 561 // (fast/frames/detach-frame-nested-no-crash.html is an example of this.)
562 if (!m_frame) 562 if (!m_frame)
563 return; 563 return;
564 564
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 617
618 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument()) 618 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument())
619 m_request.setURL(blankURL()); 619 m_request.setURL(blankURL());
620 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing()); 620 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing());
621 finishedLoading(monotonicallyIncreasingTime()); 621 finishedLoading(monotonicallyIncreasingTime());
622 return true; 622 return true;
623 } 623 }
624 624
625 void DocumentLoader::startLoadingMainResource() 625 void DocumentLoader::startLoadingMainResource()
626 { 626 {
627 RefPtrWillBeRawPtr<DocumentLoader> protect(this); 627 RawPtr<DocumentLoader> protect(this);
628 timing().markNavigationStart(); 628 timing().markNavigationStart();
629 ASSERT(!m_mainResource); 629 ASSERT(!m_mainResource);
630 ASSERT(m_state == NotStarted); 630 ASSERT(m_state == NotStarted);
631 m_state = Provisional; 631 m_state = Provisional;
632 632
633 if (maybeLoadEmpty()) 633 if (maybeLoadEmpty())
634 return; 634 return;
635 635
636 ASSERT(timing().navigationStart()); 636 ASSERT(timing().navigationStart());
637 ASSERT(!timing().fetchStart()); 637 ASSERT(!timing().fetchStart());
(...skipping 26 matching lines...) Expand all
664 m_mainResource->addClient(this); 664 m_mainResource->addClient(this);
665 } 665 }
666 666
667 void DocumentLoader::endWriting(DocumentWriter* writer) 667 void DocumentLoader::endWriting(DocumentWriter* writer)
668 { 668 {
669 ASSERT_UNUSED(writer, m_writer == writer); 669 ASSERT_UNUSED(writer, m_writer == writer);
670 m_writer->end(); 670 m_writer->end();
671 m_writer.clear(); 671 m_writer.clear();
672 } 672 }
673 673
674 PassRefPtrWillBeRawPtr<DocumentWriter> DocumentLoader::createWriterFor(const Doc umentInit& init, const AtomicString& mimeType, const AtomicString& encoding, boo l dispatch, ParserSynchronizationPolicy parsingPolicy) 674 RawPtr<DocumentWriter> DocumentLoader::createWriterFor(const DocumentInit& init, const AtomicString& mimeType, const AtomicString& encoding, bool dispatch, Pars erSynchronizationPolicy parsingPolicy)
675 { 675 {
676 LocalFrame* frame = init.frame(); 676 LocalFrame* frame = init.frame();
677 677
678 ASSERT(!frame->document() || !frame->document()->isActive()); 678 ASSERT(!frame->document() || !frame->document()->isActive());
679 ASSERT(frame->tree().childCount() == 0); 679 ASSERT(frame->tree().childCount() == 0);
680 680
681 if (!init.shouldReuseDefaultView()) 681 if (!init.shouldReuseDefaultView())
682 frame->setDOMWindow(LocalDOMWindow::create(*frame)); 682 frame->setDOMWindow(LocalDOMWindow::create(*frame));
683 683
684 RefPtrWillBeRawPtr<Document> document = frame->localDOMWindow()->installNewD ocument(mimeType, init); 684 RawPtr<Document> document = frame->localDOMWindow()->installNewDocument(mime Type, init);
685 685
686 frame->loader().didBeginDocument(dispatch); 686 frame->loader().didBeginDocument(dispatch);
687 687
688 return DocumentWriter::create(document.get(), parsingPolicy, mimeType, encod ing); 688 return DocumentWriter::create(document.get(), parsingPolicy, mimeType, encod ing);
689 } 689 }
690 690
691 const AtomicString& DocumentLoader::mimeType() const 691 const AtomicString& DocumentLoader::mimeType() const
692 { 692 {
693 if (m_writer) 693 if (m_writer)
694 return m_writer->mimeType(); 694 return m_writer->mimeType();
695 return m_response.mimeType(); 695 return m_response.mimeType();
696 } 696 }
697 697
698 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR L() 698 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR L()
699 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn it& init, const String& source) 699 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn it& init, const String& source)
700 { 700 {
701 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing); 701 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing);
702 if (!source.isNull()) 702 if (!source.isNull())
703 m_writer->appendReplacingData(source); 703 m_writer->appendReplacingData(source);
704 endWriting(m_writer.get()); 704 endWriting(m_writer.get());
705 } 705 }
706 706
707 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 707 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
708 708
709 } // namespace blink 709 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698