Commit 59250b64 authored by sunjian's avatar sunjian Committed by Commit bot

fixed encodedBodySize/decodedBodySize/initiatorType for nav timing 2. Report...

fixed encodedBodySize/decodedBodySize/initiatorType for nav timing 2. Report initiatorType as "navigation" instead of an empty string.

BUG=675044,675042

Review-Url: https://codereview.chromium.org/2582863002
Cr-Commit-Position: refs/heads/master@{#443445}
parent e0bcd199
......@@ -69,14 +69,14 @@
"Expected startTime to be: 0.");
assert_equals(entries[0].duration, entries[0].loadEventEnd,
"Expected duration to be equal to loadEventEnd.");
assert_equals(entries[0].initiatorType, "",
"Expected initiatorType to be an empty string.");
assert_equals(entries[0].initiatorType, "navigation",
"Expected initiatorType to be equal to navigation.");
// This test may fail when response is from cach. Disable or clean cach before
// running this test.
assert_true(entries[0].transferSize > entries[0].encodedBodySize,
"Expected transferSize to be greater than encodedBodySize in uncached navigation.");
assert_equals(entries[0].encodedBodySize, 0);
assert_equals(entries[0].decodedBodySize, 0);
assert_equals(entries[0].encodedBodySize, 4148);
assert_equals(entries[0].decodedBodySize, 4148);
verifyTimingEventOrder(entries[0], navTiming2EventOrder1);
// When unloadEvent happens
if (entries[0]["unloadEventStart"] != 0) {
......
......@@ -195,7 +195,7 @@ ResourceLoadPriority ResourceFetcher::computeLoadPriority(
request.resourceRequest().priority());
}
static void populateResourceTiming(ResourceTimingInfo* info,
static void populateTimingInfo(ResourceTimingInfo* info,
Resource* resource) {
KURL initialURL = resource->response().redirectResponses().isEmpty()
? resource->resourceRequest().url()
......@@ -307,7 +307,7 @@ void ResourceFetcher::requestLoadStarted(unsigned long identifier,
std::unique_ptr<ResourceTimingInfo> info = ResourceTimingInfo::create(
request.options().initiatorInfo.name, monotonicallyIncreasingTime(),
resource->getType() == Resource::MainResource);
populateResourceTiming(info.get(), resource);
populateTimingInfo(info.get(), resource);
info->clearLoadTimings();
info->setLoadFinishTime(info->initialTime());
m_scheduledResourceTimingReports.push_back(std::move(info));
......@@ -1123,6 +1123,7 @@ void ResourceFetcher::handleLoaderFinish(Resource* resource,
// Store redirect responses that were packed inside the final response.
addRedirectsToTimingInfo(resource, m_navigationTimingInfo.get());
if (resource->response().isHTTP()) {
populateTimingInfo(m_navigationTimingInfo.get(), resource);
m_navigationTimingInfo->addFinalTransferSize(
encodedDataLength == -1 ? 0 : encodedDataLength);
}
......@@ -1134,7 +1135,7 @@ void ResourceFetcher::handleLoaderFinish(Resource* resource,
if (resource->response().isHTTP() &&
resource->response().httpStatusCode() < 400) {
populateResourceTiming(info.get(), resource);
populateTimingInfo(info.get(), resource);
info->setLoadFinishTime(finishTime);
// encodedDataLength == -1 means "not available".
// TODO(ricea): Find cases where it is not available but the
......
......@@ -354,12 +354,13 @@ void PerformanceBase::addNavigationTiming(LocalFrame* frame) {
const DocumentTiming* documentTiming =
frame->document() ? &(frame->document()->timing()) : nullptr;
const ResourceResponse& finalResponse = documentLoader->response();
ResourceTimingInfo* navigationTimingInfo =
documentLoader->getNavigationTimingInfo();
if (!navigationTimingInfo)
return;
const ResourceResponse& finalResponse = navigationTimingInfo->finalResponse();
ResourceLoadTiming* resourceLoadTiming = finalResponse.resourceLoadTiming();
// Don't create a navigation timing instance when
// resourceLoadTiming is null, which could happen when visiting non-http sites
......
......@@ -34,7 +34,7 @@ PerformanceNavigationTiming::PerformanceNavigationTiming(
unsigned long long encodedBodyLength,
unsigned long long decodedBodyLength,
bool didReuseConnection)
: PerformanceResourceTiming("",
: PerformanceResourceTiming("navigation",
timeOrigin,
timing,
lastRedirectEndTime,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment