OLD | NEW |
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 "mojo/bindings/js/handle_close_observer.h" | 7 #include "mojo/bindings/js/handle_close_observer.h" |
8 | 8 |
9 namespace gin { | 9 namespace mojo { |
| 10 namespace js { |
10 | 11 |
11 gin::WrapperInfo HandleWrapper::kWrapperInfo = { gin::kEmbedderNativeGin }; | 12 gin::WrapperInfo HandleWrapper::kWrapperInfo = { gin::kEmbedderNativeGin }; |
12 | 13 |
13 HandleWrapper::HandleWrapper(MojoHandle handle) | 14 HandleWrapper::HandleWrapper(MojoHandle handle) |
14 : handle_(mojo::Handle(handle)) { | 15 : handle_(mojo::Handle(handle)) { |
15 } | 16 } |
16 | 17 |
17 HandleWrapper::~HandleWrapper() { | 18 HandleWrapper::~HandleWrapper() { |
18 NotifyCloseObservers(); | 19 NotifyCloseObservers(); |
19 } | 20 } |
(...skipping 11 matching lines...) Expand all Loading... |
31 close_observers_.RemoveObserver(observer); | 32 close_observers_.RemoveObserver(observer); |
32 } | 33 } |
33 | 34 |
34 void HandleWrapper::NotifyCloseObservers() { | 35 void HandleWrapper::NotifyCloseObservers() { |
35 if (!handle_.is_valid()) | 36 if (!handle_.is_valid()) |
36 return; | 37 return; |
37 | 38 |
38 FOR_EACH_OBSERVER(HandleCloseObserver, close_observers_, OnWillCloseHandle()); | 39 FOR_EACH_OBSERVER(HandleCloseObserver, close_observers_, OnWillCloseHandle()); |
39 } | 40 } |
40 | 41 |
| 42 } // namespace js |
| 43 } // namespace mojo |
| 44 |
| 45 namespace gin { |
| 46 |
41 v8::Handle<v8::Value> Converter<mojo::Handle>::ToV8(v8::Isolate* isolate, | 47 v8::Handle<v8::Value> Converter<mojo::Handle>::ToV8(v8::Isolate* isolate, |
42 const mojo::Handle& val) { | 48 const mojo::Handle& val) { |
43 if (!val.is_valid()) | 49 if (!val.is_valid()) |
44 return v8::Null(isolate); | 50 return v8::Null(isolate); |
45 return HandleWrapper::Create(isolate, val.value()).ToV8(); | 51 return mojo::js::HandleWrapper::Create(isolate, val.value()).ToV8(); |
46 } | 52 } |
47 | 53 |
48 bool Converter<mojo::Handle>::FromV8(v8::Isolate* isolate, | 54 bool Converter<mojo::Handle>::FromV8(v8::Isolate* isolate, |
49 v8::Handle<v8::Value> val, | 55 v8::Handle<v8::Value> val, |
50 mojo::Handle* out) { | 56 mojo::Handle* out) { |
51 if (val->IsNull()) { | 57 if (val->IsNull()) { |
52 *out = mojo::Handle(); | 58 *out = mojo::Handle(); |
53 return true; | 59 return true; |
54 } | 60 } |
55 | 61 |
56 gin::Handle<HandleWrapper> handle; | 62 gin::Handle<mojo::js::HandleWrapper> handle; |
57 if (!Converter<gin::Handle<HandleWrapper> >::FromV8(isolate, val, &handle)) | 63 if (!Converter<gin::Handle<mojo::js::HandleWrapper> >::FromV8( |
| 64 isolate, val, &handle)) |
58 return false; | 65 return false; |
59 | 66 |
60 *out = handle->get(); | 67 *out = handle->get(); |
61 return true; | 68 return true; |
62 } | 69 } |
63 | 70 |
64 } // namespace gin | 71 } // namespace gin |
OLD | NEW |