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

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

Issue 728553002: Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.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
« no previous file with comments | « mojo/edk/js/handle.h ('k') | mojo/edk/js/handle_close_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/edk/js/handle.h" 5 #include "mojo/edk/js/handle.h"
6 6
7 #include <sstream>
8 #include "mojo/edk/js/handle_close_observer.h" 7 #include "mojo/edk/js/handle_close_observer.h"
9 8
10 namespace mojo { 9 namespace mojo {
11 namespace js { 10 namespace js {
12 11
13 gin::WrapperInfo HandleWrapper::kWrapperInfo = { gin::kEmbedderNativeGin }; 12 gin::WrapperInfo HandleWrapper::kWrapperInfo = { gin::kEmbedderNativeGin };
14 13
15 HandleWrapper::HandleWrapper(MojoHandle handle) 14 HandleWrapper::HandleWrapper(MojoHandle handle)
16 : handle_(mojo::Handle(handle)) { 15 : handle_(mojo::Handle(handle)) {
17 } 16 }
18 17
19 HandleWrapper::~HandleWrapper() { 18 HandleWrapper::~HandleWrapper() {
20 NotifyCloseObservers(); 19 NotifyCloseObservers();
21 } 20 }
22 21
23 std::string HandleWrapper::ToString() {
24 std::ostringstream oss;
25 oss << "[mojo::Handle ";
26 if (handle_.is_valid())
27 oss << handle_.get().value();
28 else
29 oss << "null";
30 oss << "]";
31 return oss.str();
32 }
33
34 gin::ObjectTemplateBuilder HandleWrapper::GetObjectTemplateBuilder(
35 v8::Isolate* isolate) {
36 return Wrappable<HandleWrapper>::GetObjectTemplateBuilder(isolate)
37 .SetMethod("toString", &HandleWrapper::ToString);
38 }
39
40 void HandleWrapper::Close() { 22 void HandleWrapper::Close() {
41 NotifyCloseObservers(); 23 NotifyCloseObservers();
42 handle_.reset(); 24 handle_.reset();
43 } 25 }
44 26
45 void HandleWrapper::AddCloseObserver(HandleCloseObserver* observer) { 27 void HandleWrapper::AddCloseObserver(HandleCloseObserver* observer) {
46 close_observers_.AddObserver(observer); 28 close_observers_.AddObserver(observer);
47 } 29 }
48 30
49 void HandleWrapper::RemoveCloseObserver(HandleCloseObserver* observer) { 31 void HandleWrapper::RemoveCloseObserver(HandleCloseObserver* observer) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 74 }
93 75
94 bool Converter<mojo::MessagePipeHandle>::FromV8(v8::Isolate* isolate, 76 bool Converter<mojo::MessagePipeHandle>::FromV8(v8::Isolate* isolate,
95 v8::Handle<v8::Value> val, 77 v8::Handle<v8::Value> val,
96 mojo::MessagePipeHandle* out) { 78 mojo::MessagePipeHandle* out) {
97 return Converter<mojo::Handle>::FromV8(isolate, val, out); 79 return Converter<mojo::Handle>::FromV8(isolate, val, out);
98 } 80 }
99 81
100 82
101 } // namespace gin 83 } // namespace gin
OLDNEW
« no previous file with comments | « mojo/edk/js/handle.h ('k') | mojo/edk/js/handle_close_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698