blob: ba324a47202cefaa044965b51b75cf6b4fc5b1fe [file] [log] [blame]
Hongchan Choi7dd0b3e2019-05-13 21:19:031// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Tim van der Lippec02a97c2020-02-14 14:39:275import * as Common from '../common/common.js'; // eslint-disable-line no-unused-vars
Tim van der Lippe9081c902020-01-24 14:32:426import * as SDK from '../sdk/sdk.js'; // eslint-disable-line no-unused-vars
7import * as UI from '../ui/ui.js';
8
Hongchan Choi0927e702020-01-15 20:13:379import {ContextDetailBuilder, ContextSummaryBuilder} from './AudioContextContentBuilder.js';
10import {AudioContextSelector, Events as SelectorEvents} from './AudioContextSelector.js';
11import {GraphManager} from './graph_visualizer/GraphManager.js';
12import {Events as ModelEvents, WebAudioModel} from './WebAudioModel.js';
13
Hongchan Choi7dd0b3e2019-05-13 21:19:0314/**
Tim van der Lippe9081c902020-01-24 14:32:4215 * @implements {SDK.SDKModel.SDKModelObserver<!WebAudioModel>}
Hongchan Choi7dd0b3e2019-05-13 21:19:0316 */
Tim van der Lippe9081c902020-01-24 14:32:4217export class WebAudioView extends UI.ThrottledWidget.ThrottledWidget {
Hongchan Choi7dd0b3e2019-05-13 21:19:0318 constructor() {
19 super(true, 1000);
20 this.element.classList.add('web-audio-drawer');
21 this.registerRequiredCSS('web_audio/webAudio.css');
22
23 // Creates the toolbar.
Hongchan Choi0927e702020-01-15 20:13:3724 const toolbarContainer = this.contentElement.createChild('div', 'web-audio-toolbar-container vbox');
25 this._contextSelector = new AudioContextSelector();
Tim van der Lippe9081c902020-01-24 14:32:4226 const toolbar = new UI.Toolbar.Toolbar('web-audio-toolbar', toolbarContainer);
27 toolbar.appendToolbarItem(UI.Toolbar.Toolbar.createActionButtonForId('components.collect-garbage'));
Hongchan Choi7dd0b3e2019-05-13 21:19:0328 toolbar.appendSeparator();
29 toolbar.appendToolbarItem(this._contextSelector.toolbarItem());
30
John Emauc7d63f92020-01-15 20:15:4531 // Create content container
32 this._contentContainer = this.contentElement.createChild('div', 'web-audio-content-container vbox flex-auto');
33
Hongchan Choi7dd0b3e2019-05-13 21:19:0334 // Creates the detail view.
John Emauc7d63f92020-01-15 20:15:4535 this._detailViewContainer = this._contentContainer.createChild('div', 'web-audio-details-container vbox flex-auto');
Hongchan Choi7dd0b3e2019-05-13 21:19:0336
Hongchan Choi0927e702020-01-15 20:13:3737 this._graphManager = new GraphManager();
Gaoping Huanga471b302019-08-23 16:48:2938
Hongchan Choi7dd0b3e2019-05-13 21:19:0339 // Creates the landing page.
Tim van der Lippe9081c902020-01-24 14:32:4240 this._landingPage = new UI.Widget.VBox();
Hongchan Choi7dd0b3e2019-05-13 21:19:0341 this._landingPage.contentElement.classList.add('web-audio-landing-page', 'fill');
Tim van der Lippe9081c902020-01-24 14:32:4242 this._landingPage.contentElement.appendChild(UI.Fragment.html`
Hongchan Choi7dd0b3e2019-05-13 21:19:0343 <div>
44 <p>${ls`Open a page that uses Web Audio API to start monitoring.`}</p>
45 </div>
46 `);
47 this._landingPage.show(this._detailViewContainer);
48
49 // Creates the summary bar.
John Emauc7d63f92020-01-15 20:15:4550 this._summaryBarContainer = this._contentContainer.createChild('div', 'web-audio-summary-container');
Hongchan Choi7dd0b3e2019-05-13 21:19:0351
Hongchan Choi0927e702020-01-15 20:13:3752 this._contextSelector.addEventListener(SelectorEvents.ContextSelected, event => {
Hongchan Choi7dd0b3e2019-05-13 21:19:0353 const context =
54 /** @type {!Protocol.WebAudio.BaseAudioContext} */ (event.data);
55 this._updateDetailView(context);
56 this.doUpdate();
57 });
58
Paul Lewisdaac1062020-03-05 14:37:1059 SDK.SDKModel.TargetManager.instance().observeModels(WebAudioModel, this);
Hongchan Choi7dd0b3e2019-05-13 21:19:0360 }
61
62 /**
63 * @override
64 */
65 wasShown() {
Hongchan Choide21c962019-06-06 22:15:0866 super.wasShown();
Paul Lewisdaac1062020-03-05 14:37:1067 for (const model of SDK.SDKModel.TargetManager.instance().models(WebAudioModel)) {
Hongchan Choi7dd0b3e2019-05-13 21:19:0368 this._addEventListeners(model);
Tim van der Lippe1d6e57a2019-09-30 11:55:3469 }
Hongchan Choi7dd0b3e2019-05-13 21:19:0370 }
71
72 /**
73 * @override
74 */
75 willHide() {
Paul Lewisdaac1062020-03-05 14:37:1076 for (const model of SDK.SDKModel.TargetManager.instance().models(WebAudioModel)) {
Hongchan Choi7dd0b3e2019-05-13 21:19:0377 this._removeEventListeners(model);
Tim van der Lippe1d6e57a2019-09-30 11:55:3478 }
Hongchan Choi7dd0b3e2019-05-13 21:19:0379 }
80
81 /**
82 * @override
Hongchan Choi0927e702020-01-15 20:13:3783 * @param {!WebAudioModel} webAudioModel
Hongchan Choi7dd0b3e2019-05-13 21:19:0384 */
85 modelAdded(webAudioModel) {
Tim van der Lippe1d6e57a2019-09-30 11:55:3486 if (this.isShowing()) {
Hongchan Choi7dd0b3e2019-05-13 21:19:0387 this._addEventListeners(webAudioModel);
Tim van der Lippe1d6e57a2019-09-30 11:55:3488 }
Hongchan Choi7dd0b3e2019-05-13 21:19:0389 }
90
91 /**
92 * @override
Hongchan Choi0927e702020-01-15 20:13:3793 * @param {!WebAudioModel} webAudioModel
Hongchan Choi7dd0b3e2019-05-13 21:19:0394 */
95 modelRemoved(webAudioModel) {
96 this._removeEventListeners(webAudioModel);
97 }
98
99 /**
100 * @override
101 * @return {!Promise<?>}
102 */
103 async doUpdate() {
104 await this._pollRealtimeData();
105 this.update();
106 }
107
108 /**
Hongchan Choi0927e702020-01-15 20:13:37109 * @param {!WebAudioModel} webAudioModel
Hongchan Choi7dd0b3e2019-05-13 21:19:03110 */
111 _addEventListeners(webAudioModel) {
112 webAudioModel.ensureEnabled();
Hongchan Choi0927e702020-01-15 20:13:37113 webAudioModel.addEventListener(ModelEvents.ContextCreated, this._contextCreated, this);
114 webAudioModel.addEventListener(ModelEvents.ContextDestroyed, this._contextDestroyed, this);
115 webAudioModel.addEventListener(ModelEvents.ContextChanged, this._contextChanged, this);
116 webAudioModel.addEventListener(ModelEvents.ModelReset, this._reset, this);
117 webAudioModel.addEventListener(ModelEvents.ModelSuspend, this._suspendModel, this);
118 webAudioModel.addEventListener(ModelEvents.AudioListenerCreated, this._audioListenerCreated, this);
119 webAudioModel.addEventListener(ModelEvents.AudioListenerWillBeDestroyed, this._audioListenerWillBeDestroyed, this);
120 webAudioModel.addEventListener(ModelEvents.AudioNodeCreated, this._audioNodeCreated, this);
121 webAudioModel.addEventListener(ModelEvents.AudioNodeWillBeDestroyed, this._audioNodeWillBeDestroyed, this);
122 webAudioModel.addEventListener(ModelEvents.AudioParamCreated, this._audioParamCreated, this);
123 webAudioModel.addEventListener(ModelEvents.AudioParamWillBeDestroyed, this._audioParamWillBeDestroyed, this);
124 webAudioModel.addEventListener(ModelEvents.NodesConnected, this._nodesConnected, this);
125 webAudioModel.addEventListener(ModelEvents.NodesDisconnected, this._nodesDisconnected, this);
126 webAudioModel.addEventListener(ModelEvents.NodeParamConnected, this._nodeParamConnected, this);
127 webAudioModel.addEventListener(ModelEvents.NodeParamDisconnected, this._nodeParamDisconnected, this);
Hongchan Choi7dd0b3e2019-05-13 21:19:03128 }
129
130 /**
Paul Lewis9f21a772020-10-05 13:22:08131 * @param {!WebAudioModel} webAudioModel
Hongchan Choi7dd0b3e2019-05-13 21:19:03132 */
133 _removeEventListeners(webAudioModel) {
Hongchan Choi0927e702020-01-15 20:13:37134 webAudioModel.removeEventListener(ModelEvents.ContextCreated, this._contextCreated, this);
135 webAudioModel.removeEventListener(ModelEvents.ContextDestroyed, this._contextDestroyed, this);
136 webAudioModel.removeEventListener(ModelEvents.ContextChanged, this._contextChanged, this);
137 webAudioModel.removeEventListener(ModelEvents.ModelReset, this._reset, this);
138 webAudioModel.removeEventListener(ModelEvents.ModelSuspend, this._suspendModel, this);
139 webAudioModel.removeEventListener(ModelEvents.AudioListenerCreated, this._audioListenerCreated, this);
Gaoping Huanga471b302019-08-23 16:48:29140 webAudioModel.removeEventListener(
Hongchan Choi0927e702020-01-15 20:13:37141 ModelEvents.AudioListenerWillBeDestroyed, this._audioListenerWillBeDestroyed, this);
142 webAudioModel.removeEventListener(ModelEvents.AudioNodeCreated, this._audioNodeCreated, this);
143 webAudioModel.removeEventListener(ModelEvents.AudioNodeWillBeDestroyed, this._audioNodeWillBeDestroyed, this);
144 webAudioModel.removeEventListener(ModelEvents.AudioParamCreated, this._audioParamCreated, this);
145 webAudioModel.removeEventListener(ModelEvents.AudioParamWillBeDestroyed, this._audioParamWillBeDestroyed, this);
146 webAudioModel.removeEventListener(ModelEvents.NodesConnected, this._nodesConnected, this);
147 webAudioModel.removeEventListener(ModelEvents.NodesDisconnected, this._nodesDisconnected, this);
148 webAudioModel.removeEventListener(ModelEvents.NodeParamConnected, this._nodeParamConnected, this);
149 webAudioModel.removeEventListener(ModelEvents.NodeParamDisconnected, this._nodeParamDisconnected, this);
Hongchan Choi7dd0b3e2019-05-13 21:19:03150 }
151
152 /**
Tim van der Lippec02a97c2020-02-14 14:39:27153 * @param {!Common.EventTarget.EventTargetEvent} event
Hongchan Choi7dd0b3e2019-05-13 21:19:03154 */
155 _contextCreated(event) {
Gaoping Huanga471b302019-08-23 16:48:29156 const context = /** @type {!Protocol.WebAudio.BaseAudioContext} */ (event.data);
157 this._graphManager.createContext(context.contextId);
Hongchan Choi7dd0b3e2019-05-13 21:19:03158 this._contextSelector.contextCreated(event);
159 }
160
161 /**
Tim van der Lippec02a97c2020-02-14 14:39:27162 * @param {!Common.EventTarget.EventTargetEvent} event
Hongchan Choi7dd0b3e2019-05-13 21:19:03163 */
164 _contextDestroyed(event) {
Gaoping Huanga471b302019-08-23 16:48:29165 const contextId = /** @type {!Protocol.WebAudio.GraphObjectId} */ (event.data);
166 this._graphManager.destroyContext(contextId);
Hongchan Choi7dd0b3e2019-05-13 21:19:03167 this._contextSelector.contextDestroyed(event);
168 }
169
170 /**
Tim van der Lippec02a97c2020-02-14 14:39:27171 * @param {!Common.EventTarget.EventTargetEvent} event
Hongchan Choi7dd0b3e2019-05-13 21:19:03172 */
173 _contextChanged(event) {
Gaoping Huanga471b302019-08-23 16:48:29174 const context = /** @type {!Protocol.WebAudio.BaseAudioContext} */ (event.data);
Tim van der Lippe1d6e57a2019-09-30 11:55:34175 if (!this._graphManager.hasContext(context.contextId)) {
Gaoping Huanga471b302019-08-23 16:48:29176 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34177 }
Gaoping Huanga471b302019-08-23 16:48:29178
Hongchan Choi7dd0b3e2019-05-13 21:19:03179 this._contextSelector.contextChanged(event);
180 }
181
182 _reset() {
Tim van der Lippe1d6e57a2019-09-30 11:55:34183 if (this._landingPage.isShowing()) {
Hongchan Choi7dd0b3e2019-05-13 21:19:03184 this._landingPage.detach();
Tim van der Lippe1d6e57a2019-09-30 11:55:34185 }
Hongchan Choi7dd0b3e2019-05-13 21:19:03186 this._contextSelector.reset();
187 this._detailViewContainer.removeChildren();
188 this._landingPage.show(this._detailViewContainer);
Gaoping Huanga471b302019-08-23 16:48:29189 this._graphManager.clearGraphs();
190 }
191
192 _suspendModel() {
193 this._graphManager.clearGraphs();
194 }
195
196 /**
Tim van der Lippec02a97c2020-02-14 14:39:27197 * @param {!Common.EventTarget.EventTargetEvent} event
Gaoping Huanga471b302019-08-23 16:48:29198 */
199 _audioListenerCreated(event) {
200 const listener = /** @type {!Protocol.WebAudio.AudioListener} */ (event.data);
201 const graph = this._graphManager.getGraph(listener.contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34202 if (!graph) {
Gaoping Huanga471b302019-08-23 16:48:29203 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34204 }
Gaoping Huanga471b302019-08-23 16:48:29205 graph.addNode({
206 nodeId: listener.listenerId,
207 nodeType: 'Listener',
208 numberOfInputs: 0,
209 numberOfOutputs: 0,
210 });
211 }
212
213 /**
Tim van der Lippec02a97c2020-02-14 14:39:27214 * @param {!Common.EventTarget.EventTargetEvent} event
Gaoping Huanga471b302019-08-23 16:48:29215 */
216 _audioListenerWillBeDestroyed(event) {
217 const {contextId, listenerId} = event.data;
218 const graph = this._graphManager.getGraph(contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34219 if (!graph) {
Gaoping Huanga471b302019-08-23 16:48:29220 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34221 }
Gaoping Huanga471b302019-08-23 16:48:29222 graph.removeNode(listenerId);
223 }
224
225 /**
Tim van der Lippec02a97c2020-02-14 14:39:27226 * @param {!Common.EventTarget.EventTargetEvent} event
Gaoping Huanga471b302019-08-23 16:48:29227 */
228 _audioNodeCreated(event) {
229 const node = /** @type {!Protocol.WebAudio.AudioNode} */ (event.data);
230 const graph = this._graphManager.getGraph(node.contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34231 if (!graph) {
Gaoping Huanga471b302019-08-23 16:48:29232 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34233 }
Gaoping Huanga471b302019-08-23 16:48:29234 graph.addNode({
235 nodeId: node.nodeId,
236 nodeType: node.nodeType,
237 numberOfInputs: node.numberOfInputs,
238 numberOfOutputs: node.numberOfOutputs,
239 });
240 }
241
242 /**
Tim van der Lippec02a97c2020-02-14 14:39:27243 * @param {!Common.EventTarget.EventTargetEvent} event
Gaoping Huanga471b302019-08-23 16:48:29244 */
245 _audioNodeWillBeDestroyed(event) {
246 const {contextId, nodeId} = event.data;
247 const graph = this._graphManager.getGraph(contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34248 if (!graph) {
Gaoping Huanga471b302019-08-23 16:48:29249 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34250 }
Gaoping Huanga471b302019-08-23 16:48:29251 graph.removeNode(nodeId);
252 }
253
254 /**
Tim van der Lippec02a97c2020-02-14 14:39:27255 * @param {!Common.EventTarget.EventTargetEvent} event
Gaoping Huanga471b302019-08-23 16:48:29256 */
257 _audioParamCreated(event) {
258 const param = /** @type {!Protocol.WebAudio.AudioParam} */ (event.data);
259 const graph = this._graphManager.getGraph(param.contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34260 if (!graph) {
Gaoping Huanga471b302019-08-23 16:48:29261 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34262 }
Gaoping Huanga471b302019-08-23 16:48:29263 graph.addParam({
264 paramId: param.paramId,
265 paramType: param.paramType,
266 nodeId: param.nodeId,
267 });
268 }
269
270 /**
Tim van der Lippec02a97c2020-02-14 14:39:27271 * @param {!Common.EventTarget.EventTargetEvent} event
Gaoping Huanga471b302019-08-23 16:48:29272 */
273 _audioParamWillBeDestroyed(event) {
274 const {contextId, paramId} = event.data;
275 const graph = this._graphManager.getGraph(contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34276 if (!graph) {
Gaoping Huanga471b302019-08-23 16:48:29277 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34278 }
Gaoping Huanga471b302019-08-23 16:48:29279 graph.removeParam(paramId);
280 }
281
282 /**
Tim van der Lippec02a97c2020-02-14 14:39:27283 * @param {!Common.EventTarget.EventTargetEvent} event
Gaoping Huanga471b302019-08-23 16:48:29284 */
285 _nodesConnected(event) {
286 const {contextId, sourceId, destinationId, sourceOutputIndex, destinationInputIndex} = event.data;
287 const graph = this._graphManager.getGraph(contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34288 if (!graph) {
Gaoping Huanga471b302019-08-23 16:48:29289 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34290 }
Gaoping Huanga471b302019-08-23 16:48:29291 graph.addNodeToNodeConnection({
292 sourceId,
293 destinationId,
294 sourceOutputIndex,
295 destinationInputIndex,
296 });
297 }
298
299 /**
Tim van der Lippec02a97c2020-02-14 14:39:27300 * @param {!Common.EventTarget.EventTargetEvent} event
Gaoping Huanga471b302019-08-23 16:48:29301 */
302 _nodesDisconnected(event) {
303 const {contextId, sourceId, destinationId, sourceOutputIndex, destinationInputIndex} = event.data;
304 const graph = this._graphManager.getGraph(contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34305 if (!graph) {
Gaoping Huanga471b302019-08-23 16:48:29306 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34307 }
Gaoping Huanga471b302019-08-23 16:48:29308 graph.removeNodeToNodeConnection({
309 sourceId,
310 destinationId,
311 sourceOutputIndex,
312 destinationInputIndex,
313 });
314 }
315
316 /**
Tim van der Lippec02a97c2020-02-14 14:39:27317 * @param {!Common.EventTarget.EventTargetEvent} event
Gaoping Huanga471b302019-08-23 16:48:29318 */
319 _nodeParamConnected(event) {
320 const {contextId, sourceId, destinationId, sourceOutputIndex} = event.data;
321 const graph = this._graphManager.getGraph(contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34322 if (!graph) {
Gaoping Huanga471b302019-08-23 16:48:29323 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34324 }
Gaoping Huanga471b302019-08-23 16:48:29325 // Since the destinationId is AudioParamId, we need to find the nodeId as the
326 // real destinationId.
327 const nodeId = graph.getNodeIdByParamId(destinationId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34328 if (!nodeId) {
Gaoping Huanga471b302019-08-23 16:48:29329 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34330 }
Gaoping Huanga471b302019-08-23 16:48:29331 graph.addNodeToParamConnection({
332 sourceId,
333 destinationId: nodeId,
334 sourceOutputIndex,
335 destinationParamId: destinationId,
336 });
337 }
338
339 /**
Tim van der Lippec02a97c2020-02-14 14:39:27340 * @param {!Common.EventTarget.EventTargetEvent} event
Gaoping Huanga471b302019-08-23 16:48:29341 */
342 _nodeParamDisconnected(event) {
343 const {contextId, sourceId, destinationId, sourceOutputIndex} = event.data;
344 const graph = this._graphManager.getGraph(contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34345 if (!graph) {
Gaoping Huanga471b302019-08-23 16:48:29346 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34347 }
Gaoping Huanga471b302019-08-23 16:48:29348 // Since the destinationId is AudioParamId, we need to find the nodeId as the
349 // real destinationId.
350 const nodeId = graph.getNodeIdByParamId(destinationId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34351 if (!nodeId) {
Gaoping Huanga471b302019-08-23 16:48:29352 return;
Tim van der Lippe1d6e57a2019-09-30 11:55:34353 }
Gaoping Huanga471b302019-08-23 16:48:29354 graph.removeNodeToParamConnection({
355 sourceId,
356 destinationId: nodeId,
357 sourceOutputIndex,
358 destinationParamId: destinationId,
359 });
Hongchan Choi7dd0b3e2019-05-13 21:19:03360 }
361
362 /**
363 * @param {!Protocol.WebAudio.BaseAudioContext} context
364 */
365 _updateDetailView(context) {
Tim van der Lippe1d6e57a2019-09-30 11:55:34366 if (this._landingPage.isShowing()) {
Hongchan Choi7dd0b3e2019-05-13 21:19:03367 this._landingPage.detach();
Tim van der Lippe1d6e57a2019-09-30 11:55:34368 }
Hongchan Choi0927e702020-01-15 20:13:37369 const detailBuilder = new ContextDetailBuilder(context);
Hongchan Choi7dd0b3e2019-05-13 21:19:03370 this._detailViewContainer.removeChildren();
371 this._detailViewContainer.appendChild(detailBuilder.getFragment());
372 }
373
374 /**
Hongchan Choi65088332019-08-08 01:12:33375 * @param {!Protocol.WebAudio.GraphObjectId} contextId
Hongchan Choi7dd0b3e2019-05-13 21:19:03376 * @param {!Protocol.WebAudio.ContextRealtimeData} contextRealtimeData
377 */
378 _updateSummaryBar(contextId, contextRealtimeData) {
Hongchan Choi0927e702020-01-15 20:13:37379 const summaryBuilder = new ContextSummaryBuilder(contextId, contextRealtimeData);
Hongchan Choi7dd0b3e2019-05-13 21:19:03380 this._summaryBarContainer.removeChildren();
381 this._summaryBarContainer.appendChild(summaryBuilder.getFragment());
382 }
383
384 _clearSummaryBar() {
385 this._summaryBarContainer.removeChildren();
386 }
387
388 async _pollRealtimeData() {
389 const context = this._contextSelector.selectedContext();
390 if (!context) {
391 this._clearSummaryBar();
392 return;
393 }
394
Paul Lewis9f21a772020-10-05 13:22:08395 for (const model of SDK.SDKModel.TargetManager.instance().models(WebAudioModel)) {
Hongchan Choi7dd0b3e2019-05-13 21:19:03396 // Display summary only for real-time context.
397 if (context.contextType === 'realtime') {
Tim van der Lippe1d6e57a2019-09-30 11:55:34398 if (!this._graphManager.hasContext(context.contextId)) {
Gaoping Huanga471b302019-08-23 16:48:29399 continue;
Tim van der Lippe1d6e57a2019-09-30 11:55:34400 }
Hongchan Choi7dd0b3e2019-05-13 21:19:03401 const realtimeData = await model.requestRealtimeData(context.contextId);
Tim van der Lippe1d6e57a2019-09-30 11:55:34402 if (realtimeData) {
Hongchan Choi7dd0b3e2019-05-13 21:19:03403 this._updateSummaryBar(context.contextId, realtimeData);
Tim van der Lippe1d6e57a2019-09-30 11:55:34404 }
Hongchan Choi7dd0b3e2019-05-13 21:19:03405 } else {
406 this._clearSummaryBar();
407 }
408 }
409 }
Paul Lewis2766f082019-11-28 13:42:57410}