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

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

Issue 2318793002: Mojo C++ bindings: support disconnect with a reason. (Closed)
Patch Set: . Created 4 years, 3 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
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_INTERFACE_ENDPOINT_CLIENT_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
20 #include "mojo/public/cpp/bindings/connection_error_callback.h"
20 #include "mojo/public/cpp/bindings/filter_chain.h" 21 #include "mojo/public/cpp/bindings/filter_chain.h"
21 #include "mojo/public/cpp/bindings/lib/control_message_handler.h" 22 #include "mojo/public/cpp/bindings/lib/control_message_handler.h"
22 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" 23 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
23 #include "mojo/public/cpp/bindings/message.h" 24 #include "mojo/public/cpp/bindings/message.h"
24 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" 25 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
25 26
26 namespace mojo { 27 namespace mojo {
27 28
28 class AssociatedGroup; 29 class AssociatedGroup;
29 class AssociatedGroupController; 30 class AssociatedGroupController;
(...skipping 12 matching lines...) Expand all
42 bool expect_sync_requests, 43 bool expect_sync_requests,
43 scoped_refptr<base::SingleThreadTaskRunner> runner, 44 scoped_refptr<base::SingleThreadTaskRunner> runner,
44 uint32_t interface_version); 45 uint32_t interface_version);
45 ~InterfaceEndpointClient() override; 46 ~InterfaceEndpointClient() override;
46 47
47 // Sets the error handler to receive notifications when an error is 48 // Sets the error handler to receive notifications when an error is
48 // encountered. 49 // encountered.
49 void set_connection_error_handler(const base::Closure& error_handler) { 50 void set_connection_error_handler(const base::Closure& error_handler) {
50 DCHECK(thread_checker_.CalledOnValidThread()); 51 DCHECK(thread_checker_.CalledOnValidThread());
51 error_handler_ = error_handler; 52 error_handler_ = error_handler;
53 error_with_reason_handler_.Reset();
54 }
55
56 void set_connection_error_with_reason_handler(
57 const ConnectionErrorWithReasonCallback& error_handler) {
58 DCHECK(thread_checker_.CalledOnValidThread());
59 error_with_reason_handler_ = error_handler;
60 error_handler_.Reset();
52 } 61 }
53 62
54 // Returns true if an error was encountered. 63 // Returns true if an error was encountered.
55 bool encountered_error() const { 64 bool encountered_error() const {
56 DCHECK(thread_checker_.CalledOnValidThread()); 65 DCHECK(thread_checker_.CalledOnValidThread());
57 return encountered_error_; 66 return encountered_error_;
58 } 67 }
59 68
60 // Returns true if this endpoint has any pending callbacks. 69 // Returns true if this endpoint has any pending callbacks.
61 bool has_pending_responders() const { 70 bool has_pending_responders() const {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 MessageReceiverWithResponderStatus* const incoming_receiver_; 152 MessageReceiverWithResponderStatus* const incoming_receiver_;
144 HandleIncomingMessageThunk thunk_; 153 HandleIncomingMessageThunk thunk_;
145 FilterChain filters_; 154 FilterChain filters_;
146 155
147 AsyncResponderMap async_responders_; 156 AsyncResponderMap async_responders_;
148 SyncResponseMap sync_responses_; 157 SyncResponseMap sync_responses_;
149 158
150 uint64_t next_request_id_; 159 uint64_t next_request_id_;
151 160
152 base::Closure error_handler_; 161 base::Closure error_handler_;
162 ConnectionErrorWithReasonCallback error_with_reason_handler_;
153 bool encountered_error_; 163 bool encountered_error_;
154 164
155 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 165 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
156 166
157 internal::ControlMessageProxy control_message_proxy_; 167 internal::ControlMessageProxy control_message_proxy_;
158 internal::ControlMessageHandler control_message_handler_; 168 internal::ControlMessageHandler control_message_handler_;
159 169
160 base::ThreadChecker thread_checker_; 170 base::ThreadChecker thread_checker_;
161 171
162 base::WeakPtrFactory<InterfaceEndpointClient> weak_ptr_factory_; 172 base::WeakPtrFactory<InterfaceEndpointClient> weak_ptr_factory_;
163 173
164 DISALLOW_COPY_AND_ASSIGN(InterfaceEndpointClient); 174 DISALLOW_COPY_AND_ASSIGN(InterfaceEndpointClient);
165 }; 175 };
166 176
167 } // namespace mojo 177 } // namespace mojo
168 178
169 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_ 179 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_ENDPOINT_CLIENT_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/connection_error_callback.h ('k') | mojo/public/cpp/bindings/interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698