| OLD | NEW |
| 1 // The port for communicating back to the extension. | 1 // The port for communicating back to the extension. |
| 2 var benchmarkExtensionPort = chrome.extension.connect(); | 2 var benchmarkExtensionPort = chrome.extension.connect(); |
| 3 | 3 |
| 4 // The url is what this page is known to the benchmark as. | 4 // The url is what this page is known to the benchmark as. |
| 5 // The benchmark uses this id to differentiate the benchmark's | 5 // The benchmark uses this id to differentiate the benchmark's |
| 6 // results from random pages being browsed. | 6 // results from random pages being browsed. |
| 7 | 7 |
| 8 // TODO(mbelshe): If the page redirects, the location changed and the | 8 // TODO(mbelshe): If the page redirects, the location changed and the |
| 9 // benchmark stalls. | 9 // benchmark stalls. |
| 10 var benchmarkExtensionUrl = window.location.toString(); | 10 var benchmarkExtensionUrl = window.location.toString(); |
| 11 | 11 |
| 12 function sendTimesToExtension() { | 12 function sendTimesToExtension() { |
| 13 var times = window.chromium.GetLoadTimes(); | 13 var times = window.chrome.loadTimes(); |
| 14 |
| 14 if (times.finishLoadTime != 0) { | 15 if (times.finishLoadTime != 0) { |
| 15 benchmarkExtensionPort.postMessage({message: "load", url: benchmarkExtension
Url, values: times}); | 16 benchmarkExtensionPort.postMessage({message: "load", url: benchmarkExtension
Url, values: times}); |
| 16 } else { | 17 } else { |
| 17 window.setTimeout(sendTimesToExtension, 100); | 18 window.setTimeout(sendTimesToExtension, 100); |
| 18 } | 19 } |
| 19 } | 20 } |
| 20 | 21 |
| 21 function loadComplete() { | 22 function loadComplete() { |
| 22 // Only trigger for top-level frames (e.g. the one we benchmarked) | 23 // Only trigger for top-level frames (e.g. the one we benchmarked) |
| 23 if (window.parent == window) { | 24 if (window.parent == window) { |
| 24 sendTimesToExtension(); | 25 sendTimesToExtension(); |
| 25 } | 26 } |
| 26 } | 27 } |
| 27 | 28 |
| 28 window.addEventListener("load", loadComplete); | 29 window.addEventListener("load", loadComplete); |
| OLD | NEW |