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

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: Removed address from output, added a unit test 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
Index: mojo/bindings/js/handle.cc
diff --git a/mojo/bindings/js/handle.cc b/mojo/bindings/js/handle.cc
index baa1baea3a2eb92788fe72d03816b225012cb554..37384d6cbcb5222bece45ebf045ad3e312b54655 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,23 @@ 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 << "]";
+ 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();

Powered by Google App Engine
This is Rietveld 408576698