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

Unified Diff: tools/android/loading/request_track.py

Issue 1619713002: Upgrade analyze.py and related scripts to new world order. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 11 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 | « tools/android/loading/request_dependencies_lens.py ('k') | tools/android/loading/trace_recorder.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/loading/request_track.py
diff --git a/tools/android/loading/request_track.py b/tools/android/loading/request_track.py
index e7338abbad866ec3fe583186516d2fb91b4dc4a6..e83dc302fd91b5e566b3b91c0d9ada3ef7ca8f30 100644
--- a/tools/android/loading/request_track.py
+++ b/tools/android/loading/request_track.py
@@ -9,7 +9,9 @@ When executed, parses a JSON dump of DevTools messages.
import collections
import copy
+import json
import logging
+import re
import devtools_monitor
@@ -25,6 +27,17 @@ _TIMING_NAMES_MAPPING = {
Timing = collections.namedtuple('Timing', _TIMING_NAMES_MAPPING.values())
+def TimingAsList(timing):
+ """Transform Timing to a list, eg as is used in JSON output.
+
+ Args:
+ timing: a Timing.
+
+ Returns:
+ A list identical to what the eventual JSON output will be (eg,
+ Request.ToJsonDict).
+ """
+ return json.loads(json.dumps(timing))
class Request(object):
"""Represents a single request.
@@ -102,8 +115,12 @@ class Request(object):
result = Request()
for (k, v) in data_dict.items():
setattr(result, k, v)
+ if not result.response_headers:
+ result.response_headers = {}
if result.timing:
result.timing = Timing(*result.timing)
+ else:
+ result.timing = TimingFromDict({'requestTime': result.timestamp})
return result
def GetContentType(self):
@@ -137,7 +154,10 @@ class Request(object):
or len(cache_control) == 0):
return -1
if 'max-age' in cache_control:
- return int(cache_control['max-age'])
+ age_match = re.match(r'\s*(\d+)+', cache_control['max-age'])
+ if not age_match:
+ return -1
+ return int(age_match.group(1))
return -1
def __eq__(self, o):
« no previous file with comments | « tools/android/loading/request_dependencies_lens.py ('k') | tools/android/loading/trace_recorder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698