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_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> // For |std::swap()|. | 10 #include <algorithm> // For |std::swap()|. |
11 #include <memory> | 11 #include <memory> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "mojo/public/cpp/bindings/associated_group.h" | 20 #include "mojo/public/cpp/bindings/associated_group.h" |
| 21 #include "mojo/public/cpp/bindings/associated_group_controller.h" |
21 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" | 22 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" |
| 23 #include "mojo/public/cpp/bindings/interface_endpoint_client.h" |
| 24 #include "mojo/public/cpp/bindings/interface_id.h" |
22 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" | 25 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" |
23 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h" | |
24 #include "mojo/public/cpp/bindings/lib/interface_id.h" | |
25 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" | |
26 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" | 26 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" |
27 #include "mojo/public/cpp/system/message_pipe.h" | 27 #include "mojo/public/cpp/system/message_pipe.h" |
28 | 28 |
29 namespace mojo { | 29 namespace mojo { |
30 namespace internal { | 30 namespace internal { |
31 | 31 |
32 template <typename Interface> | 32 template <typename Interface> |
33 class AssociatedInterfacePtrState { | 33 class AssociatedInterfacePtrState { |
34 public: | 34 public: |
35 AssociatedInterfacePtrState() : version_(0u) {} | 35 AssociatedInterfacePtrState() : version_(0u) {} |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 DCHECK(!proxy_); | 83 DCHECK(!proxy_); |
84 DCHECK_EQ(0u, version_); | 84 DCHECK_EQ(0u, version_); |
85 DCHECK(info.is_valid()); | 85 DCHECK(info.is_valid()); |
86 | 86 |
87 version_ = info.version(); | 87 version_ = info.version(); |
88 endpoint_client_.reset(new InterfaceEndpointClient( | 88 endpoint_client_.reset(new InterfaceEndpointClient( |
89 info.PassHandle(), nullptr, | 89 info.PassHandle(), nullptr, |
90 base::WrapUnique(new typename Interface::ResponseValidator_()), false, | 90 base::WrapUnique(new typename Interface::ResponseValidator_()), false, |
91 std::move(runner))); | 91 std::move(runner))); |
92 proxy_.reset(new Proxy(endpoint_client_.get())); | 92 proxy_.reset(new Proxy(endpoint_client_.get())); |
93 proxy_->serialization_context()->router = endpoint_client_->router(); | 93 proxy_->serialization_context()->group_controller = |
| 94 endpoint_client_->group_controller(); |
94 } | 95 } |
95 | 96 |
96 // After this method is called, the object is in an invalid state and | 97 // After this method is called, the object is in an invalid state and |
97 // shouldn't be reused. | 98 // shouldn't be reused. |
98 AssociatedInterfacePtrInfo<Interface> PassInterface() { | 99 AssociatedInterfacePtrInfo<Interface> PassInterface() { |
99 ScopedInterfaceEndpointHandle handle = endpoint_client_->PassHandle(); | 100 ScopedInterfaceEndpointHandle handle = endpoint_client_->PassHandle(); |
100 endpoint_client_.reset(); | 101 endpoint_client_.reset(); |
101 proxy_.reset(); | 102 proxy_.reset(); |
102 return AssociatedInterfacePtrInfo<Interface>(std::move(handle), version_); | 103 return AssociatedInterfacePtrInfo<Interface>(std::move(handle), version_); |
103 } | 104 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 137 |
137 uint32_t version_; | 138 uint32_t version_; |
138 | 139 |
139 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfacePtrState); | 140 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfacePtrState); |
140 }; | 141 }; |
141 | 142 |
142 } // namespace internal | 143 } // namespace internal |
143 } // namespace mojo | 144 } // namespace mojo |
144 | 145 |
145 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ | 146 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ |
OLD | NEW |