Chromium Code Reviews| Index: components/proximity_auth/webui/resources/log-buffer.js |
| diff --git a/components/proximity_auth/webui/resources/log-buffer.js b/components/proximity_auth/webui/resources/log-buffer.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e8975785acb00c3746f7ccee32b1e5ad874bb220 |
| --- /dev/null |
| +++ b/components/proximity_auth/webui/resources/log-buffer.js |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +Polymer('log-buffer', { |
| + publish: { |
| + /** |
| + * List of displayed logs. |
| + * @type {?Array.<{{ |
| + * text: string, |
| + * time: string, |
| + * file: string, |
| + * line: number, |
| + * severity: number, |
| + * }}>} LogMessage |
| + */ |
| + logs: null, |
| + }, |
| + |
| + /** |
| + * Called when an instance is created. |
| + */ |
| + created: function() { |
| + this.logs = []; |
| + // We assume that only one instance of log-buffer is ever created. |
| + LogBufferInterface = this; |
| + chrome.send('getLogMessages'); |
| + }, |
| + |
| + // Clears the native LogBuffer. |
| + clearLogs: function() { |
| + chrome.send('clearLogBuffer'); |
| + }, |
| + |
| + // Handles when a new log message is added. |
| + onLogMessageAdded: function(log) { |
| + this.logs.push(log); |
| + }, |
| + |
| + // Handles when the logs are cleared. |
| + onLogBufferCleared: function() { |
| + this.logs = []; |
| + }, |
| + |
| + // Handles when the logs are returned in response to the 'getLogMessages' |
| + // request. |
| + onGotLogMessages: function(logs) { |
| + this.logs = logs; |
| + } |
| +}); |
| + |
| +// Interface with the native WebUI component for LogBuffer events. |
| +// The functions contained in this object will be invoked by the browser when |
| +// for each operation performed on the native LogBuffer. |
|
Ilya Sherman
2015/05/13 00:49:57
nit: "when for each" -> "for each"?
Tim Song
2015/05/13 02:24:37
Done.
|
| +LogBufferInterface = { |
| + /** |
| + * Called when a new log message is added. |
| + * @type {function(LogMessage)} |
| + */ |
| + onLogMessageAdded: function(log) {}, |
| + |
| + /** |
| + * Called when the log buffer is cleared. |
| + * @type {function()} |
| + */ |
| + onLogBufferCleared: function() {}, |
| + |
| + /** |
| + * Called in response to chrome.send('getLogMessages') with the log messages |
| + * currently in the buffer. |
| + * @type {function(Array.<LogMessage>)} |
| + */ |
| + onGotLogMessages: function(messages) {}, |
| +}; |