1<!DOCTYPE html>
2<!--
3Copyright (c) 2015 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7
8<link rel="import" href="/tracing/model/event_info.html">
9<link rel="import" href="/tracing/model/event_set.html">
10<link rel="import" href="/tracing/model/timed_event.html">
11<link rel="import" href="/tracing/value/unit.html">
12
13<script>
14'use strict';
15
16tr.exportTo('tr.model', function() {
17
18  function Alert(info, start, opt_associatedEvents, opt_args) {
19    tr.model.TimedEvent.call(this, start);
20    this.info = info;
21    this.args = opt_args || {};
22    this.associatedEvents = new tr.model.EventSet(opt_associatedEvents);
23    this.associatedEvents.forEach(function(event) {
24      event.addAssociatedAlert(this);
25    }, this);
26  }
27
28  Alert.prototype = {
29    __proto__: tr.model.TimedEvent.prototype,
30
31    get title() {
32      return this.info.title;
33    },
34
35    get colorId() {
36      return this.info.colorId;
37    },
38
39    get userFriendlyName() {
40      return 'Alert ' + this.title + ' at ' +
41          tr.v.Unit.byName.timeStampInMs.format(this.start);
42    }
43  };
44
45  tr.model.EventRegistry.register(
46      Alert,
47      {
48        name: 'alert',
49        pluralName: 'alerts',
50        singleViewElementName: 'tr-ui-a-alert-sub-view',
51        multiViewElementName: 'tr-ui-a-alert-sub-view'
52      });
53
54  return {
55    Alert: Alert
56  };
57});
58</script>
59