Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: mojo/public/cpp/bindings/lib/binding_state.h

Issue 2114523002: Move more Mojo bindings helpers out of internal namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@group-controller
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/cpp/bindings/connector.h ('k') | mojo/public/cpp/bindings/lib/connector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_BINDING_STATE_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "mojo/public/cpp/bindings/associated_group.h" 18 #include "mojo/public/cpp/bindings/associated_group.h"
19 #include "mojo/public/cpp/bindings/interface_endpoint_client.h" 19 #include "mojo/public/cpp/bindings/interface_endpoint_client.h"
20 #include "mojo/public/cpp/bindings/interface_id.h" 20 #include "mojo/public/cpp/bindings/interface_id.h"
21 #include "mojo/public/cpp/bindings/interface_ptr.h" 21 #include "mojo/public/cpp/bindings/interface_ptr.h"
22 #include "mojo/public/cpp/bindings/interface_ptr_info.h" 22 #include "mojo/public/cpp/bindings/interface_ptr_info.h"
23 #include "mojo/public/cpp/bindings/interface_request.h" 23 #include "mojo/public/cpp/bindings/interface_request.h"
24 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 24 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
25 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
26 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" 25 #include "mojo/public/cpp/bindings/lib/multiplex_router.h"
27 #include "mojo/public/cpp/bindings/lib/router.h" 26 #include "mojo/public/cpp/bindings/lib/router.h"
27 #include "mojo/public/cpp/bindings/message_header_validator.h"
28 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" 28 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
29 #include "mojo/public/cpp/system/core.h" 29 #include "mojo/public/cpp/system/core.h"
30 30
31 namespace mojo { 31 namespace mojo {
32 namespace internal { 32 namespace internal {
33 33
34 template <typename Interface, bool use_multiplex_router> 34 template <typename Interface, bool use_multiplex_router>
35 class BindingState; 35 class BindingState;
36 36
37 // Uses a single-threaded, dedicated router. If |Interface| doesn't have any 37 // Uses a single-threaded, dedicated router. If |Interface| doesn't have any
38 // methods to pass associated interface pointers or requests, there won't be 38 // methods to pass associated interface pointers or requests, there won't be
39 // multiple interfaces running on the underlying message pipe. In that case, we 39 // multiple interfaces running on the underlying message pipe. In that case, we
40 // can use this specialization to reduce cost. 40 // can use this specialization to reduce cost.
41 template <typename Interface> 41 template <typename Interface>
42 class BindingState<Interface, false> { 42 class BindingState<Interface, false> {
43 public: 43 public:
44 explicit BindingState(Interface* impl) : impl_(impl) { 44 explicit BindingState(Interface* impl) : impl_(impl) {
45 stub_.set_sink(impl_); 45 stub_.set_sink(impl_);
46 } 46 }
47 47
48 ~BindingState() { Close(); } 48 ~BindingState() { Close(); }
49 49
50 void Bind(ScopedMessagePipeHandle handle, 50 void Bind(ScopedMessagePipeHandle handle,
51 scoped_refptr<base::SingleThreadTaskRunner> runner) { 51 scoped_refptr<base::SingleThreadTaskRunner> runner) {
52 DCHECK(!router_); 52 DCHECK(!router_);
53 internal::FilterChain filters; 53 internal::FilterChain filters;
54 filters.Append<internal::MessageHeaderValidator>(Interface::Name_); 54 filters.Append<MessageHeaderValidator>(Interface::Name_);
55 filters.Append<typename Interface::RequestValidator_>(); 55 filters.Append<typename Interface::RequestValidator_>();
56 56
57 router_ = 57 router_ =
58 new internal::Router(std::move(handle), std::move(filters), 58 new internal::Router(std::move(handle), std::move(filters),
59 Interface::HasSyncMethods_, std::move(runner)); 59 Interface::HasSyncMethods_, std::move(runner));
60 router_->set_incoming_receiver(&stub_); 60 router_->set_incoming_receiver(&stub_);
61 router_->set_connection_error_handler( 61 router_->set_connection_error_handler(
62 base::Bind(&BindingState::RunConnectionErrorHandler, 62 base::Bind(&BindingState::RunConnectionErrorHandler,
63 base::Unretained(this))); 63 base::Unretained(this)));
64 } 64 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 Interface* impl_; 240 Interface* impl_;
241 base::Closure connection_error_handler_; 241 base::Closure connection_error_handler_;
242 242
243 DISALLOW_COPY_AND_ASSIGN(BindingState); 243 DISALLOW_COPY_AND_ASSIGN(BindingState);
244 }; 244 };
245 245
246 } // namesapce internal 246 } // namesapce internal
247 } // namespace mojo 247 } // namespace mojo
248 248
249 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_ 249 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/connector.h ('k') | mojo/public/cpp/bindings/lib/connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698