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

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

Issue 1174073002: C++ bindings: support using a callback as connection error handler. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
OLDNEW
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_INTERNAL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
7 7
8 #include <algorithm> // For |std::swap()|. 8 #include <algorithm> // For |std::swap()|.
9 9
10 #include "mojo/public/cpp/bindings/callback.h"
10 #include "mojo/public/cpp/bindings/interface_ptr_info.h" 11 #include "mojo/public/cpp/bindings/interface_ptr_info.h"
11 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" 12 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
12 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 13 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
13 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" 14 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
14 #include "mojo/public/cpp/bindings/lib/router.h" 15 #include "mojo/public/cpp/bindings/lib/router.h"
15 #include "mojo/public/cpp/environment/logging.h" 16 #include "mojo/public/cpp/environment/logging.h"
16 17
17 struct MojoAsyncWaiter; 18 struct MojoAsyncWaiter;
18 19
19 namespace mojo { 20 namespace mojo {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return InterfacePtrInfo<Interface>( 105 return InterfacePtrInfo<Interface>(
105 router_ ? router_->PassMessagePipe() : handle_.Pass(), version_); 106 router_ ? router_->PassMessagePipe() : handle_.Pass(), version_);
106 } 107 }
107 108
108 bool is_bound() const { return handle_.is_valid() || router_; } 109 bool is_bound() const { return handle_.is_valid() || router_; }
109 110
110 bool encountered_error() const { 111 bool encountered_error() const {
111 return router_ ? router_->encountered_error() : false; 112 return router_ ? router_->encountered_error() : false;
112 } 113 }
113 114
114 void set_error_handler(ErrorHandler* error_handler) { 115 void set_connection_error_handler(const Closure& error_handler) {
115 ConfigureProxyIfNecessary(); 116 ConfigureProxyIfNecessary();
116 117
117 MOJO_DCHECK(router_); 118 MOJO_DCHECK(router_);
118 router_->set_error_handler(error_handler); 119 router_->set_connection_error_handler(error_handler);
119 } 120 }
120 121
121 Router* router_for_testing() { 122 Router* router_for_testing() {
122 ConfigureProxyIfNecessary(); 123 ConfigureProxyIfNecessary();
123 return router_; 124 return router_;
124 } 125 }
125 126
126 private: 127 private:
127 using Proxy = typename Interface::Proxy_; 128 using Proxy = typename Interface::Proxy_;
128 129
(...skipping 30 matching lines...) Expand all
159 160
160 uint32_t version_; 161 uint32_t version_;
161 162
162 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); 163 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfacePtrState);
163 }; 164 };
164 165
165 } // namespace internal 166 } // namespace internal
166 } // namespace mojo 167 } // namespace mojo
167 168
168 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_ 169 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698