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

Unified Diff: third_party/WebKit/Source/core/inspector/CodeGeneratorInstrumentation.py

Issue 2139443002: [DevTools] Allow modifying instrumenting agents while iterating. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/debugger/detach-when-paused-in-instrumentation-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/inspector/CodeGeneratorInstrumentation.py
diff --git a/third_party/WebKit/Source/core/inspector/CodeGeneratorInstrumentation.py b/third_party/WebKit/Source/core/inspector/CodeGeneratorInstrumentation.py
index 188ed26e4f4e261ac542214bb38c4711d84835e5..eaf7a609b7099a4573fddfc91f8d76a2be737590 100755
--- a/third_party/WebKit/Source/core/inspector/CodeGeneratorInstrumentation.py
+++ b/third_party/WebKit/Source/core/inspector/CodeGeneratorInstrumentation.py
@@ -102,6 +102,72 @@ class CORE_EXPORT InstrumentingAgents : public GarbageCollected<InstrumentingAge
public:
InstrumentingAgents();
DECLARE_TRACE();
+
+ template <class T>
+ class AgentsList {
+ DISALLOW_NEW();
+ private:
+ using AgentsVector = HeapVector<Member<T>>;
+ using InnerIterator = typename AgentsVector::iterator;
+
+ public:
+ class Iterator {
+ STACK_ALLOCATED();
+ public:
+ Iterator operator++(int) { InnerIterator value = m_value; ++*this; return Iterator(value, m_list); }
+ Iterator& operator++() { if (!isEnd()) ++m_value; return *this; }
+ bool operator==(const Iterator& other) const { return (isEnd() && other.isEnd()) || m_value == other.m_value; }
+ bool operator!=(const Iterator& other) const { return !(*this == other); }
+ T* operator*() { return *m_value; }
+ T* operator->() { return *m_value; }
+
+ private:
+ friend class AgentsList;
+ Iterator(InnerIterator value, AgentsList* list) : m_value(value), m_list(list), m_version(m_list->m_version) { }
+ bool isEnd() const { return m_list->m_version != m_version || m_value == m_list->m_vector.end(); }
+
+ InnerIterator m_value;
+ Member<AgentsList> m_list;
+ int m_version;
+ };
+
+ Iterator begin() { return Iterator(m_vector.begin(), this); }
+ Iterator end() { return Iterator(m_vector.end(), this); }
+
+ DEFINE_INLINE_TRACE()
+ {
+ visitor->trace(m_vector);
+ }
+
+ private:
+ friend class InstrumentingAgents;
+ friend class Iterator;
+
+ AgentsList() : m_version(0) { }
+
+ bool isEmpty() const { return m_vector.isEmpty(); }
+
+ void add(T* value)
+ {
+ if (m_vector.contains(value))
+ return;
+ ++m_version;
+ m_vector.append(value);
+ }
+
+ void remove(T* value)
+ {
+ size_t index = m_vector.find(value);
+ if (index == WTF::kNotFound)
+ return;
+ ++m_version;
+ m_vector.remove(index);
+ }
+
+ AgentsVector m_vector;
+ int m_version;
+ };
+
${accessor_list}
private:
@@ -115,7 +181,7 @@ ${member_list}
template_instrumenting_agent_accessor = string.Template("""
bool has${class_name}s() const { return ${has_member_name}; }
- const HeapHashSet<Member<${class_name}>>& ${getter_name}s() const { return ${member_name}; }
+ AgentsList<${class_name}>& ${getter_name}s() { return ${member_name}; }
void add${class_name}(${class_name}* agent);
void remove${class_name}(${class_name}* agent);""")
@@ -123,7 +189,7 @@ template_instrumenting_agent_impl = string.Template("""
void InstrumentingAgents::add${class_name}(${class_name}* agent)
{
${member_name}.add(agent);
- ${has_member_name} = true;
+ ${has_member_name} = !${member_name}.isEmpty();
}
void InstrumentingAgents::remove${class_name}(${class_name}* agent)
@@ -389,7 +455,7 @@ def generate_instrumenting_agents(used_agents):
getter_name=getter_name,
member_name=member_name,
has_member_name=has_member_name))
- member_list.append(" HeapHashSet<Member<%s>> %s;" % (class_name, member_name))
+ member_list.append(" AgentsList<%s> %s;" % (class_name, member_name))
member_list.append(" bool %s;" % has_member_name)
init_list.append("%s(false)" % has_member_name)
trace_list.append("visitor->trace(%s);" % member_name)
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/debugger/detach-when-paused-in-instrumentation-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698