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

Side by Side Diff: mojo/bindings/js/handle.cc

Issue 686203004: Mojo JS Bindings: Simplify sharing services for content-provided JS applications (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/bindings/js/handle.h" 5 #include "mojo/bindings/js/handle.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include "mojo/bindings/js/handle_close_observer.h" 8 #include "mojo/bindings/js/handle_close_observer.h"
9 9
10 namespace mojo { 10 namespace mojo {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 gin::Handle<mojo::js::HandleWrapper> handle; 80 gin::Handle<mojo::js::HandleWrapper> handle;
81 if (!Converter<gin::Handle<mojo::js::HandleWrapper> >::FromV8( 81 if (!Converter<gin::Handle<mojo::js::HandleWrapper> >::FromV8(
82 isolate, val, &handle)) 82 isolate, val, &handle))
83 return false; 83 return false;
84 84
85 *out = handle->get(); 85 *out = handle->get();
86 return true; 86 return true;
87 } 87 }
88 88
89 v8::Handle<v8::Value> Converter<mojo::MessagePipeHandle>::ToV8(
Aaron Boodman 2014/10/29 23:06:29 You can just delegate to the converter for mojo::H
hansmuller 2014/10/30 00:23:38 Good point!
90 v8::Isolate* isolate, mojo::MessagePipeHandle val) {
91 if (!val.is_valid())
92 return v8::Null(isolate);
93 return mojo::js::HandleWrapper::Create(isolate, val.value()).ToV8();
94 }
95
96 bool Converter<mojo::MessagePipeHandle>::FromV8(v8::Isolate* isolate,
97 v8::Handle<v8::Value> val,
98 mojo::MessagePipeHandle* out) {
99 if (val->IsNull()) {
100 *out = mojo::MessagePipeHandle();
101 return true;
102 }
103
104 gin::Handle<mojo::js::HandleWrapper> handle;
105 if (!Converter<gin::Handle<mojo::js::HandleWrapper> >::FromV8(
106 isolate, val, &handle))
107 return false;
108
109 *out = mojo::MessagePipeHandle(handle->get().value());
110 return true;
111 }
112
113
89 } // namespace gin 114 } // namespace gin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698