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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/timing/PerformanceObserverEntryList.cpp
diff --git a/Source/core/timing/PerformanceObserverEntryList.cpp b/Source/core/timing/PerformanceObserverEntryList.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..97f90aa4e941343b6da0bc0909ea17fb7a82ed64
--- /dev/null
+++ b/Source/core/timing/PerformanceObserverEntryList.cpp
@@ -0,0 +1,74 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/timing/PerformanceObserverEntryList.h"
+
+#include "core/timing/PerformanceEntry.h"
+#include "wtf/StdLibExtras.h"
+
+namespace blink {
+
+PerformanceObserverEntryList::PerformanceObserverEntryList(const PerformanceEntryVector& entryVector)
+ : m_performanceEntries(entryVector)
+{
+}
+
+PerformanceObserverEntryList::~PerformanceObserverEntryList()
+{
+}
+
+
+PerformanceEntryVector PerformanceObserverEntryList::getEntries() const
+{
+ PerformanceEntryVector entries;
+
+ entries.appendVector(m_performanceEntries);
+
+ std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompareLessThan);
+ return entries;
+}
+
+PerformanceEntryVector PerformanceObserverEntryList::getEntriesByType(const String& entryType)
+{
+ PerformanceEntryVector entries;
+ PerformanceEntry::EntryType type = PerformanceEntry::toEntryTypeEnum(entryType);
+
+ if (type == PerformanceEntry::Invalid)
+ return entries;
+
+ for (const auto& entry : m_performanceEntries) {
+ if (entry->entryTypeEnum() == type) {
+ entries.append(entry);
+ }
+ }
+
+ std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompareLessThan);
+ return entries;
+}
+
+PerformanceEntryVector PerformanceObserverEntryList::getEntriesByName(const String& name, const String& entryType)
+{
+ PerformanceEntryVector entries;
+ PerformanceEntry::EntryType type = PerformanceEntry::toEntryTypeEnum(entryType);
+
+ if (!entryType.isNull() && type == PerformanceEntry::Invalid)
+ return entries;
+
+ for (const auto& entry : m_performanceEntries) {
+ if (entry->name() == name && (entryType.isNull() || type == entry->entryTypeEnum())) {
+ entries.append(entry);
+ }
+ }
+
+ std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompareLessThan);
+ return entries;
+}
+
+DEFINE_TRACE(PerformanceObserverEntryList)
+{
+ visitor->trace(m_performanceEntries);
+}
+
+} // namespace blink
« 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