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

Side by Side Diff: mojo/public/cpp/bindings/associated_binding.h

Issue 2100683002: Mojo C++ Bindings: Extract AssociatedGroupController from MultiplexRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops more gyp ugh 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/BUILD.gn ('k') | mojo/public/cpp/bindings/associated_group.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_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 <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/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.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/associated_group_controller.h"
19 #include "mojo/public/cpp/bindings/associated_interface_request.h" 20 #include "mojo/public/cpp/bindings/associated_interface_request.h"
20 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h" 21 #include "mojo/public/cpp/bindings/interface_endpoint_client.h"
21 #include "mojo/public/cpp/bindings/lib/multiplex_router.h"
22 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" 22 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
23 23
24 namespace mojo { 24 namespace mojo {
25 25
26 // Represents the implementation side of an associated interface. It is similar 26 // Represents the implementation side of an associated interface. It is similar
27 // to Binding, except that it doesn't own a message pipe handle. 27 // to Binding, except that it doesn't own a message pipe handle.
28 // 28 //
29 // When you bind this class to a request, optionally you can specify a 29 // When you bind this class to a request, optionally you can specify a
30 // base::SingleThreadTaskRunner. This task runner must belong to the same 30 // base::SingleThreadTaskRunner. This task runner must belong to the same
31 // thread. It will be used to dispatch incoming method calls and connection 31 // thread. It will be used to dispatch incoming method calls and connection
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 DCHECK(handle.is_local()) 92 DCHECK(handle.is_local())
93 << "The AssociatedInterfaceRequest is supposed to be used at the " 93 << "The AssociatedInterfaceRequest is supposed to be used at the "
94 << "other side of the message pipe."; 94 << "other side of the message pipe.";
95 95
96 if (!handle.is_valid() || !handle.is_local()) { 96 if (!handle.is_valid() || !handle.is_local()) {
97 endpoint_client_.reset(); 97 endpoint_client_.reset();
98 return; 98 return;
99 } 99 }
100 100
101 endpoint_client_.reset(new internal::InterfaceEndpointClient( 101 endpoint_client_.reset(new InterfaceEndpointClient(
102 std::move(handle), &stub_, 102 std::move(handle), &stub_,
103 base::WrapUnique(new typename Interface::RequestValidator_()), 103 base::WrapUnique(new typename Interface::RequestValidator_()),
104 Interface::HasSyncMethods_, std::move(runner))); 104 Interface::HasSyncMethods_, std::move(runner)));
105 endpoint_client_->set_connection_error_handler( 105 endpoint_client_->set_connection_error_handler(
106 base::Bind(&AssociatedBinding::RunConnectionErrorHandler, 106 base::Bind(&AssociatedBinding::RunConnectionErrorHandler,
107 base::Unretained(this))); 107 base::Unretained(this)));
108 108
109 stub_.serialization_context()->router = endpoint_client_->router(); 109 stub_.serialization_context()->group_controller =
110 endpoint_client_->group_controller();
110 } 111 }
111 112
112 // Closes the associated interface. Puts this object into a state where it can 113 // Closes the associated interface. Puts this object into a state where it can
113 // be rebound. 114 // be rebound.
114 void Close() { 115 void Close() {
115 DCHECK(endpoint_client_); 116 DCHECK(endpoint_client_);
116 endpoint_client_.reset(); 117 endpoint_client_.reset();
117 connection_error_handler_.Reset(); 118 connection_error_handler_.Reset();
118 } 119 }
119 120
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 AssociatedGroup* associated_group() { 154 AssociatedGroup* associated_group() {
154 return endpoint_client_ ? endpoint_client_->associated_group() : nullptr; 155 return endpoint_client_ ? endpoint_client_->associated_group() : nullptr;
155 } 156 }
156 157
157 private: 158 private:
158 void RunConnectionErrorHandler() { 159 void RunConnectionErrorHandler() {
159 if (!connection_error_handler_.is_null()) 160 if (!connection_error_handler_.is_null())
160 connection_error_handler_.Run(); 161 connection_error_handler_.Run();
161 } 162 }
162 163
163 std::unique_ptr<internal::InterfaceEndpointClient> endpoint_client_; 164 std::unique_ptr<InterfaceEndpointClient> endpoint_client_;
164 165
165 typename Interface::Stub_ stub_; 166 typename Interface::Stub_ stub_;
166 Interface* impl_; 167 Interface* impl_;
167 base::Closure connection_error_handler_; 168 base::Closure connection_error_handler_;
168 169
169 DISALLOW_COPY_AND_ASSIGN(AssociatedBinding); 170 DISALLOW_COPY_AND_ASSIGN(AssociatedBinding);
170 }; 171 };
171 172
172 } // namespace mojo 173 } // namespace mojo
173 174
174 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ 175 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/BUILD.gn ('k') | mojo/public/cpp/bindings/associated_group.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698