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

Unified Diff: mojo/public/cpp/bindings/lib/interface_endpoint_client.h

Issue 1823683006: Mojo C++ bindings: sync call support for associated interfaces and master interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/lib/connector.h ('k') | mojo/public/cpp/bindings/lib/interface_endpoint_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/interface_endpoint_client.h
diff --git a/mojo/public/cpp/bindings/lib/interface_endpoint_client.h b/mojo/public/cpp/bindings/lib/interface_endpoint_client.h
index 548ca381f0e57b61930a21cccf2f4e96b003eaba..2560cfc42dc710367c74d114443b578fe3f29945 100644
--- a/mojo/public/cpp/bindings/lib/interface_endpoint_client.h
+++ b/mojo/public/cpp/bindings/lib/interface_endpoint_client.h
@@ -26,6 +26,7 @@ class AssociatedGroup;
namespace internal {
class MultiplexRouter;
+class InterfaceEndpointController;
// InterfaceEndpointClient handles message sending and receiving of an interface
// endpoint, either the implementation side or the client side.
@@ -36,7 +37,8 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
// object.
InterfaceEndpointClient(ScopedInterfaceEndpointHandle handle,
MessageReceiverWithResponderStatus* receiver,
- scoped_ptr<MessageFilter> payload_validator);
+ scoped_ptr<MessageFilter> payload_validator,
+ bool expect_sync_requests);
~InterfaceEndpointClient() override;
// Sets the error handler to receive notifications when an error is
@@ -55,7 +57,7 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
// Returns true if this endpoint has any pending callbacks.
bool has_pending_responders() const {
DCHECK(thread_checker_.CalledOnValidThread());
- return !responders_.empty();
+ return !async_responders_.empty() || !sync_responses_.empty();
}
MultiplexRouter* router() const { return handle_.router(); }
@@ -82,7 +84,25 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
void NotifyError();
private:
- using ResponderMap = std::map<uint64_t, MessageReceiver*>;
+ // Maps from the id of a response to the MessageReceiver that handles the
+ // response.
+ using AsyncResponderMap = std::map<uint64_t, scoped_ptr<MessageReceiver>>;
+
+ struct SyncResponseInfo {
+ public:
+ explicit SyncResponseInfo(bool* in_response_received);
+ ~SyncResponseInfo();
+
+ scoped_ptr<Message> response;
+
+ // Points to a stack-allocated variable.
+ bool* response_received;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SyncResponseInfo);
+ };
+
+ using SyncResponseMap = std::map<uint64_t, scoped_ptr<SyncResponseInfo>>;
// Used as the sink for |payload_validator_| and forwards messages to
// HandleValidatedMessage().
@@ -104,14 +124,15 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
ScopedInterfaceEndpointHandle handle_;
scoped_ptr<AssociatedGroup> associated_group_;
+ InterfaceEndpointController* controller_;
MessageReceiverWithResponderStatus* const incoming_receiver_;
scoped_ptr<MessageFilter> payload_validator_;
HandleIncomingMessageThunk thunk_;
- // Maps from the ID of a response to the MessageReceiver that handles the
- // response.
- ResponderMap responders_;
+ AsyncResponderMap async_responders_;
+ SyncResponseMap sync_responses_;
+
uint64_t next_request_id_;
Closure error_handler_;
« no previous file with comments | « mojo/public/cpp/bindings/lib/connector.h ('k') | mojo/public/cpp/bindings/lib/interface_endpoint_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698