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

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

Issue 615633003: MediaGalleriesCustomBindings: Ensure blobs aren't GC'd when getMetadata runs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a comment, and add me to OWNERS. Created 6 years, 3 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
« no previous file with comments | « chrome/renderer/resources/extensions/OWNERS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/media_galleries_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/media_galleries_custom_bindings.js b/chrome/renderer/resources/extensions/media_galleries_custom_bindings.js
index f838086848c1b555f6a5e490288202d191f99a08..bbe740ac72245154b2b6652f1e85c0135bc0295a 100644
--- a/chrome/renderer/resources/extensions/media_galleries_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/media_galleries_custom_bindings.js
@@ -8,6 +8,7 @@ var binding = require('binding').Binding.create('mediaGalleries');
var blobNatives = requireNative('blob_natives');
var mediaGalleriesNatives = requireNative('mediaGalleries');
+var blobsAwaitingMetadata = {};
var mediaGalleriesMetadata = {};
function createFileSystemObjectsAndUpdateMetadata(response) {
@@ -101,6 +102,10 @@ binding.registerCustomHook(function(bindingsAPI, extensionId) {
apiFunctions.setUpdateArgumentsPostValidate('getMetadata',
function(mediaFile, options, callback) {
var blobUuid = blobNatives.GetBlobUuid(mediaFile)
+ // Store the blob in a global object to keep its refcount nonzero -- this
+ // prevents the object from being garbage collected before any metadata
+ // parsing gets to occur (see crbug.com/415792).
+ blobsAwaitingMetadata[blobUuid] = mediaFile;
return [blobUuid, options, callback];
});
@@ -118,6 +123,11 @@ binding.registerCustomHook(function(bindingsAPI, extensionId) {
if (request.callback)
request.callback(response.metadata);
request.callback = null;
+
+ // The UUID was in position 0 in the setUpdateArgumentsPostValidate
+ // function.
+ var uuid = request.args[0];
+ delete blobsAwaitingMetadata[uuid];
});
});
« no previous file with comments | « chrome/renderer/resources/extensions/OWNERS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698