Chromium Code Reviews| Index: tools/android/loading/user_satisfied_lens.py |
| diff --git a/tools/android/loading/user_satisfied_lens.py b/tools/android/loading/user_satisfied_lens.py |
| index 89ce7a1ca5120c3a03eccf2ac39d4f62e0dc47e0..eb34abc20e0ca280acced920dce3f773e5b248a9 100644 |
| --- a/tools/android/loading/user_satisfied_lens.py |
| +++ b/tools/android/loading/user_satisfied_lens.py |
| @@ -91,6 +91,11 @@ class _FirstEventLens(_UserSatisfiedLens): |
| # pylint: disable=abstract-method |
| @classmethod |
| + def _CheckCategory(cls, tracing_track, category): |
| + assert category in tracing_track.Categories(), ( |
| + 'The "%s" category must be enabled.' % category) |
| + |
| + @classmethod |
| def _ExtractFirstTiming(cls, times): |
| if not times: |
| return float('inf') |
| @@ -106,9 +111,11 @@ class FirstTextPaintLens(_FirstEventLens): |
| This event is taken directly from a trace. |
| """ |
| + _EVENT_CATEGORY = 'blink.user_timing' |
| def _CalculateTimes(self, tracing_track): |
| + self._CheckCategory(tracing_track, self._EVENT_CATEGORY) |
| first_paints = [e.start_msec for e in tracing_track.GetEvents() |
| - if e.Matches('blink.user_timing', 'firstPaint')] |
| + if e.Matches(self._EVENT_CATEGORY, 'firstPaint')] |
| self._satisfied_msec = self._event_msec = \ |
| self._ExtractFirstTiming(first_paints) |
| @@ -119,9 +126,11 @@ class FirstContentfulPaintLens(_FirstEventLens): |
| This event is taken directly from a trace. Internally to chrome it's computed |
| by filtering out things like background paint from firstPaint. |
| """ |
| + _EVENT_CATEGORY = 'blink.user_timing' |
| def _CalculateTimes(self, tracing_track): |
| + self._CheckCategory(tracing_track, self._EVENT_CATEGORY) |
| first_paints = [e.start_msec for e in tracing_track.GetEvents() |
| - if e.Matches('blink.user_timing', 'firstContentfulPaint')] |
| + if e.Matches(self._EVENT_CATEGORY, 'firstContentfulPaint')] |
| self._satisfied_msec = self._event_msec = \ |
| self._ExtractFirstTiming(first_paints) |
| @@ -134,8 +143,9 @@ class FirstSignificantPaintLens(_FirstEventLens): |
| that is the observable event. |
| """ |
| FIRST_LAYOUT_COUNTER = 'LayoutObjectsThatHadNeverHadLayout' |
|
mattcary
2016/04/27 08:00:04
While you're in here add an underscore to FIRST_LA
|
| - |
| + _EVENT_CATEGORY = 'disabled-by-default-blink.debug.layout' |
| def _CalculateTimes(self, tracing_track): |
| + self._CheckCategory(tracing_track, self._EVENT_CATEGORY) |
| sync_paint_times = [] |
| layouts = [] # (layout item count, msec). |
| for e in tracing_track.GetEvents(): |
| @@ -147,8 +157,7 @@ class FirstSignificantPaintLens(_FirstEventLens): |
| self.FIRST_LAYOUT_COUNTER in e.args['counters']): |
| layouts.append((e.args['counters'][self.FIRST_LAYOUT_COUNTER], |
| e.start_msec)) |
| - assert layouts, ('No layout events, was the disabled-by-default-blink' |
| - '.debug.layout category enabled?') |
| + assert layouts, 'No layout events' |
| layouts.sort(key=operator.itemgetter(0), reverse=True) |
| self._satisfied_msec = layouts[0][1] |
| self._event_msec = self._ExtractFirstTiming([ |