1 // Copyright 2018 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 REMOTING_HOST_ACTION_MESSAGE_HANDLER_H_
6 #define REMOTING_HOST_ACTION_MESSAGE_HANDLER_H_
7 
8 #include <memory>
9 #include <string>
10 #include <vector>
11 
12 #include "base/containers/flat_set.h"
13 #include "base/macros.h"
14 #include "remoting/proto/action.pb.h"
15 #include "remoting/protocol/named_message_pipe_handler.h"
16 
17 namespace remoting {
18 
19 class ActionExecutor;
20 
21 constexpr char kActionDataChannelPrefix[] = "actions";
22 
23 class ActionMessageHandler : public protocol::NamedMessagePipeHandler {
24  public:
25   ActionMessageHandler(
26       const std::string& name,
27       const std::vector<protocol::ActionRequest::Action>& actions,
28       std::unique_ptr<protocol::MessagePipe> pipe,
29       std::unique_ptr<ActionExecutor> action_executor);
30   ~ActionMessageHandler() override;
31 
32   // protocol::NamedMessagePipeHandler implementation.
33   void OnIncomingMessage(std::unique_ptr<CompoundBuffer> message) override;
34 
35  private:
36   std::unique_ptr<ActionExecutor> action_executor_;
37 
38   // Populated via the negotiated capabilities between host and client.
39   base::flat_set<protocol::ActionRequest::Action> supported_actions_;
40 
41   DISALLOW_COPY_AND_ASSIGN(ActionMessageHandler);
42 };
43 
44 }  // namespace remoting
45 
46 #endif  // REMOTING_HOST_ACTION_MESSAGE_HANDLER_H_
47