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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Intel Inc. All rights reserved. 2 * Copyright (C) 2012 Intel 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 if (performanceEntryMap.contains(name)) 103 if (performanceEntryMap.contains(name))
104 performanceEntryMap.erase(name); 104 performanceEntryMap.erase(name);
105 } 105 }
106 106
107 PerformanceEntry* UserTiming::mark(const String& markName, 107 PerformanceEntry* UserTiming::mark(const String& markName,
108 ExceptionState& exceptionState) { 108 ExceptionState& exceptionState) {
109 if (restrictedKeyMap().contains(markName)) { 109 if (restrictedKeyMap().contains(markName)) {
110 exceptionState.throwDOMException( 110 exceptionState.throwDOMException(
111 SyntaxError, "'" + markName + 111 SyntaxError,
112 "' is part of the PerformanceTiming interface, and " 112 "'" + markName +
113 "cannot be used as a mark name."); 113 "' is part of the PerformanceTiming interface, and "
114 "cannot be used as a mark name.");
114 return nullptr; 115 return nullptr;
115 } 116 }
116 117
117 TRACE_EVENT_COPY_MARK("blink.user_timing", markName.utf8().data()); 118 TRACE_EVENT_COPY_MARK("blink.user_timing", markName.utf8().data());
118 double startTime = m_performance->now(); 119 double startTime = m_performance->now();
119 PerformanceEntry* entry = PerformanceMark::create(markName, startTime); 120 PerformanceEntry* entry = PerformanceMark::create(markName, startTime);
120 insertPerformanceEntry(m_marksMap, *entry); 121 insertPerformanceEntry(m_marksMap, *entry);
121 DEFINE_THREAD_SAFE_STATIC_LOCAL( 122 DEFINE_THREAD_SAFE_STATIC_LOCAL(
122 CustomCountHistogram, userTimingMarkHistogram, 123 CustomCountHistogram, userTimingMarkHistogram,
123 new CustomCountHistogram("PLT.UserTiming_Mark", 0, 600000, 100)); 124 new CustomCountHistogram("PLT.UserTiming_Mark", 0, 600000, 100));
124 userTimingMarkHistogram.count(static_cast<int>(startTime)); 125 userTimingMarkHistogram.count(static_cast<int>(startTime));
125 return entry; 126 return entry;
126 } 127 }
127 128
128 void UserTiming::clearMarks(const String& markName) { 129 void UserTiming::clearMarks(const String& markName) {
129 clearPeformanceEntries(m_marksMap, markName); 130 clearPeformanceEntries(m_marksMap, markName);
130 } 131 }
131 132
132 double UserTiming::findExistingMarkStartTime(const String& markName, 133 double UserTiming::findExistingMarkStartTime(const String& markName,
133 ExceptionState& exceptionState) { 134 ExceptionState& exceptionState) {
134 if (m_marksMap.contains(markName)) 135 if (m_marksMap.contains(markName))
135 return m_marksMap.get(markName).back()->startTime(); 136 return m_marksMap.get(markName).back()->startTime();
136 137
137 if (restrictedKeyMap().contains(markName) && m_performance->timing()) { 138 if (restrictedKeyMap().contains(markName) && m_performance->timing()) {
138 double value = static_cast<double>( 139 double value = static_cast<double>(
139 (m_performance->timing()->*(restrictedKeyMap().get(markName)))()); 140 (m_performance->timing()->*(restrictedKeyMap().get(markName)))());
140 if (!value) { 141 if (!value) {
141 exceptionState.throwDOMException( 142 exceptionState.throwDOMException(
142 InvalidAccessError, "'" + markName + 143 InvalidAccessError,
143 "' is empty: either the event hasn't " 144 "'" + markName +
144 "happened yet, or it would provide " 145 "' is empty: either the event hasn't "
145 "cross-origin timing information."); 146 "happened yet, or it would provide "
147 "cross-origin timing information.");
146 return 0.0; 148 return 0.0;
147 } 149 }
148 return value - m_performance->timing()->navigationStart(); 150 return value - m_performance->timing()->navigationStart();
149 } 151 }
150 152
151 exceptionState.throwDOMException( 153 exceptionState.throwDOMException(
152 SyntaxError, "The mark '" + markName + "' does not exist."); 154 SyntaxError, "The mark '" + markName + "' does not exist.");
153 return 0.0; 155 return 0.0;
154 } 156 }
155 157
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return getEntrySequenceByName(m_measuresMap, name); 248 return getEntrySequenceByName(m_measuresMap, name);
247 } 249 }
248 250
249 DEFINE_TRACE(UserTiming) { 251 DEFINE_TRACE(UserTiming) {
250 visitor->trace(m_performance); 252 visitor->trace(m_performance);
251 visitor->trace(m_marksMap); 253 visitor->trace(m_marksMap);
252 visitor->trace(m_measuresMap); 254 visitor->trace(m_measuresMap);
253 } 255 }
254 256
255 } // namespace blink 257 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698