OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Setting the src of an img to an empty string can crash the browser, so we | 5 // Setting the src of an img to an empty string can crash the browser, so we |
6 // use an empty 1x1 gif instead. | 6 // use an empty 1x1 gif instead. |
7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' | 7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' |
8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; | 8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; |
9 | 9 |
10 var g_slideshow_data = null; | 10 var g_slideshow_data = null; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 this.onDiskChanged_.bind(this)); | 141 this.onDiskChanged_.bind(this)); |
142 | 142 |
143 this.refocus(); | 143 this.refocus(); |
144 | 144 |
145 // Pass all URLs to the metadata reader until we have a correct filter. | 145 // Pass all URLs to the metadata reader until we have a correct filter. |
146 this.metadataUrlFilter_ = /.*/; | 146 this.metadataUrlFilter_ = /.*/; |
147 | 147 |
148 this.metadataReader_ = new Worker('js/metadata_dispatcher.js'); | 148 this.metadataReader_ = new Worker('js/metadata_dispatcher.js'); |
149 this.metadataReader_.onmessage = this.onMetadataMessage_.bind(this); | 149 this.metadataReader_.onmessage = this.onMetadataMessage_.bind(this); |
150 this.metadataReader_.postMessage({verb: 'init'}); | 150 this.metadataReader_.postMessage({verb: 'init'}); |
| 151 // Initialization is not complete until the Worker sends back the |
| 152 // 'initialized' message. See below. |
151 } | 153 } |
152 | 154 |
153 FileManager.prototype = { | 155 FileManager.prototype = { |
154 __proto__: cr.EventTarget.prototype | 156 __proto__: cr.EventTarget.prototype |
155 }; | 157 }; |
156 | 158 |
157 // Anonymous "namespace". | 159 // Anonymous "namespace". |
158 (function() { | 160 (function() { |
159 | 161 |
160 // Private variables and helper functions. | 162 // Private variables and helper functions. |
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 } | 1494 } |
1493 | 1495 |
1494 this.metadataCache_[fileURL] = metadata; | 1496 this.metadataCache_[fileURL] = metadata; |
1495 }; | 1497 }; |
1496 | 1498 |
1497 FileManager.prototype.onMetadataError_ = function(fileURL, step, error) { | 1499 FileManager.prototype.onMetadataError_ = function(fileURL, step, error) { |
1498 console.warn('metadata: ' + fileURL + ': ' + step + ': ' + error); | 1500 console.warn('metadata: ' + fileURL + ': ' + step + ': ' + error); |
1499 this.onMetadataResult_(fileURL, {}); | 1501 this.onMetadataResult_(fileURL, {}); |
1500 }; | 1502 }; |
1501 | 1503 |
1502 FileManager.prototype.onMetadataFilter_ = function(regexp) { | 1504 /** |
| 1505 * Handles the 'initialized' message from the metadata reader Worker. |
| 1506 */ |
| 1507 FileManager.prototype.onMetadataInitialized_ = function(regexp) { |
1503 this.metadataUrlFilter_ = regexp; | 1508 this.metadataUrlFilter_ = regexp; |
| 1509 // We're ready to run. Tests can monitor for this state with |
| 1510 // ExtensionTestMessageListener listener("worker-initialized"); |
| 1511 // ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 1512 // Automated tests need to wait for this, otherwise we crash in browser_test |
| 1513 // cleanup because the worker process still has URL requests in-flight. |
| 1514 chrome.test.sendMessage('worker-initialized'); |
1504 }; | 1515 }; |
1505 | 1516 |
1506 FileManager.prototype.onMetadataLog_ = function(arglist) { | 1517 FileManager.prototype.onMetadataLog_ = function(arglist) { |
1507 console.log.apply(console, ['metadata:'].concat(arglist)); | 1518 console.log.apply(console, ['metadata:'].concat(arglist)); |
1508 }; | 1519 }; |
1509 | 1520 |
1510 /** | 1521 /** |
1511 * Dispatch a message from a metadata reader to the appropriate onMetadata* | 1522 * Dispatch a message from a metadata reader to the appropriate onMetadata* |
1512 * method. | 1523 * method. |
1513 */ | 1524 */ |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2995 | 3006 |
2996 if (msg) { | 3007 if (msg) { |
2997 console.log('no no no'); | 3008 console.log('no no no'); |
2998 this.alert.show(msg, onAccept); | 3009 this.alert.show(msg, onAccept); |
2999 return false; | 3010 return false; |
3000 } | 3011 } |
3001 | 3012 |
3002 return true; | 3013 return true; |
3003 }; | 3014 }; |
3004 })(); | 3015 })(); |
OLD | NEW |