| 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/edk/js/handle.h" | 5 #include "mojo/edk/js/handle.h" |
| 6 | 6 |
| 7 #include "mojo/edk/js/handle_close_observer.h" | 7 #include "mojo/edk/js/handle_close_observer.h" |
| 8 | 8 |
| 9 namespace mojo { | 9 namespace mojo { |
| 10 namespace edk { | 10 namespace edk { |
| 11 namespace js { | 11 namespace js { |
| 12 | 12 |
| 13 gin::WrapperInfo HandleWrapper::kWrapperInfo = { gin::kEmbedderNativeGin }; | 13 gin::WrapperInfo HandleWrapper::kWrapperInfo = { gin::kEmbedderNativeGin }; |
| 14 | 14 |
| 15 HandleWrapper::HandleWrapper(MojoHandle handle) | 15 HandleWrapper::HandleWrapper(MojoHandle handle) |
| 16 : handle_(mojo::Handle(handle)) { | 16 : handle_(mojo::Handle(handle)), handle_value_(handle) { |
| 17 LOG(INFO) << "Create " << handle_->value(); |
| 17 } | 18 } |
| 18 | 19 |
| 19 HandleWrapper::~HandleWrapper() { | 20 HandleWrapper::~HandleWrapper() { |
| 20 NotifyCloseObservers(); | 21 NotifyCloseObservers(); |
| 22 LOG(INFO) << "Delete " << handle_->value() << " (" << handle_value_ << ")"; |
| 21 } | 23 } |
| 22 | 24 |
| 23 void HandleWrapper::Close() { | 25 void HandleWrapper::Close() { |
| 24 NotifyCloseObservers(); | 26 NotifyCloseObservers(); |
| 27 LOG(INFO) << "Close " << handle_->value(); |
| 25 handle_.reset(); | 28 handle_.reset(); |
| 26 } | 29 } |
| 27 | 30 |
| 28 void HandleWrapper::AddCloseObserver(HandleCloseObserver* observer) { | 31 void HandleWrapper::AddCloseObserver(HandleCloseObserver* observer) { |
| 29 close_observers_.AddObserver(observer); | 32 close_observers_.AddObserver(observer); |
| 30 } | 33 } |
| 31 | 34 |
| 32 void HandleWrapper::RemoveCloseObserver(HandleCloseObserver* observer) { | 35 void HandleWrapper::RemoveCloseObserver(HandleCloseObserver* observer) { |
| 33 close_observers_.RemoveObserver(observer); | 36 close_observers_.RemoveObserver(observer); |
| 34 } | 37 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 return Converter<mojo::Handle>::ToV8(isolate, val); | 78 return Converter<mojo::Handle>::ToV8(isolate, val); |
| 76 } | 79 } |
| 77 | 80 |
| 78 bool Converter<mojo::MessagePipeHandle>::FromV8(v8::Isolate* isolate, | 81 bool Converter<mojo::MessagePipeHandle>::FromV8(v8::Isolate* isolate, |
| 79 v8::Handle<v8::Value> val, | 82 v8::Handle<v8::Value> val, |
| 80 mojo::MessagePipeHandle* out) { | 83 mojo::MessagePipeHandle* out) { |
| 81 return Converter<mojo::Handle>::FromV8(isolate, val, out); | 84 return Converter<mojo::Handle>::FromV8(isolate, val, out); |
| 82 } | 85 } |
| 83 | 86 |
| 84 } // namespace gin | 87 } // namespace gin |
| OLD | NEW |