| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * @typedef {{ | 6 * @typedef {{ |
| 7 * cache: (boolean|undefined), | 7 * cache: (boolean|undefined), |
| 8 * priority: (number|undefined), | 8 * priority: (number|undefined), |
| 9 * taskId: number, | 9 * taskId: number, |
| 10 * timestamp: (number|undefined), | 10 * timestamp: (number|undefined), |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 // Download data urls directly since they are not supported by XmlHttpRequest. | 230 // Download data urls directly since they are not supported by XmlHttpRequest. |
| 231 var dataUrlMatches = this.request_.url.match(/^data:([^,;]*)[,;]/); | 231 var dataUrlMatches = this.request_.url.match(/^data:([^,;]*)[,;]/); |
| 232 if (dataUrlMatches) { | 232 if (dataUrlMatches) { |
| 233 this.image_.src = this.request_.url; | 233 this.image_.src = this.request_.url; |
| 234 this.contentType_ = dataUrlMatches[1]; | 234 this.contentType_ = dataUrlMatches[1]; |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 | 237 |
| 238 // Load RAW images by using Piex loader instead of XHR. | 238 // Load RAW images by using Piex loader instead of XHR. |
| 239 if (FileType.getTypeForName(this.request_.url).type === 'raw') { | 239 var fileType = FileType.getTypeForName(this.request_.url); |
| 240 if (fileType.type === 'raw') { |
| 241 var timer = metrics.getTracker().startTiming( |
| 242 metrics.Categories.INTERNALS, |
| 243 metrics.timing.Variables.EXTRACT_JPEG_FROM_RAW, |
| 244 fileType.subtype); |
| 240 this.piexLoader_.load(this.request_.url).then(function(data) { | 245 this.piexLoader_.load(this.request_.url).then(function(data) { |
| 246 timer.send(); |
| 241 var blob = new Blob([data.thumbnail], {type: 'image/jpeg'}); | 247 var blob = new Blob([data.thumbnail], {type: 'image/jpeg'}); |
| 242 var url = URL.createObjectURL(blob); | 248 var url = URL.createObjectURL(blob); |
| 243 this.image_.src = url; | 249 this.image_.src = url; |
| 244 this.request_.orientation = data.orientation; | 250 this.request_.orientation = data.orientation; |
| 245 this.request_.colorSpace = data.colorSpace; | 251 this.request_.colorSpace = data.colorSpace; |
| 246 }.bind(this), function(error) { | 252 }.bind(this), function(error) { |
| 247 console.error('PiexLoaderError: ', error); | 253 console.error('PiexLoaderError: ', error); |
| 248 onFailure(); | 254 onFailure(); |
| 249 }); | 255 }); |
| 250 return; | 256 return; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 this.image_.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAA' + | 533 this.image_.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAA' + |
| 528 'ABAAEAAAICTAEAOw=='; | 534 'ABAAEAAAICTAEAOw=='; |
| 529 | 535 |
| 530 this.xhr_.onload = function() {}; | 536 this.xhr_.onload = function() {}; |
| 531 this.xhr_.abort(); | 537 this.xhr_.abort(); |
| 532 | 538 |
| 533 // Dispose memory allocated by Canvas. | 539 // Dispose memory allocated by Canvas. |
| 534 this.canvas_.width = 0; | 540 this.canvas_.width = 0; |
| 535 this.canvas_.height = 0; | 541 this.canvas_.height = 0; |
| 536 }; | 542 }; |
| OLD | NEW |