OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ASSOCIATED_BINDING_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // synchrounous method calls may not be run from this task runner, when they | 89 // synchrounous method calls may not be run from this task runner, when they |
90 // reenter outgoing synchrounous calls on the same thread. | 90 // reenter outgoing synchrounous calls on the same thread. |
91 template <typename Interface, | 91 template <typename Interface, |
92 typename ImplRefTraits = RawPtrImplRefTraits<Interface>> | 92 typename ImplRefTraits = RawPtrImplRefTraits<Interface>> |
93 class AssociatedBinding : public AssociatedBindingBase { | 93 class AssociatedBinding : public AssociatedBindingBase { |
94 public: | 94 public: |
95 using ImplPointerType = typename ImplRefTraits::PointerType; | 95 using ImplPointerType = typename ImplRefTraits::PointerType; |
96 | 96 |
97 // Constructs an incomplete associated binding that will use the | 97 // Constructs an incomplete associated binding that will use the |
98 // implementation |impl|. It may be completed with a subsequent call to the | 98 // implementation |impl|. It may be completed with a subsequent call to the |
99 // |Bind| method. Does not take ownership of |impl|, which must outlive this | 99 // |Bind| method. |
100 // object. | 100 explicit AssociatedBinding(ImplPointerType impl) { |
101 explicit AssociatedBinding(ImplPointerType impl) { stub_.set_sink(impl); } | 101 stub_.set_sink(std::move(impl)); |
| 102 } |
102 | 103 |
103 // Constructs a completed associated binding of |impl|. The output |ptr_info| | 104 // Constructs a completed associated binding of |impl|. The output |ptr_info| |
104 // should be sent by another interface. |impl| must outlive this object. | 105 // should be sent by another interface. |impl| must outlive this object. |
105 AssociatedBinding(ImplPointerType impl, | 106 AssociatedBinding(ImplPointerType impl, |
106 AssociatedInterfacePtrInfo<Interface>* ptr_info, | 107 AssociatedInterfacePtrInfo<Interface>* ptr_info, |
107 scoped_refptr<base::SingleThreadTaskRunner> runner = | 108 scoped_refptr<base::SingleThreadTaskRunner> runner = |
108 base::ThreadTaskRunnerHandle::Get()) | 109 base::ThreadTaskRunnerHandle::Get()) |
109 : AssociatedBinding(std::move(impl)) { | 110 : AssociatedBinding(std::move(impl)) { |
110 Bind(ptr_info, std::move(runner)); | 111 Bind(ptr_info, std::move(runner)); |
111 } | 112 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 163 |
163 private: | 164 private: |
164 typename Interface::template Stub_<ImplRefTraits> stub_; | 165 typename Interface::template Stub_<ImplRefTraits> stub_; |
165 | 166 |
166 DISALLOW_COPY_AND_ASSIGN(AssociatedBinding); | 167 DISALLOW_COPY_AND_ASSIGN(AssociatedBinding); |
167 }; | 168 }; |
168 | 169 |
169 } // namespace mojo | 170 } // namespace mojo |
170 | 171 |
171 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ | 172 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ |
OLD | NEW |