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

Unified Diff: Source/core/timing/PerformanceUserTiming.cpp

Issue 1100813004: Offer User Timing in workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/timing/PerformanceUserTiming.cpp
diff --git a/Source/core/timing/PerformanceUserTiming.cpp b/Source/core/timing/PerformanceUserTiming.cpp
index ecaf7ebf9ec770d659eca9088ec5a2b4b66bb572..94121ab0bc87d5577e47c42c2a6e9690b5f44497 100644
--- a/Source/core/timing/PerformanceUserTiming.cpp
+++ b/Source/core/timing/PerformanceUserTiming.cpp
@@ -28,7 +28,7 @@
#include "bindings/core/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
-#include "core/timing/Performance.h"
+#include "core/timing/PerformanceBase.h"
#include "core/timing/PerformanceMark.h"
#include "core/timing/PerformanceMeasure.h"
#include "platform/TraceEvent.h"
@@ -40,38 +40,43 @@ namespace blink {
namespace {
using RestrictedKeyMap = HashMap<String, NavigationTimingFunction>;
-static RestrictedKeyMap restrictedKeyMap()
-{
- DEFINE_STATIC_LOCAL(RestrictedKeyMap, map, ());
- if (map.isEmpty()) {
- map.add("navigationStart", &PerformanceTiming::navigationStart);
- map.add("unloadEventStart", &PerformanceTiming::unloadEventStart);
- map.add("unloadEventEnd", &PerformanceTiming::unloadEventEnd);
- map.add("redirectStart", &PerformanceTiming::redirectStart);
- map.add("redirectEnd", &PerformanceTiming::redirectEnd);
- map.add("fetchStart", &PerformanceTiming::fetchStart);
- map.add("domainLookupStart", &PerformanceTiming::domainLookupStart);
- map.add("domainLookupEnd", &PerformanceTiming::domainLookupEnd);
- map.add("connectStart", &PerformanceTiming::connectStart);
- map.add("connectEnd", &PerformanceTiming::connectEnd);
- map.add("secureConnectionStart", &PerformanceTiming::secureConnectionStart);
- map.add("requestStart", &PerformanceTiming::requestStart);
- map.add("responseStart", &PerformanceTiming::responseStart);
- map.add("responseEnd", &PerformanceTiming::responseEnd);
- map.add("domLoading", &PerformanceTiming::domLoading);
- map.add("domInteractive", &PerformanceTiming::domInteractive);
- map.add("domContentLoadedEventStart", &PerformanceTiming::domContentLoadedEventStart);
- map.add("domContentLoadedEventEnd", &PerformanceTiming::domContentLoadedEventEnd);
- map.add("domComplete", &PerformanceTiming::domComplete);
- map.add("loadEventStart", &PerformanceTiming::loadEventStart);
- map.add("loadEventEnd", &PerformanceTiming::loadEventEnd);
- }
+
+RestrictedKeyMap* createRestrictedKeyMap()
+{
+ RestrictedKeyMap* map = new RestrictedKeyMap();
+ map->add("navigationStart", &PerformanceTiming::navigationStart);
+ map->add("unloadEventStart", &PerformanceTiming::unloadEventStart);
+ map->add("unloadEventEnd", &PerformanceTiming::unloadEventEnd);
+ map->add("redirectStart", &PerformanceTiming::redirectStart);
+ map->add("redirectEnd", &PerformanceTiming::redirectEnd);
+ map->add("fetchStart", &PerformanceTiming::fetchStart);
+ map->add("domainLookupStart", &PerformanceTiming::domainLookupStart);
+ map->add("domainLookupEnd", &PerformanceTiming::domainLookupEnd);
+ map->add("connectStart", &PerformanceTiming::connectStart);
+ map->add("connectEnd", &PerformanceTiming::connectEnd);
+ map->add("secureConnectionStart", &PerformanceTiming::secureConnectionStart);
+ map->add("requestStart", &PerformanceTiming::requestStart);
+ map->add("responseStart", &PerformanceTiming::responseStart);
+ map->add("responseEnd", &PerformanceTiming::responseEnd);
+ map->add("domLoading", &PerformanceTiming::domLoading);
+ map->add("domInteractive", &PerformanceTiming::domInteractive);
+ map->add("domContentLoadedEventStart", &PerformanceTiming::domContentLoadedEventStart);
+ map->add("domContentLoadedEventEnd", &PerformanceTiming::domContentLoadedEventEnd);
+ map->add("domComplete", &PerformanceTiming::domComplete);
+ map->add("loadEventStart", &PerformanceTiming::loadEventStart);
+ map->add("loadEventEnd", &PerformanceTiming::loadEventEnd);
+ return map;
+}
+
+const RestrictedKeyMap& restrictedKeyMap()
+{
+ AtomicallyInitializedStaticReference(RestrictedKeyMap, map, createRestrictedKeyMap());
return map;
}
} // namespace anonymous
-UserTiming::UserTiming(Performance* performance)
+UserTiming::UserTiming(PerformanceBase* performance)
: m_performance(performance)
{
}
@@ -122,7 +127,7 @@ double UserTiming::findExistingMarkStartTime(const String& markName, ExceptionSt
if (m_marksMap.contains(markName))
return m_marksMap.get(markName).last()->startTime();
- if (restrictedKeyMap().contains(markName)) {
+ if (restrictedKeyMap().contains(markName) && m_performance->timing()) {
double value = static_cast<double>((m_performance->timing()->*(restrictedKeyMap().get(markName)))());
if (!value) {
exceptionState.throwDOMException(InvalidAccessError, "'" + markName + "' is empty: either the event hasn't happened yet, or it would provide cross-origin timing information.");
@@ -159,8 +164,8 @@ void UserTiming::measure(const String& measureName, const String& startMark, con
// User timing events are stored as integer milliseconds from the start of
// navigation, whereas trace events accept double seconds based off of
// CurrentTime::monotonicallyIncreasingTime().
- double startTimeMonotonic = m_performance->timing()->integerMillisecondsToMonotonicTime(startTime + m_performance->timing()->navigationStart());
- double endTimeMonotonic = m_performance->timing()->integerMillisecondsToMonotonicTime(endTime + m_performance->timing()->navigationStart());
+ double startTimeMonotonic = m_performance->timeOrigin() + startTime / 1000.0;
+ double endTimeMonotonic = m_performance->timeOrigin() + endTime / 1000.0;
TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0("blink.user_timing", measureName.utf8().data(), WTF::StringHash::hash(measureName), startTimeMonotonic);
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0("blink.user_timing", measureName.utf8().data(), WTF::StringHash::hash(measureName), endTimeMonotonic);
« no previous file with comments | « Source/core/timing/PerformanceUserTiming.h ('k') | Source/modules/performance/WorkerGlobalScopePerformance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698