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

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

Issue 1708233002: tools/android/loading Ignore timings for requests coming from cache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fixIntegrationTests
Patch Set: Review comments Created 4 years, 10 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 | 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 """The request data track. 5 """The request data track.
6 6
7 When executed, parses a JSON dump of DevTools messages. 7 When executed, parses a JSON dump of DevTools messages.
8 """ 8 """
9 9
10 import bisect 10 import bisect
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 response = params['response'] 484 response = params['response']
485 _CopyFromDictToObject( 485 _CopyFromDictToObject(
486 response, r, (('status', 'status'), ('mimeType', 'mime_type'), 486 response, r, (('status', 'status'), ('mimeType', 'mime_type'),
487 ('fromDiskCache', 'from_disk_cache'), 487 ('fromDiskCache', 'from_disk_cache'),
488 ('fromServiceWorker', 'from_service_worker'), 488 ('fromServiceWorker', 'from_service_worker'),
489 ('protocol', 'protocol'), 489 ('protocol', 'protocol'),
490 # Actual request headers are not known before reaching the 490 # Actual request headers are not known before reaching the
491 # network stack. 491 # network stack.
492 ('requestHeaders', 'request_headers'), 492 ('requestHeaders', 'request_headers'),
493 ('headers', 'response_headers'))) 493 ('headers', 'response_headers')))
494 # data URLs don't have a timing dict.
495 timing_dict = {} 494 timing_dict = {}
496 if r.protocol != 'data': 495 # data URLs don't have a timing dict, and timings for cached requests are
496 # stale.
497 # TODO(droger): the timestamp is inacurate, get the real timings instead.
498 if r.protocol == 'data' or r.served_from_cache:
499 timing_dict = {'requestTime': r.timestamp}
500 else:
497 timing_dict = response['timing'] 501 timing_dict = response['timing']
498 else:
499 timing_dict = {'requestTime': r.timestamp}
500 r.timing = TimingFromDict(timing_dict) 502 r.timing = TimingFromDict(timing_dict)
501 self._requests_in_flight[request_id] = (r, RequestTrack._STATUS_RESPONSE) 503 self._requests_in_flight[request_id] = (r, RequestTrack._STATUS_RESPONSE)
502 self._request_id_to_response_received[request_id] = params 504 self._request_id_to_response_received[request_id] = params
503 505
504 def _DataReceived(self, request_id, params): 506 def _DataReceived(self, request_id, params):
505 (r, status) = self._requests_in_flight[request_id] 507 (r, status) = self._requests_in_flight[request_id]
506 assert (status == RequestTrack._STATUS_RESPONSE 508 assert (status == RequestTrack._STATUS_RESPONSE
507 or status == RequestTrack._STATUS_DATA) 509 or status == RequestTrack._STATUS_DATA)
508 offset = r._TimestampOffsetFromStartMs(params['timestamp']) 510 offset = r._TimestampOffsetFromStartMs(params['timestamp'])
509 r.data_chunks.append((offset, params['encodedDataLength'])) 511 r.data_chunks.append((offset, params['encodedDataLength']))
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 566
565 567
566 if __name__ == '__main__': 568 if __name__ == '__main__':
567 import json 569 import json
568 import sys 570 import sys
569 events = json.load(open(sys.argv[1], 'r')) 571 events = json.load(open(sys.argv[1], 'r'))
570 request_track = RequestTrack(None) 572 request_track = RequestTrack(None)
571 for event in events: 573 for event in events:
572 event_method = event['method'] 574 event_method = event['method']
573 request_track.Handle(event_method, event) 575 request_track.Handle(event_method, event)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698