Chromium Code Reviews| Index: ui/file_manager/image_loader/request.js |
| diff --git a/ui/file_manager/image_loader/request.js b/ui/file_manager/image_loader/request.js |
| index e8cd3a5e742470fd98033873bfa7e9332162b674..93f8a03dc0fffd3929a028673a2e2172df7520db 100644 |
| --- a/ui/file_manager/image_loader/request.js |
| +++ b/ui/file_manager/image_loader/request.js |
| @@ -237,7 +237,9 @@ Request.prototype.downloadOriginal_ = function(onSuccess, onFailure) { |
| // Load RAW images by using Piex loader instead of XHR. |
| if (FileType.getTypeForName(this.request_.url).type === 'raw') { |
| + var startTime = new Date(); |
|
Ben Kwa
2015/04/10 15:57:31
If you don't want to mess with raw Dates there's a
|
| this.piexLoader_.load(this.request_.url).then(function(data) { |
| + this.recordRawLoadingTime_(this.request_.url, startTime, new Date()); |
| var blob = new Blob([data.thumbnail], {type: 'image/jpeg'}); |
| var url = URL.createObjectURL(blob); |
| this.image_.src = url; |
| @@ -262,6 +264,50 @@ Request.prototype.downloadOriginal_ = function(onSuccess, onFailure) { |
| }; |
| /** |
| + * Records loading time of RAW files. |
| + * @param {string} url |
| + * @param {!Date} startTime |
| + * @param {!Date} endTime |
| + */ |
| +Request.prototype.recordRawLoadingTime_ = function(url, startTime, endTime) { |
| + var type = FileType.getTypeForName(url); |
| + var metricVariable; |
| + switch (type.subtype) { |
| + case 'ARW': |
| + metricVariable = metrics.timing.Variables.RAW_LOAD_ARW; |
| + break; |
| + case 'CR2': |
| + metricVariable = metrics.timing.Variables.RAW_LOAD_CR2; |
| + break; |
| + case 'DNG': |
| + metricVariable = metrics.timing.Variables.RAW_LOAD_DNG; |
| + break; |
| + case 'NEF': |
| + metricVariable = metrics.timing.Variables.RAW_LOAD_NEF; |
| + break; |
| + case 'NRW': |
| + metricVariable = metrics.timing.Variables.RAW_LOAD_NRW; |
| + break; |
| + case 'ORF': |
| + metricVariable = metrics.timing.Variables.RAW_LOAD_ORF; |
| + break; |
| + case 'RAF': |
| + metricVariable = metrics.timing.Variables.RAW_LOAD_RAF; |
| + break; |
| + case 'RW2': |
| + metricVariable = metrics.timing.Variables.RAW_LOAD_RW2; |
| + break; |
| + default: |
| + console.error('Invalid RAW type: ' + type.subtype + '.'); |
| + return; |
| + } |
| + metrics.getTracker().sendTiming( |
| + metrics.Categories.RAW_IMAGE, |
| + metricVariable, |
| + endTime.getTime() - startTime.getTime()); |
| +}; |
| + |
| +/** |
| * Creates a XmlHttpRequest wrapper with injected OAuth2 authentication headers. |
| * @constructor |
| */ |