summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/internals
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/chrome/browser/resources/internals')
-rw-r--r--chromium/chrome/browser/resources/internals/query_tiles/BUILD.gn25
-rw-r--r--chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals.html31
-rw-r--r--chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals.js49
-rw-r--r--chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals_browser_proxy.js75
4 files changed, 180 insertions, 0 deletions
diff --git a/chromium/chrome/browser/resources/internals/query_tiles/BUILD.gn b/chromium/chrome/browser/resources/internals/query_tiles/BUILD.gn
new file mode 100644
index 00000000000..6d3f2cb3d6e
--- /dev/null
+++ b/chromium/chrome/browser/resources/internals/query_tiles/BUILD.gn
@@ -0,0 +1,25 @@
+# Copyright 2020 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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ uses_js_modules = true
+ deps = [
+ ":query_tiles_internals",
+ ":query_tiles_internals_browser_proxy",
+ ]
+}
+
+js_library("query_tiles_internals") {
+ deps = [
+ ":query_tiles_internals_browser_proxy",
+ "//ui/webui/resources/js:cr.m",
+ "//ui/webui/resources/js:util.m",
+ ]
+}
+
+js_library("query_tiles_internals_browser_proxy") {
+ deps = [ "//ui/webui/resources/js:cr.m" ]
+}
diff --git a/chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals.html b/chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals.html
new file mode 100644
index 00000000000..5b037055148
--- /dev/null
+++ b/chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals.html
@@ -0,0 +1,31 @@
+<!doctype html>
+<html lang="en" dir="ltr">
+ <head>
+ <meta charset="utf-8">
+ <title>Query Tiles Internals</title>
+ <meta name="viewport" content="width=device-width">
+ <link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
+ </head>
+ <body>
+ <h1>Query Tiles Internals</h1>
+ <h4>Fetcher Controller</h4>
+ <div>
+ <button id="start-fetch">Start fetch</button>
+ </div>
+ <h4>Database Controller</h4>
+ <div>
+ <button id="purge-db">Purge database</button>
+ </div>
+ <h4>Service State</h4>
+ <div>
+ Fetcher status: <span id="fetcher-status"></span>
+ Database status: <span id="group-status"></span>
+ </div>
+ <h4>Tile data</h4>
+ Group info: <span id="group-info"></span>
+ Tile proto: <span id="tile-proto"></span>
+ <div>
+ </div>
+ <script type="module" src="query_tiles_internals.js"></script>
+ </body>
+</html>
diff --git a/chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals.js b/chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals.js
new file mode 100644
index 00000000000..3bb73548dc2
--- /dev/null
+++ b/chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals.js
@@ -0,0 +1,49 @@
+// Copyright 2020 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.
+
+import {addWebUIListener} from 'chrome://resources/js/cr.m.js';
+import {$} from 'chrome://resources/js/util.m.js';
+
+import {QueryTilesInternalsBrowserProxy, QueryTilesInternalsBrowserProxyImpl, ServiceStatus, TileData} from './query_tiles_internals_browser_proxy.js';
+
+/**
+ * @param {!ServiceStatus} serviceStatus The current status of the tile
+ * service.
+ */
+function onServiceStatusChanged(serviceStatus) {
+ $('group-status').textContent = serviceStatus.groupStatus;
+ $('fetcher-status').textContent = serviceStatus.fetcherStatus;
+}
+
+/**
+ * @param {!TileData} tileData The raw data persisted in database.
+ */
+function onTileDataAvailable(tileData) {
+ $('group-info').textContent = tileData.groupInfo;
+ $('tile-proto').textContent = tileData.tilesProto;
+}
+
+function initialize() {
+ /** @type {!QueryTilesInternalsBrowserProxy} */
+ const browserProxy = QueryTilesInternalsBrowserProxyImpl.getInstance();
+
+ // Register all event listeners.
+ addWebUIListener('service-status-changed', onServiceStatusChanged);
+
+ addWebUIListener('tile-data-available', onTileDataAvailable);
+
+ $('start-fetch').onclick = function() {
+ browserProxy.startFetch();
+ };
+
+ $('purge-db').onclick = function() {
+ browserProxy.purgeDb();
+ };
+
+ // Kick off requests for the current system state.
+ browserProxy.getServiceStatus().then(onServiceStatusChanged);
+ browserProxy.getTileData().then(onTileDataAvailable);
+}
+
+document.addEventListener('DOMContentLoaded', initialize);
diff --git a/chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals_browser_proxy.js b/chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals_browser_proxy.js
new file mode 100644
index 00000000000..ded38b10374
--- /dev/null
+++ b/chromium/chrome/browser/resources/internals/query_tiles/query_tiles_internals_browser_proxy.js
@@ -0,0 +1,75 @@
+// Copyright 2020 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.
+
+import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js';
+
+/**
+ * @typedef {{
+ * fetcherStatus: string,
+ * groupStatus: string,
+ * }}
+ */
+export let ServiceStatus;
+
+/**
+ * @typedef {{
+ * groupInfo: string,
+ * tilesProto: string,
+ * }}
+ */
+export let TileData;
+
+/** @interface */
+export class QueryTilesInternalsBrowserProxy {
+ /**
+ * Start fetch right now.
+ */
+ startFetch() {}
+
+ /**
+ * Delete everything in the database.
+ */
+ purgeDb() {}
+
+ /**
+ * Get the current status of the TileService.
+ * @return {!Promise<ServiceStatus>} A promise firing when the service
+ * status is fetched.
+ */
+ getServiceStatus() {}
+
+ /**
+ * Get raw data from TileService database.
+ * @return {!Promise<TileData>} A promise firing when the raw data
+ * is fetched.
+ */
+ getTileData() {}
+}
+
+/**
+ * @implements {QueryTilesInternalsBrowserProxy}
+ */
+export class QueryTilesInternalsBrowserProxyImpl {
+ /** @override */
+ startFetch() {
+ return chrome.send('startFetch');
+ }
+
+ /** @override */
+ purgeDb() {
+ return chrome.send('purgeDb');
+ }
+
+ /** @override */
+ getServiceStatus() {
+ return sendWithPromise('getServiceStatus');
+ }
+
+ /** @override */
+ getTileData() {
+ return sendWithPromise('getTileData');
+ }
+}
+
+addSingletonGetter(QueryTilesInternalsBrowserProxyImpl);