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

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

Issue 2080083002: Revert of Deletes mojo::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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_interface_ptr.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"
13 #include "base/macros.h" 12 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
15 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
16 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
18 #include "mojo/public/cpp/bindings/associated_group.h" 17 #include "mojo/public/cpp/bindings/associated_group.h"
19 #include "mojo/public/cpp/bindings/associated_interface_request.h" 18 #include "mojo/public/cpp/bindings/associated_interface_request.h"
19 #include "mojo/public/cpp/bindings/callback.h"
20 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h" 20 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h"
21 #include "mojo/public/cpp/bindings/lib/multiplex_router.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
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 connection_error_handler_.Reset(); 130 connection_error_handler_.Reset();
131 131
132 return request; 132 return request;
133 } 133 }
134 134
135 // Sets an error handler that will be called if a connection error occurs. 135 // Sets an error handler that will be called if a connection error occurs.
136 // 136 //
137 // This method may only be called after this AssociatedBinding has been bound 137 // This method may only be called after this AssociatedBinding has been bound
138 // to a message pipe. The error handler will be reset when this 138 // to a message pipe. The error handler will be reset when this
139 // AssociatedBinding is unbound or closed. 139 // AssociatedBinding is unbound or closed.
140 void set_connection_error_handler(const base::Closure& error_handler) { 140 void set_connection_error_handler(const Closure& error_handler) {
141 DCHECK(is_bound()); 141 DCHECK(is_bound());
142 connection_error_handler_ = error_handler; 142 connection_error_handler_ = error_handler;
143 } 143 }
144 144
145 // Returns the interface implementation that was previously specified. 145 // Returns the interface implementation that was previously specified.
146 Interface* impl() { return impl_; } 146 Interface* impl() { return impl_; }
147 147
148 // Indicates whether the associated binding has been completed. 148 // Indicates whether the associated binding has been completed.
149 bool is_bound() const { return !!endpoint_client_; } 149 bool is_bound() const { return !!endpoint_client_; }
150 150
151 // Returns the associated group that this object belongs to. Returns null if 151 // Returns the associated group that this object belongs to. Returns null if
152 // the object is not bound. 152 // the object is not bound.
153 AssociatedGroup* associated_group() { 153 AssociatedGroup* associated_group() {
154 return endpoint_client_ ? endpoint_client_->associated_group() : nullptr; 154 return endpoint_client_ ? endpoint_client_->associated_group() : nullptr;
155 } 155 }
156 156
157 private: 157 private:
158 void RunConnectionErrorHandler() { 158 void RunConnectionErrorHandler() {
159 if (!connection_error_handler_.is_null()) 159 if (!connection_error_handler_.is_null())
160 connection_error_handler_.Run(); 160 connection_error_handler_.Run();
161 } 161 }
162 162
163 std::unique_ptr<internal::InterfaceEndpointClient> endpoint_client_; 163 std::unique_ptr<internal::InterfaceEndpointClient> endpoint_client_;
164 164
165 typename Interface::Stub_ stub_; 165 typename Interface::Stub_ stub_;
166 Interface* impl_; 166 Interface* impl_;
167 base::Closure connection_error_handler_; 167 Closure connection_error_handler_;
168 168
169 DISALLOW_COPY_AND_ASSIGN(AssociatedBinding); 169 DISALLOW_COPY_AND_ASSIGN(AssociatedBinding);
170 }; 170 };
171 171
172 } // namespace mojo 172 } // namespace mojo
173 173
174 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_ 174 #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_interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698