OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 |
| 7 #include "core/timing/PerformanceObserverEntryList.h" |
| 8 |
| 9 #include "core/timing/PerformanceEntry.h" |
| 10 |
| 11 #include "wtf/StdLibExtras.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 PerformanceObserverEntryList::PerformanceObserverEntryList(const PerformanceEntr
yVector& entryVector) |
| 16 : m_performanceEntries(entryVector) |
| 17 { |
| 18 } |
| 19 |
| 20 PerformanceObserverEntryList::~PerformanceObserverEntryList() |
| 21 { |
| 22 } |
| 23 |
| 24 |
| 25 PerformanceEntryVector PerformanceObserverEntryList::getEntries() const |
| 26 { |
| 27 PerformanceEntryVector entries; |
| 28 |
| 29 entries.appendVector(m_performanceEntries); |
| 30 |
| 31 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare
LessThan); |
| 32 return entries; |
| 33 } |
| 34 |
| 35 PerformanceEntryVector PerformanceObserverEntryList::getEntriesByType(const Stri
ng& entryType) |
| 36 { |
| 37 PerformanceEntryVector entries; |
| 38 PerformanceEntry::EntryType entryTypeEnum = PerformanceEntry::toEntryTypeEnu
m(entryType); |
| 39 |
| 40 if (entryTypeEnum == PerformanceEntry::Invalid) |
| 41 return entries; |
| 42 |
| 43 for (const auto& entry : m_performanceEntries) { |
| 44 if (entry->entryTypeEnum() == entryTypeEnum) { |
| 45 entries.append(entry); |
| 46 } |
| 47 } |
| 48 |
| 49 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare
LessThan); |
| 50 return entries; |
| 51 } |
| 52 |
| 53 PerformanceEntryVector PerformanceObserverEntryList::getEntriesByName(const Stri
ng& name, const String& entryType) |
| 54 { |
| 55 PerformanceEntryVector entries; |
| 56 PerformanceEntry::EntryType entryTypeEnum = PerformanceEntry::toEntryTypeEnu
m(entryType); |
| 57 |
| 58 if (!entryType.isNull() && entryTypeEnum == PerformanceEntry::Invalid) |
| 59 return entries; |
| 60 |
| 61 for (const auto& entry : m_performanceEntries) { |
| 62 if (entry->name() == name && (entryType.isNull() || entryTypeEnum == ent
ry->entryTypeEnum())) { |
| 63 entries.append(entry); |
| 64 } |
| 65 } |
| 66 |
| 67 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare
LessThan); |
| 68 return entries; |
| 69 } |
| 70 |
| 71 DEFINE_TRACE(PerformanceObserverEntryList) |
| 72 { |
| 73 visitor->trace(m_performanceEntries); |
| 74 } |
| 75 |
| 76 } // namespace blink |
OLD | NEW |