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

Side by Side Diff: Source/core/timing/Performance.cpp

Issue 663693005: Use C++11 features in core/timing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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) 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 const AtomicString& Performance::interfaceName() const 60 const AtomicString& Performance::interfaceName() const
61 { 61 {
62 return EventTargetNames::Performance; 62 return EventTargetNames::Performance;
63 } 63 }
64 64
65 ExecutionContext* Performance::executionContext() const 65 ExecutionContext* Performance::executionContext() const
66 { 66 {
67 if (!frame()) 67 if (!frame())
68 return 0; 68 return nullptr;
69 return frame()->document(); 69 return frame()->document();
70 } 70 }
71 71
72 PassRefPtrWillBeRawPtr<MemoryInfo> Performance::memory() const 72 PassRefPtrWillBeRawPtr<MemoryInfo> Performance::memory() const
73 { 73 {
74 return MemoryInfo::create(); 74 return MemoryInfo::create();
75 } 75 }
76 76
77 PerformanceNavigation* Performance::navigation() const 77 PerformanceNavigation* Performance::navigation() const
78 { 78 {
(...skipping 23 matching lines...) Expand all
102 } 102 }
103 103
104 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan); 104 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan);
105 return entries; 105 return entries;
106 } 106 }
107 107
108 PerformanceEntryVector Performance::getEntriesByType(const String& entryType) 108 PerformanceEntryVector Performance::getEntriesByType(const String& entryType)
109 { 109 {
110 PerformanceEntryVector entries; 110 PerformanceEntryVector entries;
111 111
112 if (equalIgnoringCase(entryType, "resource")) 112 if (equalIgnoringCase(entryType, "resource")) {
113 for (PerformanceEntryVector::const_iterator resource = m_resourceTimingB uffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource) 113 for (const auto& resource : m_resourceTimingBuffer)
114 entries.append(*resource); 114 entries.append(resource);
115 }
115 116
116 if (m_userTiming) { 117 if (m_userTiming) {
117 if (equalIgnoringCase(entryType, "mark")) 118 if (equalIgnoringCase(entryType, "mark"))
118 entries.appendVector(m_userTiming->getMarks()); 119 entries.appendVector(m_userTiming->getMarks());
119 else if (equalIgnoringCase(entryType, "measure")) 120 else if (equalIgnoringCase(entryType, "measure"))
120 entries.appendVector(m_userTiming->getMeasures()); 121 entries.appendVector(m_userTiming->getMeasures());
121 } 122 }
122 123
123 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan); 124 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan);
124 return entries; 125 return entries;
125 } 126 }
126 127
127 PerformanceEntryVector Performance::getEntriesByName(const String& name, const S tring& entryType) 128 PerformanceEntryVector Performance::getEntriesByName(const String& name, const S tring& entryType)
128 { 129 {
129 PerformanceEntryVector entries; 130 PerformanceEntryVector entries;
130 131
131 if (entryType.isNull() || equalIgnoringCase(entryType, "resource")) 132 if (entryType.isNull() || equalIgnoringCase(entryType, "resource")) {
132 for (PerformanceEntryVector::const_iterator resource = m_resourceTimingB uffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource) 133 for (const auto& resource : m_resourceTimingBuffer) {
133 if ((*resource)->name() == name) 134 if (resource->name() == name)
134 entries.append(*resource); 135 entries.append(resource);
136 }
137 }
135 138
136 if (m_userTiming) { 139 if (m_userTiming) {
137 if (entryType.isNull() || equalIgnoringCase(entryType, "mark")) 140 if (entryType.isNull() || equalIgnoringCase(entryType, "mark"))
138 entries.appendVector(m_userTiming->getMarks(name)); 141 entries.appendVector(m_userTiming->getMarks(name));
139 if (entryType.isNull() || equalIgnoringCase(entryType, "measure")) 142 if (entryType.isNull() || equalIgnoringCase(entryType, "measure"))
140 entries.appendVector(m_userTiming->getMeasures(name)); 143 entries.appendVector(m_userTiming->getMeasures(name));
141 } 144 }
142 145
143 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan); 146 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan);
144 return entries; 147 return entries;
(...skipping 22 matching lines...) Expand all
167 const AtomicString& timingAllowOriginString = originalTimingAllowOrigin.isEm pty() ? response.httpHeaderField(timingAllowOrigin) : originalTimingAllowOrigin; 170 const AtomicString& timingAllowOriginString = originalTimingAllowOrigin.isEm pty() ? response.httpHeaderField(timingAllowOrigin) : originalTimingAllowOrigin;
168 if (timingAllowOriginString.isEmpty() || equalIgnoringCase(timingAllowOrigin String, "null")) 171 if (timingAllowOriginString.isEmpty() || equalIgnoringCase(timingAllowOrigin String, "null"))
169 return false; 172 return false;
170 173
171 if (timingAllowOriginString == starAtom) 174 if (timingAllowOriginString == starAtom)
172 return true; 175 return true;
173 176
174 const String& securityOrigin = requestingDocument->securityOrigin()->toStrin g(); 177 const String& securityOrigin = requestingDocument->securityOrigin()->toStrin g();
175 Vector<String> timingAllowOrigins; 178 Vector<String> timingAllowOrigins;
176 timingAllowOriginString.string().split(' ', timingAllowOrigins); 179 timingAllowOriginString.string().split(' ', timingAllowOrigins);
177 for (size_t i = 0; i < timingAllowOrigins.size(); ++i) { 180 for (const String& allowOrigin : timingAllowOrigins) {
178 if (timingAllowOrigins[i] == securityOrigin) 181 if (allowOrigin == securityOrigin)
179 return true; 182 return true;
180 } 183 }
181 184
182 return false; 185 return false;
183 } 186 }
184 187
185 static bool allowsTimingRedirect(const Vector<ResourceResponse>& redirectChain, const ResourceResponse& finalResponse, Document* initiatorDocument) 188 static bool allowsTimingRedirect(const Vector<ResourceResponse>& redirectChain, const ResourceResponse& finalResponse, Document* initiatorDocument)
186 { 189 {
187 if (!passesTimingAllowCheck(finalResponse, initiatorDocument, emptyAtom)) 190 if (!passesTimingAllowCheck(finalResponse, initiatorDocument, emptyAtom))
188 return false; 191 return false;
189 192
190 for (size_t i = 0; i < redirectChain.size(); i++) { 193 for (const auto& response : redirectChain) {
Mike West 2014/10/21 19:29:42 Nit: Don't use auto here; I think typing ResourceR
191 if (!passesTimingAllowCheck(redirectChain[i], initiatorDocument, emptyAt om)) 194 if (!passesTimingAllowCheck(response, initiatorDocument, emptyAtom))
192 return false; 195 return false;
193 } 196 }
194 197
195 return true; 198 return true;
196 } 199 }
197 200
198 void Performance::addResourceTiming(const ResourceTimingInfo& info, Document* in itiatorDocument) 201 void Performance::addResourceTiming(const ResourceTimingInfo& info, Document* in itiatorDocument)
199 { 202 {
200 if (isResourceTimingBufferFull()) 203 if (isResourceTimingBufferFull())
201 return; 204 return;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 { 281 {
279 visitor->trace(m_navigation); 282 visitor->trace(m_navigation);
280 visitor->trace(m_timing); 283 visitor->trace(m_timing);
281 visitor->trace(m_resourceTimingBuffer); 284 visitor->trace(m_resourceTimingBuffer);
282 visitor->trace(m_userTiming); 285 visitor->trace(m_userTiming);
283 EventTargetWithInlineData::trace(visitor); 286 EventTargetWithInlineData::trace(visitor);
284 DOMWindowProperty::trace(visitor); 287 DOMWindowProperty::trace(visitor);
285 } 288 }
286 289
287 } // namespace blink 290 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698