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

Side by Side Diff: tools/android/loading/loading_trace.py

Issue 1923823003: clovis: Don't pretty-print JSON traces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « tools/android/loading/analyze.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Represents the trace of a page load.""" 5 """Represents the trace of a page load."""
6 6
7 import datetime 7 import datetime
8 import json 8 import json
9 import time 9 import time
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 self._PAGE_KEY: self.page_track.ToJsonDict(), 45 self._PAGE_KEY: self.page_track.ToJsonDict(),
46 self._REQUEST_KEY: self.request_track.ToJsonDict(), 46 self._REQUEST_KEY: self.request_track.ToJsonDict(),
47 self._TRACING_KEY: (self.tracing_track.ToJsonDict() 47 self._TRACING_KEY: (self.tracing_track.ToJsonDict()
48 if self.tracing_track else None)} 48 if self.tracing_track else None)}
49 return result 49 return result
50 50
51 def ToJsonFile(self, json_path): 51 def ToJsonFile(self, json_path):
52 """Save a json file representing this instance.""" 52 """Save a json file representing this instance."""
53 json_dict = self.ToJsonDict() 53 json_dict = self.ToJsonDict()
54 with open(json_path, 'w') as output_file: 54 with open(json_path, 'w') as output_file:
55 json.dump(json_dict, output_file, indent=2) 55 json.dump(json_dict, output_file)
56 56
57 @classmethod 57 @classmethod
58 def FromJsonDict(cls, json_dict): 58 def FromJsonDict(cls, json_dict):
59 """Returns an instance from a dictionary returned by ToJsonDict().""" 59 """Returns an instance from a dictionary returned by ToJsonDict()."""
60 keys = (cls._URL_KEY, cls._METADATA_KEY, cls._PAGE_KEY, cls._REQUEST_KEY, 60 keys = (cls._URL_KEY, cls._METADATA_KEY, cls._PAGE_KEY, cls._REQUEST_KEY,
61 cls._TRACING_KEY) 61 cls._TRACING_KEY)
62 assert all(key in json_dict for key in keys) 62 assert all(key in json_dict for key in keys)
63 page = page_track.PageTrack.FromJsonDict(json_dict[cls._PAGE_KEY]) 63 page = page_track.PageTrack.FromJsonDict(json_dict[cls._PAGE_KEY])
64 request = request_track.RequestTrack.FromJsonDict( 64 request = request_track.RequestTrack.FromJsonDict(
65 json_dict[cls._REQUEST_KEY]) 65 json_dict[cls._REQUEST_KEY])
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 """ 117 """
118 self._tracing_json_str = json.dumps(self._tracing_track.ToJsonDict()) 118 self._tracing_json_str = json.dumps(self._tracing_track.ToJsonDict())
119 self._tracing_track = None 119 self._tracing_track = None
120 120
121 def _RestoreTracingTrack(self): 121 def _RestoreTracingTrack(self):
122 if not self._tracing_json_str: 122 if not self._tracing_json_str:
123 return None 123 return None
124 self._tracing_track = tracing.TracingTrack.FromJsonDict( 124 self._tracing_track = tracing.TracingTrack.FromJsonDict(
125 json.loads(self._tracing_json_str)) 125 json.loads(self._tracing_json_str))
126 self._tracing_json_str = None 126 self._tracing_json_str = None
OLDNEW
« no previous file with comments | « tools/android/loading/analyze.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698