| 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ |
| 7 | 7 |
| 8 #include <assert.h> |
| 9 |
| 8 #include "mojo/public/c/environment/async_waiter.h" | 10 #include "mojo/public/c/environment/async_waiter.h" |
| 9 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
| 10 #include "mojo/public/cpp/bindings/error_handler.h" | 12 #include "mojo/public/cpp/bindings/error_handler.h" |
| 11 #include "mojo/public/cpp/bindings/interface_ptr.h" | 13 #include "mojo/public/cpp/bindings/interface_ptr.h" |
| 12 #include "mojo/public/cpp/bindings/interface_request.h" | 14 #include "mojo/public/cpp/bindings/interface_request.h" |
| 13 #include "mojo/public/cpp/bindings/lib/filter_chain.h" | 15 #include "mojo/public/cpp/bindings/lib/filter_chain.h" |
| 14 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" | 16 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" |
| 15 #include "mojo/public/cpp/bindings/lib/router.h" | 17 #include "mojo/public/cpp/bindings/lib/router.h" |
| 16 #include "mojo/public/cpp/system/core.h" | 18 #include "mojo/public/cpp/system/core.h" |
| 17 | 19 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 StrongBinding( | 62 StrongBinding( |
| 61 Interface* impl, | 63 Interface* impl, |
| 62 InterfaceRequest<Interface> request, | 64 InterfaceRequest<Interface> request, |
| 63 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) | 65 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) |
| 64 : StrongBinding(impl) { | 66 : StrongBinding(impl) { |
| 65 binding_.Bind(request.Pass(), waiter); | 67 binding_.Bind(request.Pass(), waiter); |
| 66 } | 68 } |
| 67 | 69 |
| 68 ~StrongBinding() override {} | 70 ~StrongBinding() override {} |
| 69 | 71 |
| 72 void Bind( |
| 73 ScopedMessagePipeHandle handle, |
| 74 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| 75 assert(!binding_.is_bound()); |
| 76 binding_.Bind(handle.Pass(), waiter); |
| 77 } |
| 78 |
| 79 void Bind( |
| 80 InterfacePtr<Interface>* ptr, |
| 81 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| 82 assert(!binding_.is_bound()); |
| 83 binding_.Bind(ptr, waiter); |
| 84 } |
| 85 |
| 86 void Bind( |
| 87 InterfaceRequest<Interface> request, |
| 88 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| 89 assert(!binding_.is_bound()); |
| 90 binding_.Bind(request.Pass(), waiter); |
| 91 } |
| 92 |
| 70 bool WaitForIncomingMethodCall() { | 93 bool WaitForIncomingMethodCall() { |
| 71 return binding_.WaitForIncomingMethodCall(); | 94 return binding_.WaitForIncomingMethodCall(); |
| 72 } | 95 } |
| 73 | 96 |
| 74 void set_error_handler(ErrorHandler* error_handler) { | 97 void set_error_handler(ErrorHandler* error_handler) { |
| 75 error_handler_ = error_handler; | 98 error_handler_ = error_handler; |
| 76 } | 99 } |
| 77 | 100 |
| 78 typename Interface::Client* client() { return binding_.client(); } | 101 typename Interface::Client* client() { return binding_.client(); } |
| 79 // Exposed for testing, should not generally be used. | 102 // Exposed for testing, should not generally be used. |
| 80 internal::Router* internal_router() { return binding_.internal_router(); } | 103 internal::Router* internal_router() { return binding_.internal_router(); } |
| 81 | 104 |
| 82 // ErrorHandler implementation | 105 // ErrorHandler implementation |
| 83 void OnConnectionError() override { | 106 void OnConnectionError() override { |
| 84 if (error_handler_) | 107 if (error_handler_) |
| 85 error_handler_->OnConnectionError(); | 108 error_handler_->OnConnectionError(); |
| 86 delete binding_.impl(); | 109 delete binding_.impl(); |
| 87 } | 110 } |
| 88 | 111 |
| 89 private: | 112 private: |
| 90 ErrorHandler* error_handler_ = nullptr; | 113 ErrorHandler* error_handler_ = nullptr; |
| 91 Binding<Interface> binding_; | 114 Binding<Interface> binding_; |
| 92 }; | 115 }; |
| 93 | 116 |
| 94 } // namespace mojo | 117 } // namespace mojo |
| 95 | 118 |
| 96 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ | 119 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ |
| OLD | NEW |