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

Unified Diff: tools/android/loading/loading_model.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: 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
Index: tools/android/loading/loading_model.py
diff --git a/tools/android/loading/loading_model.py b/tools/android/loading/loading_model.py
index 7ba75fc79b4bfa41a8e738d23bd71fa99d3484d0..e1d6a66ce4276c8e0bc3e0f57b534bd37f4e16aa 100644
--- a/tools/android/loading/loading_model.py
+++ b/tools/android/loading/loading_model.py
@@ -290,9 +290,26 @@ class ResourceGraph(object):
## Internal items
##
- _CONTENT_TYPE_TO_COLOR = {'html': 'red', 'css': 'green', 'script': 'blue',
- 'json': 'purple', 'gif_image': 'grey',
- 'image': 'orange', 'other': 'white'}
+ _CONTENT_KIND_TO_COLOR = {
blundell 2016/01/21 14:11:38 Worth documenting what these mean?
mattcary 2016/01/21 16:11:35 Done.
+ 'application': 'blue',
+ 'font': 'grey2',
+ 'image': 'orange', # This probably catches gifs?
Benoit L 2016/01/21 14:14:38 it does.
mattcary 2016/01/21 16:11:35 Then this isn't what we want. Well, let me land th
Benoit L 2016/01/21 16:20:03 About as high as deciding on the bike shed color.
+ }
+
+ _CONTENT_TYPE_TO_COLOR = {
+ 'html': 'red',
+ 'css': 'green',
+ 'script': 'blue',
+ 'javascript': 'blue',
+ 'json': 'purple',
+ 'gif': 'grey',
+ 'image': 'orange',
+ 'jpeg': 'orange',
+ 'png': 'orange',
+ 'plain': 'brown3',
+ 'octet-stream': 'brown3',
+ 'other': 'white',
+ }
# This resource type may induce a timing dependency. See _SplitChildrenByTime
# for details.
@@ -363,19 +380,20 @@ class ResourceGraph(object):
"""
parsed = urlparse.urlparse(self._request.url)
path = parsed.path
+ hostname = parsed.hostname if parsed.hostname else '?.?.?'
if path != '' and path != '/':
last_path = parsed.path.split('/')[-1]
if len(last_path) < 10:
if len(path) < 10:
- return parsed.hostname + '/' + path
+ return hostname + '/' + path
else:
- return parsed.hostname + '/..' + parsed.path[-10:]
+ return hostname + '/..' + parsed.path[-10:]
elif len(last_path) > 10:
- return parsed.hostname + '/..' + last_path[:5]
+ return hostname + '/..' + last_path[:5]
else:
- return parsed.hostname + '/..' + last_path
+ return hostname + '/..' + last_path
else:
- return parsed.hostname
+ return hostname
def Url(self):
return self._request.url
@@ -463,7 +481,7 @@ class ResourceGraph(object):
dependencies = request_dependencies_lens.RequestDependencyLens(
trace).GetRequestDependencies()
- for child_rq, parent_rq, reason in dependencies:
+ for parent_rq, child_rq, reason in dependencies:
parent = self._node_info[index_by_request[parent_rq]]
child = self._node_info[index_by_request[child_rq]]
edge_cost = child.StartTime() - parent.EndTime()
@@ -549,6 +567,17 @@ class ResourceGraph(object):
current.ReparentTo(parent, children_by_end_time[end_mark])
children_by_end_time[end_mark].AddEdgeAnnotation(current, 'timing')
+ def _ContentTypeToColor(self, content_type):
+ if not content_type:
+ type_str = 'other'
+ elif '/' in content_type:
+ kind, type_str = content_type.split('/')
+ if kind in self._CONTENT_KIND_TO_COLOR:
blundell 2016/01/21 14:11:38 hmm, also probably worth documenting the relations
mattcary 2016/01/21 16:11:35 I don't really know how these mime-types work. I t
+ return self._CONTENT_KIND_TO_COLOR[kind]
+ else:
+ type_str = content_type
+ return self._CONTENT_TYPE_TO_COLOR[type_str]
+
def _GraphvizNode(self, index, highlight):
"""Returns a graphviz node description for a given node.
@@ -563,7 +592,7 @@ class ResourceGraph(object):
is oval if its max-age is less than 300s (or if it's not cacheable).
"""
node_info = self._node_info[index]
- color = self._CONTENT_TYPE_TO_COLOR[node_info.ContentType()]
+ color = self._ContentTypeToColor(node_info.ContentType())
max_age = node_info.Request().MaxAge()
shape = 'polygon' if max_age > 300 else 'oval'
styles = ['filled']

Powered by Google App Engine
This is Rietveld 408576698