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

Unified Diff: ppapi/cpp/var.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/cpp/var.cc
diff --git a/ppapi/cpp/var.cc b/ppapi/cpp/var.cc
index 2b52f044944d7aa5566aec146147a9986095c99e..512fd00a36efe64b995f04d06ca67bf7cdcf6c85 100644
--- a/ppapi/cpp/var.cc
+++ b/ppapi/cpp/var.cc
@@ -104,7 +104,7 @@ Var::Var(const std::string& utf8_str) {
Var::Var(const Var& other) {
var_ = other.var_;
if (NeedsRefcounting(var_)) {
- if (has_interface<PPB_Var>()) {
+ if (has_interface<PPB_Var_1_0>()) {
needs_release_ = true;
get_interface<PPB_Var_1_0>()->AddRef(var_);
} else {
@@ -117,7 +117,7 @@ Var::Var(const Var& other) {
}
Var::~Var() {
- if (needs_release_ && has_interface<PPB_Var>())
+ if (needs_release_ && has_interface<PPB_Var_1_0>())
get_interface<PPB_Var_1_0>()->Release(var_);
}
@@ -132,8 +132,8 @@ Var& Var::operator=(const Var& other) {
// object to itself by addrefing the new one before releasing the old one.
bool old_needs_release = needs_release_;
if (NeedsRefcounting(other.var_)) {
- // Assume we already has_interface<PPB_Var> for refcounted vars or else we
- // couldn't have created them in the first place.
+ // Assume we already has_interface<PPB_Var_1_0> for refcounted vars or else
+ // we couldn't have created them in the first place.
needs_release_ = true;
get_interface<PPB_Var_1_0>()->AddRef(other.var_);
} else {
@@ -203,7 +203,7 @@ std::string Var::AsString() const {
return std::string();
}
- if (!has_interface<PPB_Var>())
+ if (!has_interface<PPB_Var_1_0>())
return std::string();
uint32_t len;
const char* str = get_interface<PPB_Var_1_0>()->VarToUtf8(var_, &len);
@@ -213,18 +213,18 @@ std::string Var::AsString() const {
std::string Var::DebugString() const {
char buf[256];
if (is_undefined()) {
- snprintf(buf, sizeof(buf), "Var<UNDEFINED>");
+ snprintf(buf, sizeof(buf), "Var(UNDEFINED)");
} else if (is_null()) {
- snprintf(buf, sizeof(buf), "Var<NULL>");
+ snprintf(buf, sizeof(buf), "Var(NULL)");
} else if (is_bool()) {
- snprintf(buf, sizeof(buf), AsBool() ? "Var<true>" : "Var<false>");
+ snprintf(buf, sizeof(buf), AsBool() ? "Var(true)" : "Var(false)");
} else if (is_int()) {
// Note that the following static_cast is necessary because
// NativeClient's int32_t is actually "long".
// TODO(sehr,polina): remove this after newlib is changed.
- snprintf(buf, sizeof(buf), "Var<%d>", static_cast<int>(AsInt()));
+ snprintf(buf, sizeof(buf), "Var(%d)", static_cast<int>(AsInt()));
} else if (is_double()) {
- snprintf(buf, sizeof(buf), "Var<%f>", AsDouble());
+ snprintf(buf, sizeof(buf), "Var(%f)", AsDouble());
} else if (is_string()) {
char format[] = "Var<'%s'>";
size_t decoration = sizeof(format) - 2; // The %s is removed.
@@ -235,8 +235,12 @@ std::string Var::DebugString() const {
str.append("...");
}
snprintf(buf, sizeof(buf), format, str.c_str());
+ } else if (is_array_buffer()) {
+ // TODO(dmichael): We could make this dump hex. Maybe DebugString should be
+ // virtual?
+ snprintf(buf, sizeof(buf), "Var(ARRAY_BUFFER)");
} else if (is_object()) {
- snprintf(buf, sizeof(buf), "Var<OBJECT>");
+ snprintf(buf, sizeof(buf), "Var(OBJECT)");
}
return buf;
}
« no previous file with comments | « ppapi/cpp/dev/var_array_buffer_dev.cc ('k') | ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_messaging_rpc_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698