[Media Router] Add integration tests and e2e tests for media router and presentation...
[chromium-blink-merge.git] / components / proximity_auth / webui / resources / log-buffer.js
blob82710d6a0ad4b4a7beb962d012d5c79d9d9c088e
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('log-buffer', {
6 publish: {
7 /**
8 * List of displayed logs.
9 * @type {?Array<{{
10 * text: string,
11 * time: string,
12 * file: string,
13 * line: number,
14 * severity: number,
15 * }}>} LogMessage
17 logs: null,
20 /**
21 * Called when an instance is created.
23 created: function() {
24 this.logs = [];
25 // We assume that only one instance of log-buffer is ever created.
26 LogBufferInterface = this;
27 chrome.send('getLogMessages');
30 // Clears the native LogBuffer.
31 clearLogs: function() {
32 chrome.send('clearLogBuffer');
35 // Handles when a new log message is added.
36 onLogMessageAdded: function(log) {
37 this.logs.push(log);
40 // Handles when the logs are cleared.
41 onLogBufferCleared: function() {
42 this.logs = [];
45 // Handles when the logs are returned in response to the 'getLogMessages'
46 // request.
47 onGotLogMessages: function(logs) {
48 this.logs = logs;
50 });
52 // Interface with the native WebUI component for LogBuffer events. The functions
53 // contained in this object will be invoked by the browser for each operation
54 // performed on the native LogBuffer.
55 LogBufferInterface = {
56 /**
57 * Called when a new log message is added.
58 * @type {function(LogMessage)}
60 onLogMessageAdded: function(log) {},
62 /**
63 * Called when the log buffer is cleared.
64 * @type {function()}
66 onLogBufferCleared: function() {},
68 /**
69 * Called in response to chrome.send('getLogMessages') with the log messages
70 * currently in the buffer.
71 * @type {function(Array<LogMessage>)}
73 onGotLogMessages: function(messages) {},