blob: 948316da1ed732a46bda675f5ee9c62aa3780933 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<!DOCTYPE html>
<!--
Copyright (c) 2013 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/tracing/model/async_slice.html">
<script>
'use strict';
tr.exportTo('tr.e.net', function() {
var AsyncSlice = tr.model.AsyncSlice;
function NetAsyncSlice() {
AsyncSlice.apply(this, arguments);
this.url_ = undefined;
this.byteCount_ = undefined;
// Boolean variables indicating whether we have computed corresponding
// fields. Computing these fields needs iteration through all sub-slices and
// so recomputation will be costly.
this.isTitleComputed_ = false;
this.isUrlComputed_ = false;
}
NetAsyncSlice.prototype = {
__proto__: AsyncSlice.prototype,
get viewSubGroupTitle() {
return 'NetLog';
},
get title() {
if (this.isTitleComputed_ || !this.isTopLevel)
return this.title_;
if (this.url !== undefined && this.url.length > 0) {
// Set the title so we do not have to recompute when it is redrawn.
this.title_ = this.url;
} else if (this.args !== undefined &&
this.args.source_type !== undefined) {
// We do not have a URL, use the source type as the title.
this.title_ = this.args.source_type;
}
this.isTitleComputed_ = true;
return this.title_;
},
set title(title) {
this.title_ = title;
},
// A recursive helper function that gets the url param of a slice or its
// nested subslices if there is one.
get url() {
if (this.isUrlComputed_)
return this.url_;
if (this.args !== undefined && this.args.params !== undefined &&
this.args.params.url !== undefined) {
this.url_ = this.args.params.url;
} else if (this.subSlices !== undefined && this.subSlices.length > 0) {
for (var i = 0; i < this.subSlices.length && ! this.url_; i++) {
if (this.subSlices[i].url !== undefined)
this.url_ = this.subSlices[i].url;
}
}
this.isUrlComputed_ = true;
return this.url_;
},
get byteCount() {
if (this.byteCount_ !== undefined)
return this.byteCount_;
this.byteCount_ = 0;
if ((this.originalTitle === 'URL_REQUEST_JOB_FILTERED_BYTES_READ' ||
this.originalTitle === 'URL_REQUEST_JOB_BYTES_READ') &&
this.args !== undefined && this.args.params !== undefined &&
this.args.params.byte_count !== undefined) {
this.byteCount_ = this.args.params.byte_count;
}
for (var i = 0; i < this.subSlices.length; i++) {
this.byteCount_ += this.subSlices[i].byteCount;
}
return this.byteCount_;
}
};
AsyncSlice.subTypes.register(
NetAsyncSlice,
{
categoryParts: ['netlog', 'disabled-by-default-netlog']
});
return {
NetAsyncSlice: NetAsyncSlice
};
});
</script>
|