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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/Console.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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
5 /** 4 /**
6 * @constructor 5 * @unrestricted
7 * @extends {WebInspector.Object}
8 */ 6 */
9 WebInspector.Console = function() 7 WebInspector.Console = class extends WebInspector.Object {
10 { 8 constructor() {
9 super();
11 /** @type {!Array.<!WebInspector.Console.Message>} */ 10 /** @type {!Array.<!WebInspector.Console.Message>} */
12 this._messages = []; 11 this._messages = [];
12 }
13
14 /**
15 * @param {string} text
16 * @param {!WebInspector.Console.MessageLevel} level
17 * @param {boolean=} show
18 */
19 addMessage(text, level, show) {
20 var message = new WebInspector.Console.Message(
21 text, level || WebInspector.Console.MessageLevel.Log, Date.now(), show | | false);
22 this._messages.push(message);
23 this.dispatchEventToListeners(WebInspector.Console.Events.MessageAdded, mess age);
24 }
25
26 /**
27 * @param {string} text
28 */
29 log(text) {
30 this.addMessage(text, WebInspector.Console.MessageLevel.Log);
31 }
32
33 /**
34 * @param {string} text
35 */
36 warn(text) {
37 this.addMessage(text, WebInspector.Console.MessageLevel.Warning);
38 }
39
40 /**
41 * @param {string} text
42 */
43 error(text) {
44 this.addMessage(text, WebInspector.Console.MessageLevel.Error, true);
45 }
46
47 /**
48 * @return {!Array.<!WebInspector.Console.Message>}
49 */
50 messages() {
51 return this._messages;
52 }
53
54 show() {
55 this.showPromise();
56 }
57
58 /**
59 * @return {!Promise.<undefined>}
60 */
61 showPromise() {
62 return WebInspector.Revealer.revealPromise(this);
63 }
13 }; 64 };
14 65
15 /** @enum {symbol} */ 66 /** @enum {symbol} */
16 WebInspector.Console.Events = { 67 WebInspector.Console.Events = {
17 MessageAdded: Symbol("messageAdded") 68 MessageAdded: Symbol('messageAdded')
18 }; 69 };
19 70
20 /** 71 /**
21 * @enum {string} 72 * @enum {string}
22 */ 73 */
23 WebInspector.Console.MessageLevel = { 74 WebInspector.Console.MessageLevel = {
24 Log: "log", 75 Log: 'log',
25 Warning: "warning", 76 Warning: 'warning',
26 Error: "error" 77 Error: 'error'
27 }; 78 };
28 79
29 /** 80 /**
30 * @constructor 81 * @unrestricted
31 * @param {string} text
32 * @param {!WebInspector.Console.MessageLevel} level
33 * @param {number} timestamp
34 * @param {boolean} show
35 */ 82 */
36 WebInspector.Console.Message = function(text, level, timestamp, show) 83 WebInspector.Console.Message = class {
37 { 84 /**
85 * @param {string} text
86 * @param {!WebInspector.Console.MessageLevel} level
87 * @param {number} timestamp
88 * @param {boolean} show
89 */
90 constructor(text, level, timestamp, show) {
38 this.text = text; 91 this.text = text;
39 this.level = level; 92 this.level = level;
40 this.timestamp = (typeof timestamp === "number") ? timestamp : Date.now(); 93 this.timestamp = (typeof timestamp === 'number') ? timestamp : Date.now();
41 this.show = show; 94 this.show = show;
42 }; 95 }
43
44 WebInspector.Console.prototype = {
45 /**
46 * @param {string} text
47 * @param {!WebInspector.Console.MessageLevel} level
48 * @param {boolean=} show
49 */
50 addMessage: function(text, level, show)
51 {
52 var message = new WebInspector.Console.Message(text, level || WebInspect or.Console.MessageLevel.Log, Date.now(), show || false);
53 this._messages.push(message);
54 this.dispatchEventToListeners(WebInspector.Console.Events.MessageAdded, message);
55 },
56
57 /**
58 * @param {string} text
59 */
60 log: function(text)
61 {
62 this.addMessage(text, WebInspector.Console.MessageLevel.Log);
63 },
64
65 /**
66 * @param {string} text
67 */
68 warn: function(text)
69 {
70 this.addMessage(text, WebInspector.Console.MessageLevel.Warning);
71 },
72
73 /**
74 * @param {string} text
75 */
76 error: function(text)
77 {
78 this.addMessage(text, WebInspector.Console.MessageLevel.Error, true);
79 },
80
81 /**
82 * @return {!Array.<!WebInspector.Console.Message>}
83 */
84 messages: function()
85 {
86 return this._messages;
87 },
88
89 show: function()
90 {
91 this.showPromise();
92 },
93
94 /**
95 * @return {!Promise.<undefined>}
96 */
97 showPromise: function()
98 {
99 return WebInspector.Revealer.revealPromise(this);
100 },
101
102 __proto__: WebInspector.Object.prototype
103 }; 96 };
104 97
105 WebInspector.console = new WebInspector.Console(); 98 WebInspector.console = new WebInspector.Console();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698