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

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

Issue 2506383002: Mojo: adding a thread safe associated interface ptr. (Closed)
Patch Set: Addressed comment + sync Created 4 years, 1 month 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/lib/interface_ptr_state.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_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> // For |std::swap()|. 10 #include <algorithm> // For |std::swap()|.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 // Returns true if bound and awaiting a response to a message. 136 // Returns true if bound and awaiting a response to a message.
137 bool has_pending_callbacks() const { 137 bool has_pending_callbacks() const {
138 return endpoint_client_ && endpoint_client_->has_pending_responders(); 138 return endpoint_client_ && endpoint_client_->has_pending_responders();
139 } 139 }
140 140
141 AssociatedGroup* associated_group() { 141 AssociatedGroup* associated_group() {
142 return endpoint_client_ ? endpoint_client_->associated_group() : nullptr; 142 return endpoint_client_ ? endpoint_client_->associated_group() : nullptr;
143 } 143 }
144 144
145 void ForwardMessage(Message message) { endpoint_client_->Accept(&message); }
146
147 void ForwardMessageWithResponder(Message message,
148 std::unique_ptr<MessageReceiver> responder) {
149 endpoint_client_->AcceptWithResponder(&message, responder.release());
150 }
151
145 private: 152 private:
146 using Proxy = typename Interface::Proxy_; 153 using Proxy = typename Interface::Proxy_;
147 154
148 void OnQueryVersion(const base::Callback<void(uint32_t)>& callback, 155 void OnQueryVersion(const base::Callback<void(uint32_t)>& callback,
149 uint32_t version) { 156 uint32_t version) {
150 version_ = version; 157 version_ = version;
151 callback.Run(version); 158 callback.Run(version);
152 } 159 }
153 160
154 std::unique_ptr<InterfaceEndpointClient> endpoint_client_; 161 std::unique_ptr<InterfaceEndpointClient> endpoint_client_;
155 std::unique_ptr<Proxy> proxy_; 162 std::unique_ptr<Proxy> proxy_;
156 163
157 uint32_t version_; 164 uint32_t version_;
158 165
159 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfacePtrState); 166 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfacePtrState);
160 }; 167 };
161 168
162 } // namespace internal 169 } // namespace internal
163 } // namespace mojo 170 } // namespace mojo
164 171
165 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ 172 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/BUILD.gn ('k') | mojo/public/cpp/bindings/lib/interface_ptr_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698