| OLD | NEW |
| 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 /** |
| 6 * Requests the database from the backend. | 6 * Requests the database from the backend. |
| 7 */ | 7 */ |
| 8 function requestResourcePrefetchPredictorDb() { | 8 function requestResourcePrefetchPredictorDb() { |
| 9 chrome.send('requestResourcePrefetchPredictorDb'); | 9 chrome.send('requestResourcePrefetchPredictorDb'); |
| 10 } | 10 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 function updateResourcePrefetchPredictorDbView(database) { | 38 function updateResourcePrefetchPredictorDbView(database) { |
| 39 if (!database.enabled) { | 39 if (!database.enabled) { |
| 40 $('rpp_enabled').style.display = 'none'; | 40 $('rpp_enabled').style.display = 'none'; |
| 41 $('rpp_disabled').style.display = 'block'; | 41 $('rpp_disabled').style.display = 'block'; |
| 42 return; | 42 return; |
| 43 } else { | 43 } else { |
| 44 $('rpp_enabled').style.display = 'block'; | 44 $('rpp_enabled').style.display = 'block'; |
| 45 $('rpp_disabled').style.display = 'none'; | 45 $('rpp_disabled').style.display = 'none'; |
| 46 } | 46 } |
| 47 | 47 |
| 48 var has_url_data = database.url_db && database.url_db.length > 0; | 48 var hasUrlData = database.url_db && database.url_db.length > 0; |
| 49 var has_host_data = database.host_db && database.host_db.length > 0; | 49 var hasHostData = database.host_db && database.host_db.length > 0; |
| 50 | 50 |
| 51 if (has_url_data) | 51 if (hasUrlData) |
| 52 renderCacheData($('rpp_url_body'), database.url_db); | 52 renderCacheData($('rpp_url_body'), database.url_db); |
| 53 if (has_host_data) | 53 if (hasHostData) |
| 54 renderCacheData($('rpp_host_body'), database.host_db); | 54 renderCacheData($('rpp_host_body'), database.host_db); |
| 55 } | 55 } |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Renders cache data for URL or host based data. | 58 * Renders cache data for URL or host based data. |
| 59 * @param {HTMLElement} body element of table to render into. | 59 * @param {HTMLElement} body element of table to render into. |
| 60 * @param {Dictionary} database to render. | 60 * @param {Dictionary} database to render. |
| 61 */ | 61 */ |
| 62 function renderCacheData(body, database) { | 62 function renderCacheData(body, database) { |
| 63 body.textContent = ''; | 63 body.textContent = ''; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 93 resource.position; | 93 resource.position; |
| 94 row.appendChild(document.createElement('td')).textContent = | 94 row.appendChild(document.createElement('td')).textContent = |
| 95 resource.score; | 95 resource.score; |
| 96 body.appendChild(row); | 96 body.appendChild(row); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 document.addEventListener('DOMContentLoaded', | 101 document.addEventListener('DOMContentLoaded', |
| 102 requestResourcePrefetchPredictorDb); | 102 requestResourcePrefetchPredictorDb); |
| OLD | NEW |