Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3345)

Unified Diff: chrome/renderer/resources/extensions/app_runtime_custom_bindings.js

Issue 12391006: Give an app the file entries it had back on restart. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/app_runtime_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/app_runtime_custom_bindings.js b/chrome/renderer/resources/extensions/app_runtime_custom_bindings.js
index d17d2e55fa76c8696fe26e0b90475b1af60ca3d9..0f3a0f784daa5cc6874c6d2ae5c3b2a72a5fb9d7 100644
--- a/chrome/renderer/resources/extensions/app_runtime_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/app_runtime_custom_bindings.js
@@ -15,6 +15,38 @@ var appNatives = requireNative('app_runtime');
var DeserializeString = appNatives.DeserializeString;
var SerializeToString = appNatives.SerializeToString;
var CreateBlob = appNatives.CreateBlob;
+var entryIdManager = require('entryIdManager');
+
+chromeHidden.Event.registerArgumentMassager('app.runtime.onRestarted',
+ function(args, dispatch) {
+ // These file entries don't get dispatched, we just use this hook to register
+ // them all with entryIdManager.
+ var fileEntries = args[0];
+
+ var pendingCallbacks = fileEntries.length;
+
+ var dispatchIfNoPendingCallbacks = function() {
+ if (pendingCallbacks == 0)
+ dispatch([]);
+ };
+
+ for (var i = 0; i < fileEntries.length; i++) {
+ var fe = fileEntries[i];
+ var fs = GetIsolatedFileSystem(fe.fileSystemId);
+ (function(fe, fs) {
benwells 2013/03/13 03:58:29 Why is this done in an anonymous function?
koz (OOO until 15th September) 2013/03/13 05:01:13 Because the var fe, fs above are actually scoped t
+ fs.root.getFile(fe.baseName, {}, function(fileEntry) {
+ entryIdManager.registerEntry(fe.id, fileEntry);
+ pendingCallbacks--;
+ dispatchIfNoPendingCallbacks();
+ }, function(err) {
+ console.error('Error getting fileEntry, code: ' + err.code);
+ pendingCallbacks--;
+ dispatchIfNoPendingCallbacks();
+ });
+ })(fe, fs);
+ }
+ dispatchIfNoPendingCallbacks();
+});
chromeHidden.Event.registerArgumentMassager('app.runtime.onLaunched',
function(args, dispatch) {

Powered by Google App Engine
This is Rietveld 408576698