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

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

Issue 916273002: Make DocumentLoader::timing return a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 { 221 {
222 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading() || In spectorInstrumentation::isDebuggerPaused(m_frame)); 222 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading() || In spectorInstrumentation::isDebuggerPaused(m_frame));
223 223
224 RefPtr<DocumentLoader> protect(this); 224 RefPtr<DocumentLoader> protect(this);
225 225
226 double responseEndTime = finishTime; 226 double responseEndTime = finishTime;
227 if (!responseEndTime) 227 if (!responseEndTime)
228 responseEndTime = m_timeOfLastDataReceived; 228 responseEndTime = m_timeOfLastDataReceived;
229 if (!responseEndTime) 229 if (!responseEndTime)
230 responseEndTime = monotonicallyIncreasingTime(); 230 responseEndTime = monotonicallyIncreasingTime();
231 timing()->setResponseEnd(responseEndTime); 231 timing().setResponseEnd(responseEndTime);
232 232
233 commitIfReady(); 233 commitIfReady();
234 if (!frameLoader()) 234 if (!frameLoader())
235 return; 235 return;
236 236
237 if (!maybeCreateArchive()) { 237 if (!maybeCreateArchive()) {
238 // If this is an empty document, it will not have actually been created yet. Commit dummy data so that 238 // If this is an empty document, it will not have actually been created yet. Commit dummy data so that
239 // DocumentWriter::begin() gets called and creates the Document. 239 // DocumentWriter::begin() gets called and creates the Document.
240 if (!m_writer) 240 if (!m_writer)
241 commitData(0, 0); 241 commitData(0, 0);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // Note that there are no asserts here as there are for the other callbacks. This is due to the 318 // Note that there are no asserts here as there are for the other callbacks. This is due to the
319 // fact that this "callback" is sent when starting every load, and the state of callback 319 // fact that this "callback" is sent when starting every load, and the state of callback
320 // deferrals plays less of a part in this function in preventing the bad beh avior deferring 320 // deferrals plays less of a part in this function in preventing the bad beh avior deferring
321 // callbacks is meant to prevent. 321 // callbacks is meant to prevent.
322 ASSERT(!newRequest.isNull()); 322 ASSERT(!newRequest.isNull());
323 if (isFormSubmission(m_navigationType) && !m_frame->document()->contentSecur ityPolicy()->allowFormAction(newRequest.url())) { 323 if (isFormSubmission(m_navigationType) && !m_frame->document()->contentSecur ityPolicy()->allowFormAction(newRequest.url())) {
324 cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url())); 324 cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url()));
325 return; 325 return;
326 } 326 }
327 327
328 ASSERT(timing()->fetchStart()); 328 ASSERT(timing().fetchStart());
329 if (!redirectResponse.isNull()) { 329 if (!redirectResponse.isNull()) {
330 // If the redirecting url is not allowed to display content from the tar get origin, 330 // If the redirecting url is not allowed to display content from the tar get origin,
331 // then block the redirect. 331 // then block the redirect.
332 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redire ctResponse.url()); 332 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redire ctResponse.url());
333 if (!redirectingOrigin->canDisplay(newRequest.url())) { 333 if (!redirectingOrigin->canDisplay(newRequest.url())) {
334 FrameLoader::reportLocalLoadFailed(m_frame, newRequest.url().string( )); 334 FrameLoader::reportLocalLoadFailed(m_frame, newRequest.url().string( ));
335 cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url( ))); 335 cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url( )));
336 return; 336 return;
337 } 337 }
338 timing()->addRedirect(redirectResponse.url(), newRequest.url()); 338 timing().addRedirect(redirectResponse.url(), newRequest.url());
339 } 339 }
340 340
341 // If we're fielding a redirect in response to a POST, force a load from ori gin, since 341 // If we're fielding a redirect in response to a POST, force a load from ori gin, since
342 // this is a common site technique to return to a page viewing some data tha t the POST 342 // this is a common site technique to return to a page viewing some data tha t the POST
343 // just modified. 343 // just modified.
344 if (newRequest.cachePolicy() == UseProtocolCachePolicy && isRedirectAfterPos t(newRequest, redirectResponse)) 344 if (newRequest.cachePolicy() == UseProtocolCachePolicy && isRedirectAfterPos t(newRequest, redirectResponse))
345 newRequest.setCachePolicy(ReloadBypassingCache); 345 newRequest.setCachePolicy(ReloadBypassingCache);
346 346
347 m_request = newRequest; 347 m_request = newRequest;
348 348
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 m_request.setURL(blankURL()); 691 m_request.setURL(blankURL());
692 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing()); 692 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing());
693 finishedLoading(monotonicallyIncreasingTime()); 693 finishedLoading(monotonicallyIncreasingTime());
694 return true; 694 return true;
695 } 695 }
696 696
697 void DocumentLoader::startLoadingMainResource() 697 void DocumentLoader::startLoadingMainResource()
698 { 698 {
699 RefPtr<DocumentLoader> protect(this); 699 RefPtr<DocumentLoader> protect(this);
700 m_mainDocumentError = ResourceError(); 700 m_mainDocumentError = ResourceError();
701 timing()->markNavigationStart(); 701 timing().markNavigationStart();
702 ASSERT(!m_mainResource); 702 ASSERT(!m_mainResource);
703 ASSERT(!m_loadingMainResource); 703 ASSERT(!m_loadingMainResource);
704 m_loadingMainResource = true; 704 m_loadingMainResource = true;
705 705
706 if (maybeLoadEmpty()) 706 if (maybeLoadEmpty())
707 return; 707 return;
708 708
709 ASSERT(timing()->navigationStart()); 709 ASSERT(timing().navigationStart());
710 ASSERT(!timing()->fetchStart()); 710 ASSERT(!timing().fetchStart());
711 timing()->markFetchStart(); 711 timing().markFetchStart();
712 willSendRequest(m_request, ResourceResponse()); 712 willSendRequest(m_request, ResourceResponse());
713 713
714 // willSendRequest() may lead to our LocalFrame being detached or cancelling the load via nulling the ResourceRequest. 714 // willSendRequest() may lead to our LocalFrame being detached or cancelling the load via nulling the ResourceRequest.
715 if (!m_frame || m_request.isNull()) 715 if (!m_frame || m_request.isNull())
716 return; 716 return;
717 717
718 m_applicationCacheHost->willStartLoadingMainResource(m_request); 718 m_applicationCacheHost->willStartLoadingMainResource(m_request);
719 prepareSubframeArchiveLoadIfNeeded(); 719 prepareSubframeArchiveLoadIfNeeded();
720 720
721 ResourceRequest request(m_request); 721 ResourceRequest request(m_request);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR L() 812 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR L()
813 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn it& init, const String& source, Document* ownerDocument) 813 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn it& init, const String& source, Document* ownerDocument)
814 { 814 {
815 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri ter->encoding() : emptyAtom, true, ForceSynchronousParsing); 815 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri ter->encoding() : emptyAtom, true, ForceSynchronousParsing);
816 if (!source.isNull()) 816 if (!source.isNull())
817 m_writer->appendReplacingData(source); 817 m_writer->appendReplacingData(source);
818 endWriting(m_writer.get()); 818 endWriting(m_writer.get());
819 } 819 }
820 820
821 } // namespace blink 821 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698