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

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

Issue 2646853003: Mojo C++ bindings: Simplify associated interface API. (Closed)
Patch Set: . Created 3 years, 10 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
Index: mojo/public/cpp/bindings/interface_endpoint_client.h
diff --git a/mojo/public/cpp/bindings/interface_endpoint_client.h b/mojo/public/cpp/bindings/interface_endpoint_client.h
index 5c5243ca2145f76bcc21b0e268d3a483ab44d981..0aea75678adc196caf49dec10f57e33bba48b3c2 100644
--- a/mojo/public/cpp/bindings/interface_endpoint_client.h
+++ b/mojo/public/cpp/bindings/interface_endpoint_client.h
@@ -31,7 +31,6 @@
namespace mojo {
class AssociatedGroup;
-class AssociatedGroupController;
class InterfaceEndpointController;
// InterfaceEndpointClient handles message sending and receiving of an interface
@@ -77,11 +76,7 @@ class MOJO_CPP_BINDINGS_EXPORT InterfaceEndpointClient
return !async_responders_.empty() || !sync_responses_.empty();
}
- AssociatedGroupController* group_controller() const {
- return handle_.group_controller();
- }
AssociatedGroup* associated_group();
- uint32_t interface_id() const;
// Adds a MessageReceiver which can filter a message after validation but
// before dispatch.
@@ -97,6 +92,8 @@ class MOJO_CPP_BINDINGS_EXPORT InterfaceEndpointClient
void CloseWithReason(uint32_t custom_reason, const std::string& description);
// MessageReceiverWithResponder implementation:
+ // They must only be called when the handle is not in pending association
+ // state.
bool Accept(Message* message) override;
bool AcceptWithResponder(Message* message,
MessageReceiver* responder) override;
@@ -108,9 +105,12 @@ class MOJO_CPP_BINDINGS_EXPORT InterfaceEndpointClient
bool HandleIncomingMessage(Message* message);
void NotifyError(const base::Optional<DisconnectReason>& reason);
- internal::ControlMessageProxy* control_message_proxy() {
- return &control_message_proxy_;
- }
+ // The following methods send interface control messages.
+ // They must only be called when the handle is not in pending association
+ // state.
+ void QueryVersion(const base::Callback<void(uint32_t)>& callback);
+ void RequireVersion(uint32_t version);
+ void FlushForTesting();
private:
// Maps from the id of a response to the MessageReceiver that handles the
@@ -150,24 +150,31 @@ class MOJO_CPP_BINDINGS_EXPORT InterfaceEndpointClient
DISALLOW_COPY_AND_ASSIGN(HandleIncomingMessageThunk);
};
+ void InitControllerIfNecessary();
+
+ void OnAssociationEvent(
+ ScopedInterfaceEndpointHandle::AssociationEvent event);
+
bool HandleValidatedMessage(Message* message);
+ const bool expect_sync_requests_ = false;
+
ScopedInterfaceEndpointHandle handle_;
std::unique_ptr<AssociatedGroup> associated_group_;
- InterfaceEndpointController* controller_;
+ InterfaceEndpointController* controller_ = nullptr;
- MessageReceiverWithResponderStatus* const incoming_receiver_;
+ MessageReceiverWithResponderStatus* const incoming_receiver_ = nullptr;
HandleIncomingMessageThunk thunk_;
FilterChain filters_;
AsyncResponderMap async_responders_;
SyncResponseMap sync_responses_;
- uint64_t next_request_id_;
+ uint64_t next_request_id_ = 1;
base::Closure error_handler_;
ConnectionErrorWithReasonCallback error_with_reason_handler_;
- bool encountered_error_;
+ bool encountered_error_ = false;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
« no previous file with comments | « mojo/public/cpp/bindings/associated_interface_request.h ('k') | mojo/public/cpp/bindings/interface_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698