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

Side by Side Diff: tracing/tracing/model/user_model/load_expectation.html

Issue 2020813002: Rewrite LoadExpectation to v1.0. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: . Created 4 years, 6 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 | « tracing/tracing/model/instant_event.html ('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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2015 The Chromium Authors. All rights reserved. 3 Copyright (c) 2015 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/model/user_model/user_expectation.html"> 8 <link rel="import" href="/tracing/model/user_model/user_expectation.html">
9 9
10 <script> 10 <script>
11 'use strict'; 11 'use strict';
12 12
13 tr.exportTo('tr.model.um', function() { 13 tr.exportTo('tr.model.um', function() {
14 var LoadEvents = {
15 /**
16 * Returns true if event is relevant to loading.
17 *
18 * @param {!tr.model.Event} event
19 * @return {boolean}
20 */
21 isLoadEvent: function(event) {
22 return LoadEvents.isRenderFrameImplEvent(event) ||
23 LoadEvents.isStartEvent(event) ||
24 LoadEvents.isEndEvent(event) ||
25 LoadEvents.isPaintEvent(event) ||
26 LoadEvents.isLayoutEvent(event);
27 },
28
29 isLayoutEvent: function(event) {
30 return event.title === 'FrameView::performLayout';
31 },
32
33 /**
34 * Returns true if event could signify the start of a load.
35 *
36 * @param {!tr.model.Event} event
37 * @return {boolean}
38 */
39 isStartEvent: function(event) {
40 return LoadEvents.isOnNavigateEvent(event) ||
41 LoadEvents.isNavigationStartEvent(event) ||
42 LoadEvents.isStartProvisionalEvent(event) ||
43 LoadEvents.isStartLoadingEvent(event) ||
44 LoadEvents.isCommitEvent(event);
45 },
46
47 isRenderFrameImplEvent: function(event) {
48 return event.title.indexOf('RenderFrameImpl::') === 0;
49 },
50
51 /**
52 * Returns true if event could be considered to signify the end of a Load.
53 *
54 * @param {!tr.model.Event} event
55 * @return {boolean}
56 */
57 isEndEvent: function(event) {
58 return LoadEvents.isFailEvent(event) ||
59 LoadEvents.isFinishDocumentEvent(event) ||
60 LoadEvents.isFirstContentfulPaintEvent(event) ||
61 LoadEvents.isLoadFinishedEvent(event) ||
62 LoadEvents.isFinishLoadEvent(event);
63 },
64
65 isFinishLoadEvent: function(event) {
66 return event.title === 'RenderFrameImpl::didFinishLoad';
67 },
68
69 isLoadFinishedEvent: function(event) {
70 return ((event.title === 'LoadFinished') &&
71 tr.b.hasCategory(event.category, 'WebCore'));
72 },
73
74 isFinishDocumentEvent: function(event) {
75 return event.title === 'RenderFrameImpl::didFinishDocumentLoad';
76 },
77
78 /**
79 * Returns true if event signifies failure of a load.
80 *
81 * @param {!tr.model.Event} event
82 * @return {boolean}
83 */
84 isFailEvent: function(event) {
85 return ((event.title === 'RenderFrameImpl::didFailLoad') ||
86 (event.title === 'RenderFrameImpl::didFailProvisionalLoad'));
87 },
88
89 isPaintEvent: function(event) {
90 return ((event.title === 'Paint') &&
91 tr.b.hasCategory(event.category, 'devtools.timeline'));
92 },
93
94 isStartLoadingEvent: function(event) {
95 return event.title === 'RenderFrameImpl::didStartLoading';
96 },
97
98 isCommitEvent: function(event) {
99 return event.title === 'RenderFrameImpl::didCommitProvisionalLoad';
100 },
101
102 isStartProvisionalEvent: function(event) {
103 return event.title === 'RenderFrameImpl::didStartProvisionalLoad';
104 },
105
106 // This render-process instant event marks the first contentful paint in a
107 // main frame.
108 isFirstContentfulPaintEvent: function(event) {
109 return event.title === 'firstContentfulPaint';
110 },
111
112 isNavigationStartEvent: function(event) {
113 return event.title === 'NavigationTiming navigationStart';
114 },
115
116 isOnNavigateEvent: function(event) {
117 return event.title === 'RenderFrameImpl::OnNavigate';
118 },
119
120 findRenderFrameSnapshotForEvent: function(event) {
121 var renderFrameSnapshot = undefined;
122 event.contexts.forEach(function(context) {
123 if (context.type === 'FrameBlameContext')
124 renderFrameSnapshot = context.snapshot;
125 else if (context.type === 'FrameTreeNodeBlameContext')
126 renderFrameSnapshot = context.snapshot.renderFrameSnapshot;
127 });
128
129 if (renderFrameSnapshot === undefined)
130 throw new Error('Unable to find frame for ' + event.title);
131
132 return renderFrameSnapshot;
133 }
134 };
135
14 var LOAD_SUBTYPE_NAMES = { 136 var LOAD_SUBTYPE_NAMES = {
15 SUCCESSFUL: 'Successful', 137 SUCCESSFUL: 'Successful',
16 FAILED: 'Failed', 138 FAILED: 'Failed',
17 }; 139 };
18 140
19 var DOES_LOAD_SUBTYPE_NAME_EXIST = {}; 141 var DOES_LOAD_SUBTYPE_NAME_EXIST = {};
20 for (var key in LOAD_SUBTYPE_NAMES) { 142 for (var key in LOAD_SUBTYPE_NAMES) {
21 DOES_LOAD_SUBTYPE_NAME_EXIST[LOAD_SUBTYPE_NAMES[key]] = true;; 143 DOES_LOAD_SUBTYPE_NAME_EXIST[LOAD_SUBTYPE_NAMES[key]] = true;;
22 } 144 }
23 145
24 function LoadExpectation(parentModel, initiatorTitle, start, duration) { 146 function LoadExpectation(parentModel, initiatorTitle, start, duration) {
25 if (!DOES_LOAD_SUBTYPE_NAME_EXIST[initiatorTitle]) 147 if (!DOES_LOAD_SUBTYPE_NAME_EXIST[initiatorTitle])
26 throw new Error(initiatorTitle + ' is not in LOAD_SUBTYPE_NAMES'); 148 throw new Error(initiatorTitle + ' is not in LOAD_SUBTYPE_NAMES');
27 149
28 tr.model.um.UserExpectation.call( 150 tr.model.um.UserExpectation.call(
29 this, parentModel, initiatorTitle, start, duration); 151 this, parentModel, initiatorTitle, start, duration);
30 152
31 // |renderProcess| is the renderer process that contains the loading 153 this.navigationEvent_ = undefined;
32 // RenderFrame. 154 this.frameTreeNodeSnapshot_ = undefined;
33 this.renderProcess = undefined; 155 this.layoutEvents_ = undefined;
34 156 this.paintEvents_ = undefined;
35 // |renderMainThread| is the CrRendererMain thread in the |renderProcess| 157 this.firstMeaningfulPaintEvent_ = undefined;
36 // that contains the loading RenderFrame.
37 this.renderMainThread = undefined;
38
39 // |routingId| identifies the loading RenderFrame within the renderer
40 // process.
41 this.routingId = undefined;
42
43 // |parentRoutingId| identifies the RenderFrame that created and contains
44 // the loading RenderFrame.
45 this.parentRoutingId = undefined;
46
47 // |loadFinishedEvent|, if present, signals that this is a main frame.
48 this.loadFinishedEvent = undefined;
49
50 // Startup LoadIRs do not have renderProcess, routingId, or
51 // parentRoutingId. Maybe RenderLoadIR should be a separate class?
52 } 158 }
53 159
54 LoadExpectation.prototype = { 160 LoadExpectation.prototype = {
55 __proto__: tr.model.um.UserExpectation.prototype, 161 __proto__: tr.model.um.UserExpectation.prototype,
56 constructor: LoadExpectation 162 constructor: LoadExpectation,
163
164 get frameTreeNodeSnapshot() {
165 if (this.frameTreeNodeSnapshot_ === undefined) {
166 this.associatedEvents.forEach(function(event) {
167 var renderFrameSnapshot = LoadEvents.findRenderFrameSnapshotForEvent(
168 event);
169 if (renderFrameSnapshot) {
170 this.frameTreeNodeSnapshot_ =
171 renderFrameSnapshot.frameTreeNodeSnapshot;
172 }
173 }, this);
174 }
175 return this.frameTreeNodeSnapshot_;
176 },
177
178 get navigationEvent() {
179 if (this.navigationEvent_ === undefined) {
180 this.associatedEvents.forEach(function(event) {
181 if ((this.navigationEvent_ === undefined) &&
182 (LoadEvents.isNavigationStartEvent(event) ||
183 LoadEvents.isOnNavigateEvent(event)))
184 this.navigationEvent_ = event;
185 }, this);
186 }
187 return this.navigationEvent_;
188 },
189
190 get layoutEvents() {
191 if (this.layoutEvents_ === undefined) {
192 this.layoutEvents_ = new tr.model.EventSet();
193 this.associatedEvents.forEach(function(event) {
194 if (event.title === PERFORM_LAYOUT_TITLE)
195 this.layoutEvents_.push(event);
196 }, this);
197 }
198 return this.layoutEvents_;
199 },
200
201 get paintEvents() {
202 if (this.paintEvents_ === undefined) {
203 this.paintEvents_ = new tr.model.EventSet();
204 this.associatedEvents.forEach(function(event) {
205 if (event.title === DEVTOOLS_PAINT_TITLE)
206 this.paintEvents_.push(event);
207 }, this);
208 }
209 return this.paintEvents_;
210 },
211
212 get firstContentfulPaintEvent() {
213 if (this.firstContentfulPaintEvent_ === undefined) {
214 this.associatedEvents.forEach(function(event) {
215 if (event.title === FIRST_CONTENTFUL_PAINT_TITLE)
216 this.firstContentfulPaintEvent_ = event;
217 }, this);
218 }
219 return this.firstContentfulPaintEvent_;
220 },
221
222 get firstMeaningfulPaintEvent() {
223 if (this.firstMeaningfulPaintEvent_ === undefined) {
224 // TODO(ksakamoto): Find FMP.
225 }
226 return this.firstMeaningfulPaintEvent_;
227 }
57 }; 228 };
58 229
59 tr.model.um.UserExpectation.register(LoadExpectation, { 230 tr.model.um.UserExpectation.register(LoadExpectation, {
60 stageTitle: 'Load', 231 stageTitle: 'Load',
61 colorId: tr.b.ColorScheme.getColorIdForReservedName('rail_load') 232 colorId: tr.b.ColorScheme.getColorIdForReservedName('rail_load')
62 }); 233 });
63 234
64 return { 235 return {
65 LOAD_SUBTYPE_NAMES: LOAD_SUBTYPE_NAMES, 236 LOAD_SUBTYPE_NAMES: LOAD_SUBTYPE_NAMES,
237 LoadEvents: LoadEvents,
66 LoadExpectation: LoadExpectation 238 LoadExpectation: LoadExpectation
67 }; 239 };
68 }); 240 });
69 </script> 241 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/model/instant_event.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698