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

Side by Side Diff: third_party/WebKit/Source/core/timing/PerformanceBase.cpp

Issue 2511313002: transferSize implementation (Closed)
Patch Set: addressed comments Created 4 years 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel 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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 if (!isResourceTimingBufferFull()) 329 if (!isResourceTimingBufferFull())
330 addResourceTimingBuffer(*entry); 330 addResourceTimingBuffer(*entry);
331 } 331 }
332 332
333 void PerformanceBase::addNavigationTiming(LocalFrame* frame) { 333 void PerformanceBase::addNavigationTiming(LocalFrame* frame) {
334 if (!RuntimeEnabledFeatures::performanceNavigationTiming2Enabled()) 334 if (!RuntimeEnabledFeatures::performanceNavigationTiming2Enabled())
335 return; 335 return;
336 DCHECK(frame); 336 DCHECK(frame);
337 const DocumentLoader* documentLoader = frame->loader().documentLoader(); 337 const DocumentLoader* documentLoader = frame->loader().documentLoader();
338 DCHECK(documentLoader); 338 DCHECK(documentLoader);
339
339 const DocumentLoadTiming& documentLoadTiming = documentLoader->timing(); 340 const DocumentLoadTiming& documentLoadTiming = documentLoader->timing();
340 341
341 const DocumentTiming* documentTiming = 342 const DocumentTiming* documentTiming =
342 frame->document() ? &(frame->document()->timing()) : nullptr; 343 frame->document() ? &(frame->document()->timing()) : nullptr;
343 344
344 const ResourceResponse& finalResponse = documentLoader->response(); 345 const ResourceResponse& finalResponse = documentLoader->response();
346 ResourceTimingInfo* resourceTimingInfo =
347 documentLoader->getMainResourceTimingInfo();
Nate Chapin 2016/12/06 20:07:50 Should the main resource timing info always be the
sunjian 2016/12/07 19:09:50 We need this accessor to access non-iframe main re
348 // Don't create navigation timing instance when resourceTimingInfo
349 // is null, which could happen when it is an iframe navigation restored
350 // from history, since its location may have been changed after initial
351 // navigation.
352 if (!resourceTimingInfo)
353 return;
345 354
346 ResourceLoadTiming* resourceLoadTiming = finalResponse.resourceLoadTiming(); 355 ResourceLoadTiming* resourceLoadTiming = finalResponse.resourceLoadTiming();
347 // Don't create a navigation timing instance when 356 // Don't create a navigation timing instance when
348 // resourceLoadTiming is null, which could happen when visiting non-http sites 357 // resourceLoadTiming is null, which could happen when visiting non-http sites
349 // such as about:blank or in some error cases. 358 // such as about:blank or in some error cases.
350 if (!resourceLoadTiming) 359 if (!resourceLoadTiming)
351 return; 360 return;
352 double lastRedirectEndTime = documentLoadTiming.redirectEnd(); 361 double lastRedirectEndTime = documentLoadTiming.redirectEnd();
353 double finishTime = documentLoadTiming.loadEventEnd(); 362 double finishTime = documentLoadTiming.loadEventEnd();
354 363
355 // TODO(sunjian) Implement transfer size. crbug/663187 364 unsigned long long transferSize = resourceTimingInfo->transferSize();
356 unsigned long long transferSize = 0;
357 unsigned long long encodedBodyLength = finalResponse.encodedBodyLength(); 365 unsigned long long encodedBodyLength = finalResponse.encodedBodyLength();
358 unsigned long long decodedBodyLength = finalResponse.decodedBodyLength(); 366 unsigned long long decodedBodyLength = finalResponse.decodedBodyLength();
359 bool didReuseConnection = finalResponse.connectionReused(); 367 bool didReuseConnection = finalResponse.connectionReused();
360 PerformanceNavigationTiming::NavigationType type = 368 PerformanceNavigationTiming::NavigationType type =
361 getNavigationType(documentLoader->getNavigationType(), frame->document()); 369 getNavigationType(documentLoader->getNavigationType(), frame->document());
362 370
363 m_navigationTiming = new PerformanceNavigationTiming( 371 m_navigationTiming = new PerformanceNavigationTiming(
364 timeOrigin(), documentLoadTiming.unloadEventStart(), 372 timeOrigin(), documentLoadTiming.unloadEventStart(),
365 documentLoadTiming.unloadEventEnd(), documentLoadTiming.loadEventStart(), 373 documentLoadTiming.unloadEventEnd(), documentLoadTiming.loadEventStart(),
366 documentLoadTiming.loadEventEnd(), documentLoadTiming.redirectCount(), 374 documentLoadTiming.loadEventEnd(), documentLoadTiming.redirectCount(),
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 visitor->trace(m_resourceTimingBuffer); 562 visitor->trace(m_resourceTimingBuffer);
555 visitor->trace(m_navigationTiming); 563 visitor->trace(m_navigationTiming);
556 visitor->trace(m_userTiming); 564 visitor->trace(m_userTiming);
557 visitor->trace(m_observers); 565 visitor->trace(m_observers);
558 visitor->trace(m_activeObservers); 566 visitor->trace(m_activeObservers);
559 visitor->trace(m_suspendedObservers); 567 visitor->trace(m_suspendedObservers);
560 EventTargetWithInlineData::trace(visitor); 568 EventTargetWithInlineData::trace(visitor);
561 } 569 }
562 570
563 } // namespace blink 571 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698