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

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

Issue 2532053004: Mojo C++ bindings: remove the single-threaded Router. (Closed)
Patch Set: . Created 4 years 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/lib/router.cc ('k') | mojo/public/cpp/bindings/tests/BUILD.gn » ('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 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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
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/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "mojo/public/cpp/bindings/binding.h" 17 #include "mojo/public/cpp/bindings/binding.h"
18 #include "mojo/public/cpp/bindings/connection_error_callback.h" 18 #include "mojo/public/cpp/bindings/connection_error_callback.h"
19 #include "mojo/public/cpp/bindings/filter_chain.h" 19 #include "mojo/public/cpp/bindings/filter_chain.h"
20 #include "mojo/public/cpp/bindings/interface_ptr.h" 20 #include "mojo/public/cpp/bindings/interface_ptr.h"
21 #include "mojo/public/cpp/bindings/interface_request.h" 21 #include "mojo/public/cpp/bindings/interface_request.h"
22 #include "mojo/public/cpp/bindings/lib/router.h"
23 #include "mojo/public/cpp/bindings/message_header_validator.h" 22 #include "mojo/public/cpp/bindings/message_header_validator.h"
24 #include "mojo/public/cpp/system/core.h" 23 #include "mojo/public/cpp/system/core.h"
25 24
26 namespace mojo { 25 namespace mojo {
27 26
28 template <typename Interface> 27 template <typename Interface>
29 class StrongBinding; 28 class StrongBinding;
30 29
31 template <typename Interface> 30 template <typename Interface>
32 using StrongBindingPtr = base::WeakPtr<StrongBinding<Interface>>; 31 using StrongBindingPtr = base::WeakPtr<StrongBinding<Interface>>;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 DCHECK(binding_.is_bound()); 68 DCHECK(binding_.is_bound());
70 connection_error_with_reason_handler_ = error_handler; 69 connection_error_with_reason_handler_ = error_handler;
71 connection_error_handler_.Reset(); 70 connection_error_handler_.Reset();
72 } 71 }
73 72
74 // Forces the binding to close. This destroys the StrongBinding instance. 73 // Forces the binding to close. This destroys the StrongBinding instance.
75 void Close() { delete this; } 74 void Close() { delete this; }
76 75
77 Interface* impl() { return impl_.get(); } 76 Interface* impl() { return impl_.get(); }
78 77
79 // Exposed for testing, should not generally be used.
80 internal::Router* internal_router() { return binding_.internal_router(); }
81
82 // Sends a message on the underlying message pipe and runs the current 78 // Sends a message on the underlying message pipe and runs the current
83 // message loop until its response is received. This can be used in tests to 79 // message loop until its response is received. This can be used in tests to
84 // verify that no message was sent on a message pipe in response to some 80 // verify that no message was sent on a message pipe in response to some
85 // stimulus. 81 // stimulus.
86 void FlushForTesting() { binding_.FlushForTesting(); } 82 void FlushForTesting() { binding_.FlushForTesting(); }
87 83
88 private: 84 private:
89 StrongBinding(std::unique_ptr<Interface> impl, 85 StrongBinding(std::unique_ptr<Interface> impl,
90 InterfaceRequest<Interface> request) 86 InterfaceRequest<Interface> request)
91 : impl_(std::move(impl)), 87 : impl_(std::move(impl)),
(...skipping 26 matching lines...) Expand all
118 template <typename Interface, typename Impl> 114 template <typename Interface, typename Impl>
119 StrongBindingPtr<Interface> MakeStrongBinding( 115 StrongBindingPtr<Interface> MakeStrongBinding(
120 std::unique_ptr<Impl> impl, 116 std::unique_ptr<Impl> impl,
121 InterfaceRequest<Interface> request) { 117 InterfaceRequest<Interface> request) {
122 return StrongBinding<Interface>::Create(std::move(impl), std::move(request)); 118 return StrongBinding<Interface>::Create(std::move(impl), std::move(request));
123 } 119 }
124 120
125 } // namespace mojo 121 } // namespace mojo
126 122
127 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ 123 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/router.cc ('k') | mojo/public/cpp/bindings/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698