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_LIB_INTERFACE_PTR_STATE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_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 <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/callback_forward.h" | 16 #include "base/callback_forward.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
21 #include "base/single_thread_task_runner.h" | 21 #include "base/sequenced_task_runner.h" |
22 #include "mojo/public/cpp/bindings/associated_group.h" | 22 #include "mojo/public/cpp/bindings/associated_group.h" |
23 #include "mojo/public/cpp/bindings/connection_error_callback.h" | 23 #include "mojo/public/cpp/bindings/connection_error_callback.h" |
24 #include "mojo/public/cpp/bindings/filter_chain.h" | 24 #include "mojo/public/cpp/bindings/filter_chain.h" |
25 #include "mojo/public/cpp/bindings/interface_endpoint_client.h" | 25 #include "mojo/public/cpp/bindings/interface_endpoint_client.h" |
26 #include "mojo/public/cpp/bindings/interface_id.h" | 26 #include "mojo/public/cpp/bindings/interface_id.h" |
27 #include "mojo/public/cpp/bindings/interface_ptr_info.h" | 27 #include "mojo/public/cpp/bindings/interface_ptr_info.h" |
28 #include "mojo/public/cpp/bindings/lib/control_message_handler.h" | 28 #include "mojo/public/cpp/bindings/lib/control_message_handler.h" |
29 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" | 29 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" |
30 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" | 30 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" |
31 #include "mojo/public/cpp/bindings/message_header_validator.h" | 31 #include "mojo/public/cpp/bindings/message_header_validator.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 using std::swap; | 88 using std::swap; |
89 swap(other->router_, router_); | 89 swap(other->router_, router_); |
90 swap(other->endpoint_client_, endpoint_client_); | 90 swap(other->endpoint_client_, endpoint_client_); |
91 swap(other->proxy_, proxy_); | 91 swap(other->proxy_, proxy_); |
92 handle_.swap(other->handle_); | 92 handle_.swap(other->handle_); |
93 runner_.swap(other->runner_); | 93 runner_.swap(other->runner_); |
94 swap(other->version_, version_); | 94 swap(other->version_, version_); |
95 } | 95 } |
96 | 96 |
97 void Bind(InterfacePtrInfo<Interface> info, | 97 void Bind(InterfacePtrInfo<Interface> info, |
98 scoped_refptr<base::SingleThreadTaskRunner> runner) { | 98 scoped_refptr<base::SequencedTaskRunner> runner) { |
99 DCHECK(!router_); | 99 DCHECK(!router_); |
100 DCHECK(!endpoint_client_); | 100 DCHECK(!endpoint_client_); |
101 DCHECK(!proxy_); | 101 DCHECK(!proxy_); |
102 DCHECK(!handle_.is_valid()); | 102 DCHECK(!handle_.is_valid()); |
103 DCHECK_EQ(0u, version_); | 103 DCHECK_EQ(0u, version_); |
104 DCHECK(info.is_valid()); | 104 DCHECK(info.is_valid()); |
105 | 105 |
106 handle_ = info.PassHandle(); | 106 handle_ = info.PassHandle(); |
107 version_ = info.version(); | 107 version_ = info.version(); |
108 runner_ = std::move(runner); | 108 runner_ = std::move(runner); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 scoped_refptr<MultiplexRouter> router_; | 211 scoped_refptr<MultiplexRouter> router_; |
212 | 212 |
213 std::unique_ptr<InterfaceEndpointClient> endpoint_client_; | 213 std::unique_ptr<InterfaceEndpointClient> endpoint_client_; |
214 std::unique_ptr<Proxy> proxy_; | 214 std::unique_ptr<Proxy> proxy_; |
215 | 215 |
216 // |router_| (as well as other members above) is not initialized until | 216 // |router_| (as well as other members above) is not initialized until |
217 // read/write with the message pipe handle is needed. |handle_| is valid | 217 // read/write with the message pipe handle is needed. |handle_| is valid |
218 // between the Bind() call and the initialization of |router_|. | 218 // between the Bind() call and the initialization of |router_|. |
219 ScopedMessagePipeHandle handle_; | 219 ScopedMessagePipeHandle handle_; |
220 scoped_refptr<base::SingleThreadTaskRunner> runner_; | 220 scoped_refptr<base::SequencedTaskRunner> runner_; |
221 | 221 |
222 uint32_t version_; | 222 uint32_t version_; |
223 | 223 |
224 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); | 224 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); |
225 }; | 225 }; |
226 | 226 |
227 } // namespace internal | 227 } // namespace internal |
228 } // namespace mojo | 228 } // namespace mojo |
229 | 229 |
230 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ | 230 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ |
OLD | NEW |