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

Side by Side Diff: chrome/browser/resources/predictors/predictors.js

Issue 10416002: Seculative resource prefetching for URLs CL. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Resolving conflicts. Created 8 years, 6 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 /** 5 <include src="autocomplete_action_predictor.js"/>
6 * Requests the database from the backend. 6 <include src="resource_prefetch_predictor.js"/>
7 */
8 function requestAutocompleteActionPredictorDb() {
9 console.debug('Requesting NAP DB');
10 chrome.send('requestAutocompleteActionPredictorDb');
11 }
12 7
8 if (cr.isWindows)
9 document.documentElement.setAttribute('os', 'win');
13 10
14 /** 11 cr.ui.decorate('tabbox', cr.ui.TabBox);
15 * Callback from backend with the database contents. Sets up some globals and
16 * calls to create the UI.
17 * @param {Dictionary} database Information about AutocompleteActionPredictor
18 * including the database as a flattened list, a boolean indicating if the
19 * system is enabled and the current hit weight.
20 */
21 function updateDatabaseTable(database) {
22 console.debug('Updating Table NAP DB');
23
24 var filter = $('filter');
25 filter.disabled = false;
26 filter.onchange = function() {
27 updateDatabaseView(database);
28 };
29
30 updateDatabaseView(database);
31 }
32
33 /**
34 * Updates the table from the database.
35 * @param {Dictionary} database Information about AutocompleteActionPredictor
36 * including the database as a flattened list, a boolean indicating if the
37 * system is enabled and the current hit weight.
38 */
39 function updateDatabaseView(database) {
40 var databaseSection = $('databaseTableBody');
41 var showEnabled = database.enabled && database.db;
42
43 $('enabledMode').hidden = !showEnabled;
44 $('disabledMode').hidden = showEnabled;
45
46 if (!showEnabled)
47 return;
48
49 var filter = $('filter');
50
51 // Clear any previous list.
52 databaseSection.textContent = '';
53
54 for (var i = 0; i < database.db.length; ++i) {
55 var entry = database.db[i];
56
57 if (!filter.checked || entry.confidence > 0) {
58 var row = document.createElement('tr');
59 row.className = (entry.confidence > 0.8 ? 'action-prerender' :
60 (entry.confidence > 0.5 ? 'action-preconnect' :
61 'action-none'));
62
63 row.appendChild(document.createElement('td')).textContent =
64 entry.user_text;
65 row.appendChild(document.createElement('td')).textContent = entry.url;
66 row.appendChild(document.createElement('td')).textContent =
67 entry.hit_count;
68 row.appendChild(document.createElement('td')).textContent =
69 entry.miss_count;
70 row.appendChild(document.createElement('td')).textContent =
71 entry.confidence;
72
73 databaseSection.appendChild(row);
74 }
75 }
76 $('countBanner').textContent = 'Entries: ' + databaseSection.children.length;
77 }
78
79 document.addEventListener('DOMContentLoaded',
80 requestAutocompleteActionPredictorDb);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698