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

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.h

Issue 2449673002: Refactor InspectorWebPerfAgent: update lifecycle management to be per Local Frame root; replace hea… (Closed)
Patch Set: sync and rebase Created 4 years, 1 month 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: third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.h
diff --git a/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.h b/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.h
index f0f8ed6c185fd0eae694d20c151973f156cb97e1..b89d760d0500ae6c62679e60549c37699cc6ce52 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.h
+++ b/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.h
@@ -17,8 +17,37 @@ class ExecutionContext;
class Frame;
class LocalFrame;
class Location;
+class Performance;
// Inspector Agent for Web Performance APIs
+// The agent is maintained per local root.
+// Long task notifications are delivered to observing Performance* instances
+// (in the local frame tree) in m_webPerformanceObservers.
+//
+// Usage:
+// To create agent:
+// - instantiate and enable the agent:
+// inspectorWebPerfAgent = new InspectorWebPerfAgent(localFrame);
+// inspectorWebPerfAgent->enable();
+// - add first Performanace* instance:
+// inspectorWebPerfAgent->addWebPerformanceObserver(performance)
+//
+// To add additional Performance* observers, within the local frame tree:
+// inspectorWebPerfAgent->addWebPerformanceObserver(performance);
+//
+// To remove Performance* observer:
+// inspectorWebPerfAgent->removeWebPerformanceObserver(performance);
+//
+// To delete the agent:
+// - remove last Performance* observer
+// inspectorWebPerfAgent->removeWebPerformanceObserver(performance);
+// - ensure all Performance* observers have been removed:
+// if (!inspectorWebPerfAgent->hasWebPerformanceObservers()) { ..
+// - delete the agent:
+// inspectorWebPerfAgent->disable();
+// inspectorWebPerfAgent = nullptr; // depending on lifetime
+// management
+//
class CORE_EXPORT InspectorWebPerfAgent final
: public GarbageCollectedFinalized<InspectorWebPerfAgent>,
public WebThread::TaskObserver,
@@ -33,6 +62,11 @@ class CORE_EXPORT InspectorWebPerfAgent final
void enable();
void disable();
+ bool isEnabled();
+
+ void addWebPerformanceObserver(Performance*);
+ void removeWebPerformanceObserver(Performance*);
+ bool hasWebPerformanceObservers();
void willExecuteScript(ExecutionContext*);
void didExecuteScript();
@@ -49,11 +83,12 @@ class CORE_EXPORT InspectorWebPerfAgent final
private:
bool m_enabled;
std::pair<String, DOMWindow*> sanitizedAttribution(
- const HeapHashSet<Member<Location>>& frameContextLocations,
+ const HeapHashSet<Member<Frame>>& frameContexts,
Frame* observerFrame);
- Member<LocalFrame> m_localFrame;
- HeapHashSet<Member<Location>> m_frameContextLocations;
+ Member<LocalFrame> m_localRoot;
+ HeapHashSet<Member<Frame>> m_frameContexts;
+ HeapHashSet<Member<Performance>> m_webPerformanceObservers;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698