• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_CONTROL_MESSAGE_PROXY_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CONTROL_MESSAGE_PROXY_H_
7 
8 #include <stdint.h>
9 
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "mojo/public/cpp/bindings/bindings_export.h"
13 #include "mojo/public/cpp/bindings/lib/serialization_context.h"
14 
15 namespace mojo {
16 
17 class MessageReceiverWithResponder;
18 
19 namespace internal {
20 
21 // Proxy for request messages defined in interface_control_messages.mojom.
22 class MOJO_CPP_BINDINGS_EXPORT ControlMessageProxy {
23  public:
24   // Doesn't take ownership of |receiver|. It must outlive this object.
25   explicit ControlMessageProxy(MessageReceiverWithResponder* receiver);
26   ~ControlMessageProxy();
27 
28   void QueryVersion(const base::Callback<void(uint32_t)>& callback);
29   void RequireVersion(uint32_t version);
30 
31   void FlushForTesting();
32   void OnConnectionError();
33 
34  private:
35   void RunFlushForTestingClosure();
36 
37   // Not owned.
38   MessageReceiverWithResponder* receiver_;
39   bool encountered_error_ = false;
40 
41   base::Closure run_loop_quit_closure_;
42 
43   DISALLOW_COPY_AND_ASSIGN(ControlMessageProxy);
44 };
45 
46 }  // namespace internal
47 }  // namespace mojo
48 
49 #endif  // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONTROL_MESSAGE_PROXY_H_
50