summaryrefslogtreecommitdiff
path: root/Source/WebCore/page/Performance.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/page/Performance.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/page/Performance.h')
-rw-r--r--Source/WebCore/page/Performance.h109
1 files changed, 57 insertions, 52 deletions
diff --git a/Source/WebCore/page/Performance.h b/Source/WebCore/page/Performance.h
index 19c995bae..01654f392 100644
--- a/Source/WebCore/page/Performance.h
+++ b/Source/WebCore/page/Performance.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
* Copyright (C) 2012 Intel Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,89 +30,93 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef Performance_h
-#define Performance_h
+#pragma once
#if ENABLE(WEB_TIMING)
-#include "DOMWindowProperty.h"
+#include "ContextDestructionObserver.h"
#include "EventTarget.h"
-#include "PerformanceEntryList.h"
-#include "PerformanceNavigation.h"
-#include "PerformanceTiming.h"
-#include "ScriptWrappable.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "ExceptionOr.h"
+#include "GenericTaskQueue.h"
+#include <wtf/ListHashSet.h>
namespace WebCore {
-class Document;
-class ResourceRequest;
+class LoadTiming;
+class PerformanceEntry;
+class PerformanceNavigation;
+class PerformanceObserver;
+class PerformanceTiming;
class ResourceResponse;
+class ResourceTiming;
+class ScriptExecutionContext;
+class URL;
class UserTiming;
-class Performance final : public ScriptWrappable, public RefCounted<Performance>, public DOMWindowProperty, public EventTargetWithInlineData {
+class Performance final : public RefCounted<Performance>, public ContextDestructionObserver, public EventTargetWithInlineData {
public:
- static PassRefPtr<Performance> create(Frame* frame) { return adoptRef(new Performance(frame)); }
+ static Ref<Performance> create(ScriptExecutionContext& context, MonotonicTime timeOrigin) { return adoptRef(*new Performance(context, timeOrigin)); }
~Performance();
- virtual EventTargetInterface eventTargetInterface() const override { return PerformanceEventTargetInterfaceType; }
- virtual ScriptExecutionContext* scriptExecutionContext() const override;
-
- PerformanceNavigation* navigation() const;
- PerformanceTiming* timing() const;
double now() const;
-#if ENABLE(PERFORMANCE_TIMELINE)
- PassRefPtr<PerformanceEntryList> webkitGetEntries() const;
- PassRefPtr<PerformanceEntryList> webkitGetEntriesByType(const String& entryType);
- PassRefPtr<PerformanceEntryList> webkitGetEntriesByName(const String& name, const String& entryType);
-#endif
+ PerformanceNavigation* navigation();
+ PerformanceTiming* timing();
+
+ Vector<RefPtr<PerformanceEntry>> getEntries() const;
+ Vector<RefPtr<PerformanceEntry>> getEntriesByType(const String& entryType) const;
+ Vector<RefPtr<PerformanceEntry>> getEntriesByName(const String& name, const String& entryType) const;
+
+ void clearResourceTimings();
+ void setResourceTimingBufferSize(unsigned);
-#if ENABLE(RESOURCE_TIMING)
- void webkitClearResourceTimings();
- void webkitSetResourceTimingBufferSize(unsigned int);
+ ExceptionOr<void> mark(const String& markName);
+ void clearMarks(const String& markName);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitresourcetimingbufferfull);
+ ExceptionOr<void> measure(const String& measureName, const String& startMark, const String& endMark);
+ void clearMeasures(const String& measureName);
- void addResourceTiming(const String& initiatorName, Document*, const ResourceRequest&, const ResourceResponse&, double initiationTime, double finishTime);
-#endif
+ void addResourceTiming(ResourceTiming&&);
- using RefCounted<Performance>::ref;
- using RefCounted<Performance>::deref;
+ void registerPerformanceObserver(PerformanceObserver&);
+ void unregisterPerformanceObserver(PerformanceObserver&);
-#if ENABLE(USER_TIMING)
- void webkitMark(const String& markName, ExceptionCode&);
- void webkitClearMarks(const String& markName);
+ static Seconds reduceTimeResolution(Seconds);
- void webkitMeasure(const String& measureName, const String& startMark, const String& endMark, ExceptionCode&);
- void webkitClearMeasures(const String& measureName);
-#endif // ENABLE(USER_TIMING)
+ ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); }
+
+ using RefCounted::ref;
+ using RefCounted::deref;
private:
- explicit Performance(Frame*);
+ Performance(ScriptExecutionContext&, MonotonicTime timeOrigin);
+
+ void contextDestroyed() override;
+
+ EventTargetInterface eventTargetInterface() const final { return PerformanceEventTargetInterfaceType; }
- virtual void refEventTarget() override { ref(); }
- virtual void derefEventTarget() override { deref(); }
- bool isResourceTimingBufferFull();
+ void refEventTarget() final { ref(); }
+ void derefEventTarget() final { deref(); }
+
+ bool isResourceTimingBufferFull() const;
+
+ void queueEntry(PerformanceEntry&);
mutable RefPtr<PerformanceNavigation> m_navigation;
mutable RefPtr<PerformanceTiming> m_timing;
-
-#if ENABLE(RESOURCE_TIMING)
+
+ // https://w3c.github.io/resource-timing/#extensions-performance-interface recommends size of 150.
Vector<RefPtr<PerformanceEntry>> m_resourceTimingBuffer;
- unsigned m_resourceTimingBufferSize;
-#endif
+ unsigned m_resourceTimingBufferSize { 150 };
-#if ENABLE(USER_TIMING)
- RefPtr<UserTiming> m_userTiming;
-#endif // ENABLE(USER_TIMING)
+ MonotonicTime m_timeOrigin;
+
+ std::unique_ptr<UserTiming> m_userTiming;
+
+ GenericTaskQueue<ScriptExecutionContext> m_performanceTimelineTaskQueue;
+ ListHashSet<RefPtr<PerformanceObserver>> m_observers;
};
}
#endif // ENABLE(WEB_TIMING)
-
-#endif // Performance_h