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

Unified Diff: systrace/systrace/tracing_controller.py

Issue 3018533002: Implementing a Monsoon power monitor trace agent, utilizing the UI infrastructure that the BattOr a…
Patch Set: Updating static methods and fixing test fakes. Created 3 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: systrace/systrace/tracing_controller.py
diff --git a/systrace/systrace/tracing_controller.py b/systrace/systrace/tracing_controller.py
index d0d2d7c3735988f4b4904a0a980ae87baeee86c7..368f9cd68acad60c7dc82661577c921114c63889 100644
--- a/systrace/systrace/tracing_controller.py
+++ b/systrace/systrace/tracing_controller.py
@@ -117,9 +117,31 @@ class TracingController(object):
self._child_agents_with_config = agents_with_config
self._controller_agent = TracingControllerAgent()
self._controller_config = controller_config
+ self._connection_owner = None
self._trace_in_progress = False
self.all_results = None
+ # If we have a connection owner in the group, make an explicit reference to
+ # it. We need to collect data from it before any other collectors as it may
+ # re-enable USB for the subsequent collectors to collect their data.
+ # In addition, move this agent to the end of the list so it is the last
+ # to start (it could disable USB).
+ connection_owner_with_config = None
+ sorted_agents_with_config = []
+
+ for agent_with_config in self._child_agents_with_config:
+ if agent_with_config.agent.IsConnectionOwner():
+ if connection_owner_with_config is not None:
+ raise Exception("Multiple connection owners found.")
+ connection_owner_with_config = agent_with_config
+ else:
+ sorted_agents_with_config.append(agent_with_config)
+
+ if connection_owner_with_config:
+ sorted_agents_with_config.append(connection_owner_with_config)
+ self._connection_owner = connection_owner_with_config.agent
+ self._child_agents_with_config = sorted_agents_with_config
+
@property
def get_child_agents(self):
return self._child_agents
@@ -163,6 +185,7 @@ class TracingController(object):
if ns < na:
print 'Warning: Only %d of %d tracing agents started.' % (ns, na)
self._child_agents = succ_agents
+
return True
def StopTracing(self):
@@ -179,6 +202,14 @@ class TracingController(object):
assert self._trace_in_progress, 'No trace in progress.'
self._trace_in_progress = False
+ # Explicity stop the connection owner (if any) tracing first, as it may
+ # re-enable USB.
+ if self._connection_owner:
+ sync_id = GetUniqueSyncID()
+ if not self._connection_owner.StopCollectionWithClockSync(sync_id,
Zhen Wang 2017/09/28 01:58:48 Do we still need this |StopCollectionWithClockSync
+ ControllerAgentClockSync):
+ print 'Connection owner failed to stop collection.'
+
# Issue the clock sync marker and stop the child tracing agents.
self._IssueClockSyncMarker()
succ_agents = []

Powered by Google App Engine
This is Rietveld 408576698