OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // The |m_documentLoader| is null in the FrameFetchContext of an imported docume
nt. | 308 // The |m_documentLoader| is null in the FrameFetchContext of an imported docume
nt. |
309 // FIXME(http://crbug.com/274173): This means Inspector, which uses DocumentLoad
er | 309 // FIXME(http://crbug.com/274173): This means Inspector, which uses DocumentLoad
er |
310 // as a grouping entity, cannot see imported documents. | 310 // as a grouping entity, cannot see imported documents. |
311 inline DocumentLoader* FrameFetchContext::masterDocumentLoader() const | 311 inline DocumentLoader* FrameFetchContext::masterDocumentLoader() const |
312 { | 312 { |
313 return m_documentLoader ? m_documentLoader.get() : frame()->loader().documen
tLoader(); | 313 return m_documentLoader ? m_documentLoader.get() : frame()->loader().documen
tLoader(); |
314 } | 314 } |
315 | 315 |
316 void FrameFetchContext::dispatchDidChangeResourcePriority(unsigned long identifi
er, ResourceLoadPriority loadPriority, int intraPriorityValue) | 316 void FrameFetchContext::dispatchDidChangeResourcePriority(unsigned long identifi
er, ResourceLoadPriority loadPriority, int intraPriorityValue) |
317 { | 317 { |
318 frame()->loader().client()->dispatchDidChangeResourcePriority(identifier, lo
adPriority, intraPriorityValue); | |
319 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceChangePriority", TRACE_EV
ENT_SCOPE_THREAD, "data", InspectorChangeResourcePriorityEvent::data(identifier,
loadPriority)); | 318 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceChangePriority", TRACE_EV
ENT_SCOPE_THREAD, "data", InspectorChangeResourcePriorityEvent::data(identifier,
loadPriority)); |
320 InspectorInstrumentation::didChangeResourcePriority(frame(), identifier, loa
dPriority); | 319 InspectorInstrumentation::didChangeResourcePriority(frame(), identifier, loa
dPriority); |
321 } | 320 } |
322 | 321 |
323 void FrameFetchContext::prepareRequest(unsigned long identifier, ResourceRequest
& request, const ResourceResponse& redirectResponse) | 322 void FrameFetchContext::prepareRequest(ResourceRequest& request) |
324 { | 323 { |
325 frame()->loader().applyUserAgent(request); | 324 frame()->loader().applyUserAgent(request); |
326 frame()->loader().client()->dispatchWillSendRequest(m_documentLoader, identi
fier, request, redirectResponse); | 325 frame()->loader().client()->dispatchWillSendRequest(request); |
327 } | 326 } |
328 | 327 |
329 void FrameFetchContext::dispatchWillSendRequest(unsigned long identifier, Resour
ceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiat
orInfo& initiatorInfo) | 328 void FrameFetchContext::dispatchWillSendRequest(unsigned long identifier, Resour
ceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiat
orInfo& initiatorInfo) |
330 { | 329 { |
331 // For initial requests, prepareRequest() is called in | 330 // For initial requests, prepareRequest() is called in |
332 // willStartLoadingResource(), before revalidation policy is determined. | 331 // willStartLoadingResource(), before revalidation policy is determined. |
333 // That call doesn't exist for redirects, so call preareRequest() here. | 332 // That call doesn't exist for redirects, so call preareRequest() here. |
334 if (!redirectResponse.isNull()) | 333 if (!redirectResponse.isNull()) |
335 prepareRequest(identifier, request, redirectResponse); | 334 prepareRequest(request); |
336 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT
_SCOPE_THREAD, "data", InspectorSendRequestEvent::data(identifier, frame(), requ
est)); | 335 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT
_SCOPE_THREAD, "data", InspectorSendRequestEvent::data(identifier, frame(), requ
est)); |
337 InspectorInstrumentation::willSendRequest(frame(), identifier, masterDocumen
tLoader(), request, redirectResponse, initiatorInfo); | 336 InspectorInstrumentation::willSendRequest(frame(), identifier, masterDocumen
tLoader(), request, redirectResponse, initiatorInfo); |
338 if (frame()->frameScheduler()) | 337 if (frame()->frameScheduler()) |
339 frame()->frameScheduler()->didStartLoading(identifier); | 338 frame()->frameScheduler()->didStartLoading(identifier); |
340 } | 339 } |
341 | 340 |
342 void FrameFetchContext::dispatchDidReceiveResponse(unsigned long identifier, con
st ResourceResponse& response, WebURLRequest::FrameType frameType, WebURLRequest
::RequestContext requestContext, Resource* resource) | 341 void FrameFetchContext::dispatchDidReceiveResponse(unsigned long identifier, con
st ResourceResponse& response, WebURLRequest::FrameType frameType, WebURLRequest
::RequestContext requestContext, Resource* resource) |
343 { | 342 { |
344 dispatchDidReceiveResponseInternal(identifier, response, frameType, requestC
ontext, resource, LinkLoader::LoadResourcesAndPreconnect); | 343 dispatchDidReceiveResponseInternal(identifier, response, frameType, requestC
ontext, resource, LinkLoader::LoadResourcesAndPreconnect); |
345 } | 344 } |
346 | 345 |
347 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, const c
har* data, int dataLength, int encodedDataLength) | 346 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, const c
har* data, int dataLength, int encodedDataLength) |
348 { | 347 { |
349 frame()->loader().progress().incrementProgress(identifier, dataLength); | 348 frame()->loader().progress().incrementProgress(identifier, dataLength); |
350 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceivedData", TRACE_EVEN
T_SCOPE_THREAD, "data", InspectorReceiveDataEvent::data(identifier, frame(), enc
odedDataLength)); | 349 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceivedData", TRACE_EVEN
T_SCOPE_THREAD, "data", InspectorReceiveDataEvent::data(identifier, frame(), enc
odedDataLength)); |
351 InspectorInstrumentation::didReceiveData(frame(), identifier, data, dataLeng
th, encodedDataLength); | 350 InspectorInstrumentation::didReceiveData(frame(), identifier, data, dataLeng
th, encodedDataLength); |
352 } | 351 } |
353 | 352 |
354 void FrameFetchContext::dispatchDidDownloadData(unsigned long identifier, int da
taLength, int encodedDataLength) | 353 void FrameFetchContext::dispatchDidDownloadData(unsigned long identifier, int da
taLength, int encodedDataLength) |
355 { | 354 { |
356 frame()->loader().progress().incrementProgress(identifier, dataLength); | 355 frame()->loader().progress().incrementProgress(identifier, dataLength); |
357 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceivedData", TRACE_EVEN
T_SCOPE_THREAD, "data", InspectorReceiveDataEvent::data(identifier, frame(), enc
odedDataLength)); | 356 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceivedData", TRACE_EVEN
T_SCOPE_THREAD, "data", InspectorReceiveDataEvent::data(identifier, frame(), enc
odedDataLength)); |
358 InspectorInstrumentation::didReceiveData(frame(), identifier, 0, dataLength,
encodedDataLength); | 357 InspectorInstrumentation::didReceiveData(frame(), identifier, 0, dataLength,
encodedDataLength); |
359 } | 358 } |
360 | 359 |
361 void FrameFetchContext::dispatchDidFinishLoading(unsigned long identifier, doubl
e finishTime, int64_t encodedDataLength) | 360 void FrameFetchContext::dispatchDidFinishLoading(unsigned long identifier, doubl
e finishTime, int64_t encodedDataLength) |
362 { | 361 { |
363 frame()->loader().progress().completeProgress(identifier); | 362 frame()->loader().progress().completeProgress(identifier); |
364 frame()->loader().client()->dispatchDidFinishLoading(m_documentLoader, ident
ifier); | |
365 | |
366 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_SCOP
E_THREAD, "data", InspectorResourceFinishEvent::data(identifier, finishTime, fal
se)); | 363 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_SCOP
E_THREAD, "data", InspectorResourceFinishEvent::data(identifier, finishTime, fal
se)); |
367 InspectorInstrumentation::didFinishLoading(frame(), identifier, finishTime,
encodedDataLength); | 364 InspectorInstrumentation::didFinishLoading(frame(), identifier, finishTime,
encodedDataLength); |
368 if (frame()->frameScheduler()) | 365 if (frame()->frameScheduler()) |
369 frame()->frameScheduler()->didStopLoading(identifier); | 366 frame()->frameScheduler()->didStopLoading(identifier); |
370 } | 367 } |
371 | 368 |
372 void FrameFetchContext::dispatchDidFail(unsigned long identifier, const Resource
Error& error, bool isInternalRequest) | 369 void FrameFetchContext::dispatchDidFail(unsigned long identifier, const Resource
Error& error, bool isInternalRequest) |
373 { | 370 { |
374 frame()->loader().progress().completeProgress(identifier); | 371 frame()->loader().progress().completeProgress(identifier); |
375 frame()->loader().client()->dispatchDidFinishLoading(m_documentLoader, ident
ifier); | |
376 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_SCOP
E_THREAD, "data", InspectorResourceFinishEvent::data(identifier, 0, true)); | 372 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_SCOP
E_THREAD, "data", InspectorResourceFinishEvent::data(identifier, 0, true)); |
377 InspectorInstrumentation::didFailLoading(frame(), identifier, error); | 373 InspectorInstrumentation::didFailLoading(frame(), identifier, error); |
378 // Notification to FrameConsole should come AFTER InspectorInstrumentation c
all, DevTools front-end relies on this. | 374 // Notification to FrameConsole should come AFTER InspectorInstrumentation c
all, DevTools front-end relies on this. |
379 if (!isInternalRequest) | 375 if (!isInternalRequest) |
380 frame()->console().didFailLoading(identifier, error); | 376 frame()->console().didFailLoading(identifier, error); |
381 if (frame()->frameScheduler()) | 377 if (frame()->frameScheduler()) |
382 frame()->frameScheduler()->didStopLoading(identifier); | 378 frame()->frameScheduler()->didStopLoading(identifier); |
383 } | 379 } |
384 | 380 |
385 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(unsigned long ide
ntifier, Resource* resource, WebURLRequest::FrameType frameType, WebURLRequest::
RequestContext requestContext) | 381 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(unsigned long ide
ntifier, Resource* resource, WebURLRequest::FrameType frameType, WebURLRequest::
RequestContext requestContext) |
(...skipping 29 matching lines...) Expand all Loading... |
415 value->setString("requestId", requestId); | 411 value->setString("requestId", requestId); |
416 value->setString("url", url.getString()); | 412 value->setString("url", url.getString()); |
417 value->setInteger("priority", priority); | 413 value->setInteger("priority", priority); |
418 return value; | 414 return value; |
419 } | 415 } |
420 | 416 |
421 void FrameFetchContext::willStartLoadingResource(unsigned long identifier, Resou
rceRequest& request, Resource::Type type) | 417 void FrameFetchContext::willStartLoadingResource(unsigned long identifier, Resou
rceRequest& request, Resource::Type type) |
422 { | 418 { |
423 TRACE_EVENT_ASYNC_BEGIN1("blink.net", "Resource", identifier, "data", loadRe
sourceTraceData(identifier, request.url(), request.priority())); | 419 TRACE_EVENT_ASYNC_BEGIN1("blink.net", "Resource", identifier, "data", loadRe
sourceTraceData(identifier, request.url(), request.priority())); |
424 frame()->loader().progress().willStartLoading(identifier); | 420 frame()->loader().progress().willStartLoading(identifier); |
425 prepareRequest(identifier, request, ResourceResponse()); | 421 prepareRequest(request); |
426 | 422 |
427 if (!m_documentLoader || m_documentLoader->fetcher()->archive() || !request.
url().isValid()) | 423 if (!m_documentLoader || m_documentLoader->fetcher()->archive() || !request.
url().isValid()) |
428 return; | 424 return; |
429 if (type == Resource::MainResource) | 425 if (type == Resource::MainResource) |
430 m_documentLoader->applicationCacheHost()->willStartLoadingMainResource(r
equest); | 426 m_documentLoader->applicationCacheHost()->willStartLoadingMainResource(r
equest); |
431 else | 427 else |
432 m_documentLoader->applicationCacheHost()->willStartLoadingResource(reque
st); | 428 m_documentLoader->applicationCacheHost()->willStartLoadingResource(reque
st); |
433 } | 429 } |
434 | 430 |
435 void FrameFetchContext::didLoadResource(Resource* resource) | 431 void FrameFetchContext::didLoadResource(Resource* resource) |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 m_documentLoader->clientHintsPreferences().updateFromAcceptClientHintsHe
ader(response.httpHeaderField(HTTPNames::Accept_CH), fetcher); | 815 m_documentLoader->clientHintsPreferences().updateFromAcceptClientHintsHe
ader(response.httpHeaderField(HTTPNames::Accept_CH), fetcher); |
820 // When response is received with a provisional docloader, the resource
haven't committed yet, and we cannot load resources, only preconnect. | 816 // When response is received with a provisional docloader, the resource
haven't committed yet, and we cannot load resources, only preconnect. |
821 resourceLoadingPolicy = LinkLoader::DoNotLoadResources; | 817 resourceLoadingPolicy = LinkLoader::DoNotLoadResources; |
822 } | 818 } |
823 LinkLoader::loadLinksFromHeader(response.httpHeaderField(HTTPNames::Link), r
esponse.url(), frame()->document(), NetworkHintsInterfaceImpl(), resourceLoading
Policy, LinkLoader::LoadAll, nullptr); | 819 LinkLoader::loadLinksFromHeader(response.httpHeaderField(HTTPNames::Link), r
esponse.url(), frame()->document(), NetworkHintsInterfaceImpl(), resourceLoading
Policy, LinkLoader::LoadAll, nullptr); |
824 | 820 |
825 if (response.hasMajorCertificateErrors()) | 821 if (response.hasMajorCertificateErrors()) |
826 MixedContentChecker::handleCertificateError(frame(), response, frameType
, requestContext); | 822 MixedContentChecker::handleCertificateError(frame(), response, frameType
, requestContext); |
827 | 823 |
828 frame()->loader().progress().incrementProgress(identifier, response); | 824 frame()->loader().progress().incrementProgress(identifier, response); |
829 frame()->loader().client()->dispatchDidReceiveResponse(m_documentLoader, ide
ntifier, response); | 825 frame()->loader().client()->dispatchDidReceiveResponse(response); |
830 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceiveResponse", TRACE_E
VENT_SCOPE_THREAD, "data", InspectorReceiveResponseEvent::data(identifier, frame
(), response)); | 826 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceiveResponse", TRACE_E
VENT_SCOPE_THREAD, "data", InspectorReceiveResponseEvent::data(identifier, frame
(), response)); |
831 DocumentLoader* documentLoader = masterDocumentLoader(); | 827 DocumentLoader* documentLoader = masterDocumentLoader(); |
832 InspectorInstrumentation::didReceiveResourceResponse(frame(), identifier, do
cumentLoader, response, resource); | 828 InspectorInstrumentation::didReceiveResourceResponse(frame(), identifier, do
cumentLoader, response, resource); |
833 // It is essential that inspector gets resource response BEFORE console. | 829 // It is essential that inspector gets resource response BEFORE console. |
834 frame()->console().reportResourceResponseReceived(documentLoader, identifier
, response); | 830 frame()->console().reportResourceResponseReceived(documentLoader, identifier
, response); |
835 } | 831 } |
836 | 832 |
837 DEFINE_TRACE(FrameFetchContext) | 833 DEFINE_TRACE(FrameFetchContext) |
838 { | 834 { |
839 visitor->trace(m_document); | 835 visitor->trace(m_document); |
840 visitor->trace(m_documentLoader); | 836 visitor->trace(m_documentLoader); |
841 FetchContext::trace(visitor); | 837 FetchContext::trace(visitor); |
842 } | 838 } |
843 | 839 |
844 } // namespace blink | 840 } // namespace blink |
OLD | NEW |