| Index: third_party/WebKit/Source/core/frame/PerformanceMonitor.h
|
| diff --git a/third_party/WebKit/Source/core/frame/PerformanceMonitor.h b/third_party/WebKit/Source/core/frame/PerformanceMonitor.h
|
| index 3d6178766484455967d4924588f2b813fc42faf4..07e018c3460edbb2c87b7eab429e4bf9ebc88ef0 100644
|
| --- a/third_party/WebKit/Source/core/frame/PerformanceMonitor.h
|
| +++ b/third_party/WebKit/Source/core/frame/PerformanceMonitor.h
|
| @@ -6,7 +6,6 @@
|
| #define PerformanceMonitor_h
|
|
|
| #include "core/CoreExport.h"
|
| -#include "core/inspector/ConsoleTypes.h"
|
| #include "platform/heap/Handle.h"
|
| #include "public/platform/WebThread.h"
|
| #include "public/platform/scheduler/base/task_time_observer.h"
|
| @@ -32,36 +31,51 @@ class CORE_EXPORT PerformanceMonitor final
|
| WTF_MAKE_NONCOPYABLE(PerformanceMonitor);
|
|
|
| public:
|
| - // Instrumenting methods, TODO: codegen those.
|
| - static void performanceObserverAdded(Performance*);
|
| - static void performanceObserverRemoved(Performance*);
|
| + enum Violation : size_t { kLongTask, kLongLayout, kBlockedEvent, kAfterLast };
|
| +
|
| + class CORE_EXPORT Client : public GarbageCollectedMixin {
|
| + public:
|
| + virtual void reportLongTask(
|
| + double startTime,
|
| + double endTime,
|
| + const HeapHashSet<Member<Frame>>& contextFrames){};
|
| + virtual void reportLongLayout(double duration){};
|
| + virtual void reportGenericViolation(Violation,
|
| + const String& text,
|
| + double time,
|
| + SourceLocation*){};
|
| + DEFINE_INLINE_VIRTUAL_TRACE() {}
|
| + };
|
| +
|
| + // Instrumenting methods.
|
| static void willExecuteScript(ExecutionContext*);
|
| static void didExecuteScript(ExecutionContext*);
|
| static void willUpdateLayout(Document*);
|
| static void didUpdateLayout(Document*);
|
| static void willRecalculateStyle(Document*);
|
| static void didRecalculateStyle(Document*);
|
| + static void reportGenericViolation(ExecutionContext*,
|
| + Violation,
|
| + const String& text,
|
| + double time,
|
| + SourceLocation*);
|
| + static double threshold(ExecutionContext*, Violation);
|
|
|
| - // Direct logging API for core.
|
| - static bool enabled(ExecutionContext*);
|
| - static void logViolation(MessageLevel, ExecutionContext*, const String&);
|
| - static void logViolation(MessageLevel,
|
| - ExecutionContext*,
|
| - const String&,
|
| - std::unique_ptr<SourceLocation>);
|
| + // Direct API for core.
|
| + void subscribe(Violation, double threshold, Client*);
|
| + void unsubscribeAll(Client*);
|
|
|
| explicit PerformanceMonitor(LocalFrame*);
|
| ~PerformanceMonitor();
|
|
|
| - void setLoggingEnabled(bool);
|
| -
|
| DECLARE_VIRTUAL_TRACE();
|
|
|
| private:
|
| friend class PerformanceMonitorTest;
|
| friend class PerformanceTest;
|
|
|
| - static PerformanceMonitor* instrumentingMonitor(ExecutionContext*);
|
| + static PerformanceMonitor* monitor(const ExecutionContext*);
|
| + static PerformanceMonitor* instrumentingMonitor(const ExecutionContext*);
|
|
|
| void updateInstrumentation();
|
|
|
| @@ -72,11 +86,6 @@ class CORE_EXPORT PerformanceMonitor final
|
| void willRecalculateStyle();
|
| void didRecalculateStyle();
|
|
|
| - void logViolation(MessageLevel, const String&);
|
| - void logViolation(MessageLevel,
|
| - const String&,
|
| - std::unique_ptr<SourceLocation>);
|
| -
|
| // WebThread::TaskObserver implementation.
|
| void willProcessTask() override;
|
| void didProcessTask() override;
|
| @@ -91,14 +100,21 @@ class CORE_EXPORT PerformanceMonitor final
|
| Frame* observerFrame);
|
|
|
| bool m_enabled = false;
|
| - bool m_loggingEnabled = false;
|
| bool m_isExecutingScript = false;
|
| double m_layoutStartTime = 0;
|
| double m_styleStartTime = 0;
|
| double m_perTaskStyleAndLayoutTime = 0;
|
| +
|
| + double m_thresholds[kAfterLast];
|
| +
|
| Member<LocalFrame> m_localRoot;
|
| HeapHashSet<Member<Frame>> m_frameContexts;
|
| - HeapHashSet<Member<Performance>> m_webPerformanceObservers;
|
| + using ClientThresholds = HeapHashMap<Member<Client>, double>;
|
| + HeapHashMap<Violation,
|
| + Member<ClientThresholds>,
|
| + typename DefaultHash<size_t>::Hash,
|
| + WTF::UnsignedWithZeroKeyHashTraits<size_t>>
|
| + m_subscriptions;
|
| };
|
|
|
| } // namespace blink
|
|
|