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

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

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

Powered by Google App Engine
This is Rietveld 408576698