• 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_HANDLER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CONTROL_MESSAGE_HANDLER_H_
7 
8 #include <stdint.h>
9 
10 #include "base/compiler_specific.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 #include "mojo/public/cpp/bindings/message.h"
15 
16 namespace mojo {
17 namespace internal {
18 
19 // Handlers for request messages defined in interface_control_messages.mojom.
20 class MOJO_CPP_BINDINGS_EXPORT ControlMessageHandler
21     : public MessageReceiverWithResponderStatus {
22  public:
23   static bool IsControlMessage(const Message* message);
24 
25   explicit ControlMessageHandler(uint32_t interface_version);
26   ~ControlMessageHandler() override;
27 
28   // Call the following methods only if IsControlMessage() returned true.
29   bool Accept(Message* message) override;
30   bool AcceptWithResponder(
31       Message* message,
32       std::unique_ptr<MessageReceiverWithStatus> responder) override;
33 
34  private:
35   bool Run(Message* message,
36            std::unique_ptr<MessageReceiverWithStatus> responder);
37   bool RunOrClosePipe(Message* message);
38 
39   uint32_t interface_version_;
40   SerializationContext context_;
41 
42   DISALLOW_COPY_AND_ASSIGN(ControlMessageHandler);
43 };
44 
45 }  // namespace internal
46 }  // namespace mojo
47 
48 #endif  // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONTROL_MESSAGE_HANDLER_H_
49