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 * Loads and resizes an image. | 6 * Loads and resizes an image. |
7 * @constructor | 7 * @constructor |
8 */ | 8 */ |
9 function ImageLoader() { | 9 function ImageLoader() { |
10 /** | 10 /** |
(...skipping 24 matching lines...) Expand all Loading... |
35 function(event) { | 35 function(event) { |
36 if (event.eventType === 'mount' && event.status === 'success') { | 36 if (event.eventType === 'mount' && event.status === 'success') { |
37 chrome.fileSystem.requestFileSystem( | 37 chrome.fileSystem.requestFileSystem( |
38 {volumeId: event.volumeMetadata.volumeId}, function() {}); | 38 {volumeId: event.volumeMetadata.volumeId}, function() {}); |
39 } | 39 } |
40 }); | 40 }); |
41 var initPromises = volumeMetadataList.map(function(volumeMetadata) { | 41 var initPromises = volumeMetadataList.map(function(volumeMetadata) { |
42 var requestPromise = new Promise(function(callback) { | 42 var requestPromise = new Promise(function(callback) { |
43 chrome.fileSystem.requestFileSystem( | 43 chrome.fileSystem.requestFileSystem( |
44 {volumeId: volumeMetadata.volumeId}, | 44 {volumeId: volumeMetadata.volumeId}, |
45 callback); | 45 /** @type {function(FileSystem=)} */(callback)); |
46 }); | 46 }); |
47 return requestPromise; | 47 return requestPromise; |
48 }); | 48 }); |
49 initPromises.push(new Promise(function(resolve, reject) { | 49 initPromises.push(new Promise(function(resolve, reject) { |
50 this.cache_.initialize(resolve); | 50 this.cache_.initialize(resolve); |
51 }.bind(this))); | 51 }.bind(this))); |
52 | 52 |
53 // After all initialization promises are done, start the scheduler. | 53 // After all initialization promises are done, start the scheduler. |
54 Promise.all(initPromises).then(this.scheduler_.start.bind(this.scheduler_)); | 54 Promise.all(initPromises).then(this.scheduler_.start.bind(this.scheduler_)); |
55 }.bind(this)); | 55 }.bind(this)); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 var targetContext = target.getContext('2d'); | 220 var targetContext = target.getContext('2d'); |
221 targetContext.save(); | 221 targetContext.save(); |
222 orientation.cancelImageOrientation( | 222 orientation.cancelImageOrientation( |
223 targetContext, targetDimensions.width, targetDimensions.height); | 223 targetContext, targetDimensions.width, targetDimensions.height); |
224 targetContext.drawImage( | 224 targetContext.drawImage( |
225 source, | 225 source, |
226 0, 0, source.width, source.height, | 226 0, 0, source.width, source.height, |
227 0, 0, targetDimensions.width, targetDimensions.height); | 227 0, 0, targetDimensions.width, targetDimensions.height); |
228 targetContext.restore(); | 228 targetContext.restore(); |
229 }; | 229 }; |
OLD | NEW |