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

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: Undo unintended change to apitest. 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 | « no previous file | 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..841cefa387f2300aad1ef2795b35d3a63213699f 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 mediaFilesMetadata = {};
tommycli 2014/09/29 21:50:00 This makes it sound like you're storing the metada
Oren Blasberg 2014/09/29 22:05:48 Done.
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
tommycli 2014/09/29 21:50:00 Perfect comment :)
Oren Blasberg 2014/09/29 22:05:48 Thanks Tommy!
+ // prevents the object from being garbage collected before any metadata
+ // parsing gets to occur (see crbug.com/415792).
+ mediaFilesMetadata[blobUuid] = mediaFile;
return [blobUuid, options, callback];
});
@@ -118,6 +123,9 @@ binding.registerCustomHook(function(bindingsAPI, extensionId) {
if (request.callback)
request.callback(response.metadata);
request.callback = null;
+
+ var uuid = request.args[0];
tommycli 2014/09/29 21:50:00 Maybe a short one-line comment since this is not s
Oren Blasberg 2014/09/29 22:05:48 What sort of comment would be reasonable here? Rem
tommycli 2014/09/29 22:09:25 It's the uuid because of line 109: return [blobUui
+ delete mediaFilesMetadata[uuid];
});
});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698