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

Side by Side Diff: Source/core/page/PerformanceUserTiming.cpp

Issue 22311011: Improve 'performance.{mark,measure} exception messages. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/performance/performance-measure-exceptions-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return; 94 return;
95 } 95 }
96 96
97 if (performanceEntryMap.contains(name)) 97 if (performanceEntryMap.contains(name))
98 performanceEntryMap.remove(name); 98 performanceEntryMap.remove(name);
99 } 99 }
100 100
101 void UserTiming::mark(const String& markName, ExceptionState& es) 101 void UserTiming::mark(const String& markName, ExceptionState& es)
102 { 102 {
103 if (restrictedKeyMap().contains(markName)) { 103 if (restrictedKeyMap().contains(markName)) {
104 es.throwDOMException(SyntaxError); 104 es.throwDOMException(SyntaxError, "'" + markName + "' is part of the Per formanceTiming interface, and cannot be used as a mark name.");
105 return; 105 return;
106 } 106 }
107 107
108 double startTime = m_performance->now(); 108 double startTime = m_performance->now();
109 insertPerformanceEntry(m_marksMap, PerformanceMark::create(markName, startTi me)); 109 insertPerformanceEntry(m_marksMap, PerformanceMark::create(markName, startTi me));
110 } 110 }
111 111
112 void UserTiming::clearMarks(const String& markName) 112 void UserTiming::clearMarks(const String& markName)
113 { 113 {
114 clearPeformanceEntries(m_marksMap, markName); 114 clearPeformanceEntries(m_marksMap, markName);
115 } 115 }
116 116
117 double UserTiming::findExistingMarkStartTime(const String& markName, ExceptionSt ate& es) 117 double UserTiming::findExistingMarkStartTime(const String& markName, ExceptionSt ate& es)
118 { 118 {
119 if (m_marksMap.contains(markName)) 119 if (m_marksMap.contains(markName))
120 return m_marksMap.get(markName).last()->startTime(); 120 return m_marksMap.get(markName).last()->startTime();
121 121
122 if (restrictedKeyMap().contains(markName)) { 122 if (restrictedKeyMap().contains(markName)) {
123 double value = static_cast<double>((m_performance->timing()->*(restricte dKeyMap().get(markName)))()); 123 double value = static_cast<double>((m_performance->timing()->*(restricte dKeyMap().get(markName)))());
124 if (!value) { 124 if (!value) {
125 es.throwDOMException(InvalidAccessError); 125 es.throwDOMException(InvalidAccessError, "'" + markName + "' is empt y: either the event hasn't happened yet, or it would provide cross-origin timing information.");
126 return 0.0; 126 return 0.0;
127 } 127 }
128 return value - m_performance->timing()->navigationStart(); 128 return value - m_performance->timing()->navigationStart();
129 } 129 }
130 130
131 es.throwDOMException(SyntaxError); 131 es.throwDOMException(SyntaxError, "The mark '" + markName + "' does not exis t.");
132 return 0.0; 132 return 0.0;
133 } 133 }
134 134
135 void UserTiming::measure(const String& measureName, const String& startMark, con st String& endMark, ExceptionState& es) 135 void UserTiming::measure(const String& measureName, const String& startMark, con st String& endMark, ExceptionState& es)
136 { 136 {
137 double startTime = 0.0; 137 double startTime = 0.0;
138 double endTime = 0.0; 138 double endTime = 0.0;
139 139
140 if (startMark.isNull()) 140 if (startMark.isNull())
141 endTime = m_performance->now(); 141 endTime = m_performance->now();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 { 196 {
197 return convertToEntrySequence(m_measuresMap); 197 return convertToEntrySequence(m_measuresMap);
198 } 198 }
199 199
200 Vector<RefPtr<PerformanceEntry> > UserTiming::getMeasures(const String& name) co nst 200 Vector<RefPtr<PerformanceEntry> > UserTiming::getMeasures(const String& name) co nst
201 { 201 {
202 return getEntrySequenceByName(m_measuresMap, name); 202 return getEntrySequenceByName(m_measuresMap, name);
203 } 203 }
204 204
205 } // namespace WebCore 205 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/performance/performance-measure-exceptions-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698