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

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

Issue 1198863006: First version of PerformanceObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code review comments Created 5 years, 3 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
(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 #include "core/timing/PerformanceObserverEntryList.h"
7
8 #include "core/timing/PerformanceEntry.h"
9 #include "wtf/StdLibExtras.h"
10
11 namespace blink {
12
13 PerformanceObserverEntryList::PerformanceObserverEntryList(const PerformanceEntr yVector& entryVector)
14 : m_performanceEntries(entryVector)
15 {
16 }
17
18 PerformanceObserverEntryList::~PerformanceObserverEntryList()
19 {
20 }
21
22
23 PerformanceEntryVector PerformanceObserverEntryList::getEntries() const
24 {
25 PerformanceEntryVector entries;
26
27 entries.appendVector(m_performanceEntries);
28
29 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan);
30 return entries;
31 }
32
33 PerformanceEntryVector PerformanceObserverEntryList::getEntriesByType(const Stri ng& entryType)
34 {
35 PerformanceEntryVector entries;
36 PerformanceEntry::EntryType type = PerformanceEntry::toEntryTypeEnum(entryTy pe);
37
38 if (type == PerformanceEntry::Invalid)
39 return entries;
40
41 for (const auto& entry : m_performanceEntries) {
42 if (entry->entryTypeEnum() == type) {
43 entries.append(entry);
44 }
45 }
46
47 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan);
48 return entries;
49 }
50
51 PerformanceEntryVector PerformanceObserverEntryList::getEntriesByName(const Stri ng& name, const String& entryType)
52 {
53 PerformanceEntryVector entries;
54 PerformanceEntry::EntryType type = PerformanceEntry::toEntryTypeEnum(entryTy pe);
55
56 if (!entryType.isNull() && type == PerformanceEntry::Invalid)
57 return entries;
58
59 for (const auto& entry : m_performanceEntries) {
60 if (entry->name() == name && (entryType.isNull() || type == entry->entry TypeEnum())) {
61 entries.append(entry);
62 }
63 }
64
65 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan);
66 return entries;
67 }
68
69 DEFINE_TRACE(PerformanceObserverEntryList)
70 {
71 visitor->trace(m_performanceEntries);
72 }
73
74 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/timing/PerformanceObserverEntryList.h ('k') | Source/core/timing/PerformanceObserverEntryList.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698