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

Unified Diff: ppapi/proxy/host_var_serialization_rules.cc

Issue 874703003: PPAPI: Release renderer Var refcount when returning to plugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | ppapi/proxy/serialized_var_unittest.cc » ('j') | ppapi/proxy/serialized_var_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/host_var_serialization_rules.cc
diff --git a/ppapi/proxy/host_var_serialization_rules.cc b/ppapi/proxy/host_var_serialization_rules.cc
index dcc965bd69121622deefe3aeb8c4dd4636ad3d8c..cab4be5c3c7f8a631b5c3dceb83207f19fb58778 100644
--- a/ppapi/proxy/host_var_serialization_rules.cc
+++ b/ppapi/proxy/host_var_serialization_rules.cc
@@ -45,9 +45,18 @@ PP_Var HostVarSerializationRules::BeginSendPassRef(const PP_Var& var) {
return var;
}
-void HostVarSerializationRules::EndSendPassRef(const PP_Var& /* var */) {
+void HostVarSerializationRules::EndSendPassRef(const PP_Var& var) {
// See PluginVarSerialization::ReceivePassRef for an example. We don't need
raymes 2015/01/27 00:12:44 nit: PluginVarSerializationRules?
- // to do anything here.
+ // to do anything here for "Object" vars; we continue holding one ref on
+ // behalf of the plugin.
+ if (var.type != PP_VARTYPE_OBJECT) {
+ // But for other ref-counted types (like String, Array, and Dictionary),
+ // the value will be re-constituted on the other side as a new Var with no
+ // connection to the host-side reference counting. We must therefore release
+ // our reference count; this is roughly equivalent to passing the ref to the
+ // plugin.
+ PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var);
+ }
}
void HostVarSerializationRules::ReleaseObjectRef(const PP_Var& var) {
« no previous file with comments | « no previous file | ppapi/proxy/serialized_var_unittest.cc » ('j') | ppapi/proxy/serialized_var_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698