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

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

Issue 2332353004: Mojo C++ bindings: support closing [Associated]InterfaceRequest with reason. (Closed)
Patch Set: Created 4 years, 3 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 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_CONTROL_MESSAGE_PROXY_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_CONTROL_MESSAGE_PROXY_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CONTROL_MESSAGE_PROXY_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CONTROL_MESSAGE_PROXY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "mojo/public/cpp/bindings/lib/serialization_context.h" 14 #include "mojo/public/cpp/bindings/lib/serialization_context.h"
15 #include "mojo/public/cpp/bindings/message.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 18
18 class MessageReceiverWithResponder;
19
20 namespace internal { 19 namespace internal {
21 20
22 // Proxy for request messages defined in interface_control_messages.mojom. 21 // Proxy for request messages defined in interface_control_messages.mojom.
23 class ControlMessageProxy { 22 class ControlMessageProxy {
24 public: 23 public:
25 // Doesn't take ownership of |receiver|. It must outlive this object. 24 // Doesn't take ownership of |receiver|. It must outlive this object.
26 explicit ControlMessageProxy(MessageReceiverWithResponder* receiver); 25 explicit ControlMessageProxy(MessageReceiverWithResponder* receiver);
27 ~ControlMessageProxy(); 26 ~ControlMessageProxy();
28 27
29 void QueryVersion(const base::Callback<void(uint32_t)>& callback); 28 void QueryVersion(const base::Callback<void(uint32_t)>& callback);
30 void RequireVersion(uint32_t version); 29 void RequireVersion(uint32_t version);
31 30
32 void FlushForTesting(); 31 void FlushForTesting();
33 void SendDisconnectReason(uint32_t custom_reason, 32 void SendDisconnectReason(uint32_t custom_reason,
34 const std::string& description); 33 const std::string& description);
35 34
36 void OnConnectionError(); 35 void OnConnectionError();
37 36
37 static Message ConstructDisconnectReasonMessage(
38 uint32_t custom_reason,
39 const std::string& description);
40
38 private: 41 private:
39 void RunFlushForTestingClosure(); 42 void RunFlushForTestingClosure();
40 43
41 // Not owned. 44 // Not owned.
42 MessageReceiverWithResponder* receiver_; 45 MessageReceiverWithResponder* receiver_;
43 SerializationContext context_;
44 bool encountered_error_ = false; 46 bool encountered_error_ = false;
45 47
46 base::Closure run_loop_quit_closure_; 48 base::Closure run_loop_quit_closure_;
47 49
48 DISALLOW_COPY_AND_ASSIGN(ControlMessageProxy); 50 DISALLOW_COPY_AND_ASSIGN(ControlMessageProxy);
49 }; 51 };
50 52
51 } // namespace internal 53 } // namespace internal
52 } // namespace mojo 54 } // namespace mojo
53 55
54 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONTROL_MESSAGE_PROXY_H_ 56 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONTROL_MESSAGE_PROXY_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/interface_request.h ('k') | mojo/public/cpp/bindings/lib/control_message_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698