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

Unified Diff: ppapi/native_client/src/shared/ppapi_proxy/proxy_var_cache.cc

Issue 8982006: Add GetLiveVars to PPB_Testing_Dev. Fix leaks it uncovered. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged Created 9 years 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: ppapi/native_client/src/shared/ppapi_proxy/proxy_var_cache.cc
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/proxy_var_cache.cc b/ppapi/native_client/src/shared/ppapi_proxy/proxy_var_cache.cc
index 636302cf21035750066f9bf1ddcb6ce74189be64..b1728695e6f4907ea8ddb4f0c89d8c63fac31bd7 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/proxy_var_cache.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/proxy_var_cache.cc
@@ -16,6 +16,17 @@ namespace {
pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER;
+// Convert the given SharedProxyVar to a PP_Var, incrementing the reference
+// count by 1.
+PP_Var GetPPVar(const SharedProxyVar& proxy_var) {
+ PP_Var var;
+ var.type = proxy_var->pp_var_type();
+ var.padding = 0;
+ var.value.as_id = proxy_var->id();
+ proxy_var->AddRef();
+ return var;
+}
+
} // namespace
ProxyVarCache* ProxyVarCache::cache_singleton = NULL;
@@ -86,4 +97,15 @@ SharedProxyVar ProxyVarCache::SharedProxyVarForVar(PP_Var pp_var) const {
return proxy_var;
}
+std::vector<PP_Var> ProxyVarCache::GetLiveVars() {
+ std::vector<PP_Var> live_vars;
+ pthread_mutex_lock(&mu);
+ for (ProxyVarDictionary::const_iterator iter(proxy_var_cache_.begin());
+ iter != proxy_var_cache_.end();
+ ++iter)
+ live_vars.push_back(GetPPVar(iter->second));
+ pthread_mutex_unlock(&mu);
+ return live_vars;
+}
+
} // namespace ppapi_proxy
« no previous file with comments | « ppapi/native_client/src/shared/ppapi_proxy/proxy_var_cache.h ('k') | ppapi/proxy/plugin_var_serialization_rules.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698