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

Unified Diff: mojo/bindings/js/handle.cc

Issue 646783005: Mojo JS Bindings: Mojo handles need a toString() method Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « mojo/bindings/js/handle.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/bindings/js/handle.cc
diff --git a/mojo/bindings/js/handle.cc b/mojo/bindings/js/handle.cc
index baa1baea3a2eb92788fe72d03816b225012cb554..c5d5411609e3a8a3aa4861fb8d60c1cdbe1628cf 100644
--- a/mojo/bindings/js/handle.cc
+++ b/mojo/bindings/js/handle.cc
@@ -4,6 +4,7 @@
#include "mojo/bindings/js/handle.h"
+#include <sstream>
#include "mojo/bindings/js/handle_close_observer.h"
namespace mojo {
@@ -19,6 +20,24 @@ HandleWrapper::~HandleWrapper() {
NotifyCloseObservers();
}
+std::string HandleWrapper::ToString() {
+ std::ostringstream oss;
+ oss << "[mojo::Handle ";
+ if (handle_.is_valid())
+ oss << handle_.get().value();
+ else
+ oss << "null";
+ oss << " " << std::hex << this;
abarth-chromium 2014/10/24 17:13:27 I don't think you want to leak the address of |thi
hansmuller 2014/10/24 18:14:02 OK, I've removed that.
+ oss << "]";
+ return oss.str();
+}
+
+gin::ObjectTemplateBuilder HandleWrapper::GetObjectTemplateBuilder(
+ v8::Isolate* isolate) {
+ return Wrappable<HandleWrapper>::GetObjectTemplateBuilder(isolate)
+ .SetMethod("toString", &HandleWrapper::ToString);
+}
+
void HandleWrapper::Close() {
NotifyCloseObservers();
handle_.reset();
« no previous file with comments | « mojo/bindings/js/handle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698