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

Side by Side Diff: mojo/public/cpp/bindings/strong_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
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_STRONG_BINDING_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h"
12 #include "base/logging.h" 11 #include "base/logging.h"
13 #include "base/macros.h" 12 #include "base/macros.h"
14 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
14 #include "mojo/public/cpp/bindings/callback.h"
15 #include "mojo/public/cpp/bindings/interface_ptr.h" 15 #include "mojo/public/cpp/bindings/interface_ptr.h"
16 #include "mojo/public/cpp/bindings/interface_request.h" 16 #include "mojo/public/cpp/bindings/interface_request.h"
17 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 17 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
18 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" 18 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
19 #include "mojo/public/cpp/bindings/lib/router.h" 19 #include "mojo/public/cpp/bindings/lib/router.h"
20 #include "mojo/public/cpp/system/core.h" 20 #include "mojo/public/cpp/system/core.h"
21 21
22 namespace mojo { 22 namespace mojo {
23 23
24 // This connects an interface implementation strongly to a pipe. When a 24 // This connects an interface implementation strongly to a pipe. When a
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 93
94 bool WaitForIncomingMethodCall() { 94 bool WaitForIncomingMethodCall() {
95 return binding_.WaitForIncomingMethodCall(); 95 return binding_.WaitForIncomingMethodCall();
96 } 96 }
97 97
98 // Note: The error handler must not delete the interface implementation. 98 // Note: The error handler must not delete the interface implementation.
99 // 99 //
100 // This method may only be called after this StrongBinding has been bound to a 100 // This method may only be called after this StrongBinding has been bound to a
101 // message pipe. 101 // message pipe.
102 void set_connection_error_handler(const base::Closure& error_handler) { 102 void set_connection_error_handler(const Closure& error_handler) {
103 DCHECK(binding_.is_bound()); 103 DCHECK(binding_.is_bound());
104 connection_error_handler_ = error_handler; 104 connection_error_handler_ = error_handler;
105 } 105 }
106 106
107 Interface* impl() { return binding_.impl(); } 107 Interface* impl() { return binding_.impl(); }
108 // Exposed for testing, should not generally be used. 108 // Exposed for testing, should not generally be used.
109 internal::Router* internal_router() { return binding_.internal_router(); } 109 internal::Router* internal_router() { return binding_.internal_router(); }
110 110
111 void OnConnectionError() { 111 void OnConnectionError() {
112 if (!connection_error_handler_.is_null()) 112 if (!connection_error_handler_.is_null())
113 connection_error_handler_.Run(); 113 connection_error_handler_.Run();
114 delete binding_.impl(); 114 delete binding_.impl();
115 } 115 }
116 116
117 private: 117 private:
118 base::Closure connection_error_handler_; 118 Closure connection_error_handler_;
119 Binding<Interface> binding_; 119 Binding<Interface> binding_;
120 120
121 DISALLOW_COPY_AND_ASSIGN(StrongBinding); 121 DISALLOW_COPY_AND_ASSIGN(StrongBinding);
122 }; 122 };
123 123
124 } // namespace mojo 124 } // namespace mojo
125 125
126 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ 126 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_errors.cc ('k') | mojo/public/cpp/bindings/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698