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

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

Issue 2103673003: tools/android/loading: Properly detect page loading failures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | tools/android/loading/request_track.py » ('j') | 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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])
66 tracing_track = tracing.TracingTrack.FromJsonDict( 66 tracing_track = tracing.TracingTrack.FromJsonDict(
67 json_dict[cls._TRACING_KEY]) 67 json_dict[cls._TRACING_KEY])
68 return LoadingTrace(json_dict[cls._URL_KEY], json_dict[cls._METADATA_KEY], 68 return LoadingTrace(json_dict[cls._URL_KEY], json_dict[cls._METADATA_KEY],
69 page, request, tracing_track) 69 page, request, tracing_track)
70 70
71 def HasLoadingSucceed(self):
mattcary 2016/06/28 10:07:06 Move this to the tracing track. Then you can test
gabadie 2016/06/28 11:42:45 Makes sens. Done.
72 """Returns whether the loading has succeed at recording time."""
73 main_frame_id = self.tracing_track.GetMainFrameRoutingID()
74 for event in self.tracing_track.GetMatchingEvents(
75 'navigation', 'RenderFrameImpl::didFailProvisionalLoad'):
76 if event.args['id'] == main_frame_id:
77 return False
78 for event in self.tracing_track.GetMatchingEvents(
79 'navigation', 'RenderFrameImpl::didFailLoad'):
80 if event.args['id'] == main_frame_id:
81 return False
82 return True
83
71 @classmethod 84 @classmethod
72 def FromJsonFile(cls, json_path): 85 def FromJsonFile(cls, json_path):
73 """Returns an instance from a json file saved by ToJsonFile().""" 86 """Returns an instance from a json file saved by ToJsonFile()."""
74 with open(json_path) as input_file: 87 with open(json_path) as input_file:
75 return cls.FromJsonDict(json.load(input_file)) 88 return cls.FromJsonDict(json.load(input_file))
76 89
77 @classmethod 90 @classmethod
78 def RecordUrlNavigation( 91 def RecordUrlNavigation(
79 cls, url, connection, chrome_metadata, categories, 92 cls, url, connection, chrome_metadata, categories,
80 timeout_seconds=devtools_monitor.DEFAULT_TIMEOUT_SECONDS, 93 timeout_seconds=devtools_monitor.DEFAULT_TIMEOUT_SECONDS,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 """ 133 """
121 self._tracing_json_str = json.dumps(self._tracing_track.ToJsonDict()) 134 self._tracing_json_str = json.dumps(self._tracing_track.ToJsonDict())
122 self._tracing_track = None 135 self._tracing_track = None
123 136
124 def _RestoreTracingTrack(self): 137 def _RestoreTracingTrack(self):
125 if not self._tracing_json_str: 138 if not self._tracing_json_str:
126 return None 139 return None
127 self._tracing_track = tracing.TracingTrack.FromJsonDict( 140 self._tracing_track = tracing.TracingTrack.FromJsonDict(
128 json.loads(self._tracing_json_str)) 141 json.loads(self._tracing_json_str))
129 self._tracing_json_str = None 142 self._tracing_json_str = None
OLDNEW
« no previous file with comments | « no previous file | tools/android/loading/request_track.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698