Roll src/third_party/WebKit 605a979:06cb9e9 (svn 202556:202558)
[chromium-blink-merge.git] / components / proximity_auth / webui / resources / log-buffer.js
blob41d978e162a8b4637c121511d7fdf0b791496dd2
1 // Copyright 2015 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.
5 Polymer({
6 is: 'log-buffer',
8 properties: {
9 /**
10 * List of displayed logs.
11 * @type {?Array<{{
12 * text: string,
13 * time: string,
14 * file: string,
15 * line: number,
16 * severity: number,
17 * }}>} LogMessage
19 logs: {
20 type: Array,
21 value: [],
22 notify: true,
26 /**
27 * Called when an instance is initialized.
29 ready: function() {
30 // We assume that only one instance of log-buffer is ever created.
31 LogBufferInterface = this;
32 chrome.send('getLogMessages');
35 // Clears the native LogBuffer.
36 clearLogs: function() {
37 chrome.send('clearLogBuffer');
40 // Handles when a new log message is added.
41 onLogMessageAdded: function(log) {
42 this.push('logs', log);
45 // Handles when the logs are cleared.
46 onLogBufferCleared: function() {
47 this.logs = [];
50 // Handles when the logs are returned in response to the 'getLogMessages'
51 // request.
52 onGotLogMessages: function(logs) {
53 this.logs = logs;
55 });
57 // Interface with the native WebUI component for LogBuffer events. The functions
58 // contained in this object will be invoked by the browser for each operation
59 // performed on the native LogBuffer.
60 LogBufferInterface = {
61 /**
62 * Called when a new log message is added.
63 * @type {function(LogMessage)}
65 onLogMessageAdded: function(log) {},
67 /**
68 * Called when the log buffer is cleared.
69 * @type {function()}
71 onLogBufferCleared: function() {},
73 /**
74 * Called in response to chrome.send('getLogMessages') with the log messages
75 * currently in the buffer.
76 * @type {function(Array<LogMessage>)}
78 onGotLogMessages: function(messages) {},