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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 WebURLRequest::FrameType frameType, | 406 WebURLRequest::FrameType frameType, |
407 WebURLRequest::RequestContext requestContext, | 407 WebURLRequest::RequestContext requestContext, |
408 Resource* resource) { | 408 Resource* resource) { |
409 dispatchDidReceiveResponseInternal(identifier, response, frameType, | 409 dispatchDidReceiveResponseInternal(identifier, response, frameType, |
410 requestContext, resource, | 410 requestContext, resource, |
411 LinkLoader::LoadResourcesAndPreconnect); | 411 LinkLoader::LoadResourcesAndPreconnect); |
412 } | 412 } |
413 | 413 |
414 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, | 414 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, |
415 const char* data, | 415 const char* data, |
416 int dataLength, | 416 int dataLength) { |
417 int encodedDataLength) { | 417 TRACE_EVENT1("devtools.timeline", "ResourceReceivedData", "data", |
418 TRACE_EVENT1( | 418 InspectorReceiveDataEvent::data(identifier, frame())); |
419 "devtools.timeline", "ResourceReceivedData", "data", | |
420 InspectorReceiveDataEvent::data(identifier, frame(), encodedDataLength)); | |
421 frame()->loader().progress().incrementProgress(identifier, dataLength); | 419 frame()->loader().progress().incrementProgress(identifier, dataLength); |
422 InspectorInstrumentation::didReceiveData(frame(), identifier, data, | 420 InspectorInstrumentation::didReceiveData(frame(), identifier, data, |
423 dataLength, encodedDataLength); | 421 dataLength); |
424 } | 422 } |
425 | 423 |
426 void FrameFetchContext::dispatchDidDownloadData(unsigned long identifier, | 424 void FrameFetchContext::dispatchDidDownloadData(unsigned long identifier, |
427 int dataLength, | 425 int dataLength, |
428 int encodedDataLength) { | 426 int encodedDataLength) { |
429 TRACE_EVENT1( | 427 TRACE_EVENT1("devtools.timeline", "ResourceReceivedData", "data", |
430 "devtools.timeline", "ResourceReceivedData", "data", | 428 InspectorReceiveDataEvent::data(identifier, frame())); |
431 InspectorReceiveDataEvent::data(identifier, frame(), encodedDataLength)); | |
432 frame()->loader().progress().incrementProgress(identifier, dataLength); | 429 frame()->loader().progress().incrementProgress(identifier, dataLength); |
433 InspectorInstrumentation::didReceiveData(frame(), identifier, 0, dataLength, | 430 InspectorInstrumentation::didReceiveData(frame(), identifier, 0, dataLength); |
434 encodedDataLength); | |
435 } | 431 } |
436 | 432 |
437 void FrameFetchContext::dispatchDidFinishLoading(unsigned long identifier, | 433 void FrameFetchContext::dispatchDidFinishLoading(unsigned long identifier, |
438 double finishTime, | 434 double finishTime, |
439 int64_t encodedDataLength) { | 435 int64_t encodedDataLength) { |
440 TRACE_EVENT1( | 436 TRACE_EVENT1( |
441 "devtools.timeline", "ResourceFinish", "data", | 437 "devtools.timeline", "ResourceFinish", "data", |
442 InspectorResourceFinishEvent::data(identifier, finishTime, false)); | 438 InspectorResourceFinishEvent::data(identifier, finishTime, false)); |
443 frame()->loader().progress().completeProgress(identifier); | 439 frame()->loader().progress().completeProgress(identifier); |
444 InspectorInstrumentation::didFinishLoading(frame(), identifier, finishTime, | 440 InspectorInstrumentation::didFinishLoading(frame(), identifier, finishTime, |
445 encodedDataLength); | 441 encodedDataLength); |
446 if (frame()->frameScheduler()) | 442 if (frame()->frameScheduler()) |
447 frame()->frameScheduler()->didStopLoading(identifier); | 443 frame()->frameScheduler()->didStopLoading(identifier); |
448 } | 444 } |
449 | 445 |
450 void FrameFetchContext::dispatchDidFail(unsigned long identifier, | 446 void FrameFetchContext::dispatchDidFail(unsigned long identifier, |
451 const ResourceError& error, | 447 const ResourceError& error, |
| 448 int64_t encodedDataLength, |
452 bool isInternalRequest) { | 449 bool isInternalRequest) { |
453 TRACE_EVENT1("devtools.timeline", "ResourceFinish", "data", | 450 TRACE_EVENT1("devtools.timeline", "ResourceFinish", "data", |
454 InspectorResourceFinishEvent::data(identifier, 0, true)); | 451 InspectorResourceFinishEvent::data(identifier, 0, true)); |
455 frame()->loader().progress().completeProgress(identifier); | 452 frame()->loader().progress().completeProgress(identifier); |
456 InspectorInstrumentation::didFailLoading(frame(), identifier, error); | 453 InspectorInstrumentation::didFailLoading(frame(), identifier, error, |
| 454 encodedDataLength); |
457 // Notification to FrameConsole should come AFTER InspectorInstrumentation | 455 // Notification to FrameConsole should come AFTER InspectorInstrumentation |
458 // call, DevTools front-end relies on this. | 456 // call, DevTools front-end relies on this. |
459 if (!isInternalRequest) | 457 if (!isInternalRequest) |
460 frame()->console().didFailLoading(identifier, error); | 458 frame()->console().didFailLoading(identifier, error); |
461 if (frame()->frameScheduler()) | 459 if (frame()->frameScheduler()) |
462 frame()->frameScheduler()->didStopLoading(identifier); | 460 frame()->frameScheduler()->didStopLoading(identifier); |
463 } | 461 } |
464 | 462 |
465 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache( | 463 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache( |
466 unsigned long identifier, | 464 unsigned long identifier, |
467 Resource* resource, | 465 Resource* resource, |
468 WebURLRequest::FrameType frameType, | 466 WebURLRequest::FrameType frameType, |
469 WebURLRequest::RequestContext requestContext) { | 467 WebURLRequest::RequestContext requestContext) { |
470 ResourceRequest request(resource->url()); | 468 ResourceRequest request(resource->url()); |
471 frame()->loader().client()->dispatchDidLoadResourceFromMemoryCache( | 469 frame()->loader().client()->dispatchDidLoadResourceFromMemoryCache( |
472 request, resource->response()); | 470 request, resource->response()); |
473 dispatchWillSendRequest(identifier, request, ResourceResponse(), | 471 dispatchWillSendRequest(identifier, request, ResourceResponse(), |
474 resource->options().initiatorInfo); | 472 resource->options().initiatorInfo); |
475 | 473 |
476 InspectorInstrumentation::markResourceAsCached(frame(), identifier); | 474 InspectorInstrumentation::markResourceAsCached(frame(), identifier); |
477 if (!resource->response().isNull()) { | 475 if (!resource->response().isNull()) { |
478 dispatchDidReceiveResponseInternal(identifier, resource->response(), | 476 dispatchDidReceiveResponseInternal(identifier, resource->response(), |
479 frameType, requestContext, resource, | 477 frameType, requestContext, resource, |
480 LinkLoader::DoNotLoadResources); | 478 LinkLoader::DoNotLoadResources); |
481 } | 479 } |
482 | 480 |
483 if (resource->encodedSize() > 0) | 481 if (resource->encodedSize() > 0) |
484 dispatchDidReceiveData(identifier, 0, resource->encodedSize(), 0); | 482 dispatchDidReceiveData(identifier, 0, resource->encodedSize()); |
485 | 483 |
486 dispatchDidFinishLoading(identifier, 0, 0); | 484 dispatchDidFinishLoading(identifier, 0, 0); |
487 } | 485 } |
488 | 486 |
489 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const { | 487 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const { |
490 if (!m_documentLoader) | 488 if (!m_documentLoader) |
491 return true; | 489 return true; |
492 if (type == Resource::MainResource) | 490 if (type == Resource::MainResource) |
493 return m_documentLoader == frame()->loader().provisionalDocumentLoader(); | 491 return m_documentLoader == frame()->loader().provisionalDocumentLoader(); |
494 return m_documentLoader == frame()->loader().documentLoader(); | 492 return m_documentLoader == frame()->loader().documentLoader(); |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 response); | 1002 response); |
1005 } | 1003 } |
1006 | 1004 |
1007 DEFINE_TRACE(FrameFetchContext) { | 1005 DEFINE_TRACE(FrameFetchContext) { |
1008 visitor->trace(m_document); | 1006 visitor->trace(m_document); |
1009 visitor->trace(m_documentLoader); | 1007 visitor->trace(m_documentLoader); |
1010 FetchContext::trace(visitor); | 1008 FetchContext::trace(visitor); |
1011 } | 1009 } |
1012 | 1010 |
1013 } // namespace blink | 1011 } // namespace blink |
OLD | NEW |