desktop_process.h 3.3 KB
Newer Older
1 2 3 4 5 6 7
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_HOST_DESKTOP_PROCESS_H_
#define REMOTING_HOST_DESKTOP_PROCESS_H_

8 9
#include <stdint.h>

10
#include <memory>
11 12
#include <string>

13
#include "base/callback_forward.h"
14
#include "base/compiler_specific.h"
15
#include "base/macros.h"
16
#include "base/memory/ref_counted.h"
17
#include "base/memory/weak_ptr.h"
18
#include "ipc/ipc_listener.h"
19
#include "mojo/public/cpp/system/message_pipe.h"
20
#include "remoting/host/desktop_session_agent.h"
21 22 23 24

namespace IPC {
class ChannelProxy;
}  // namespace IPC
25 26 27

namespace remoting {

28
class AutoThreadTaskRunner;
29
class DesktopEnvironmentFactory;
30 31
class DesktopSessionAgent;

32 33 34
class DesktopProcess : public DesktopSessionAgent::Delegate,
                       public IPC::Listener,
                       public base::SupportsWeakPtr<DesktopProcess> {
35
 public:
36 37 38 39
  DesktopProcess(scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
                 scoped_refptr<AutoThreadTaskRunner> input_task_runner,
                 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
                 mojo::ScopedMessagePipeHandle daemon_channel_handle);
40
  ~DesktopProcess() override;
41

42
  // DesktopSessionAgent::Delegate implementation.
43 44
  DesktopEnvironmentFactory& desktop_environment_factory() override;
  void OnNetworkProcessDisconnected() override;
45

46
  // IPC::Listener implementation.
47
  bool OnMessageReceived(const IPC::Message& message) override;
48
  void OnChannelConnected(int32_t peer_pid) override;
49
  void OnChannelError() override;
50

51 52 53
  // Injects Secure Attention Sequence.
  void InjectSas();

54 55 56
  // Locks the workstation for the current session.
  void LockWorkStation();

57 58
  // Creates the desktop agent and required threads and IPC channels. Returns
  // true on success.
59 60
  bool Start(
      std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory);
61 62

 private:
63 64
  // Crashes the process in response to a daemon's request. The daemon passes
  // the location of the code that detected the fatal error resulted in this
65
  // request. See the declaration of ChromotingDaemonMsg_Crash message.
66 67 68
  void OnCrash(const std::string& function_name,
               const std::string& file_name,
               const int& line_number);
69

70 71 72
  // Task runner on which public methods of this class should be called.
  scoped_refptr<AutoThreadTaskRunner> caller_task_runner_;

73 74 75
  // Used to run input-related tasks.
  scoped_refptr<AutoThreadTaskRunner> input_task_runner_;

76 77 78
  // Used for IPC communication with Daemon process.
  scoped_refptr<AutoThreadTaskRunner> io_task_runner_;

79
  // Factory used to create integration components for use by |desktop_agent_|.
80
  std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory_;
81

82
  // Handle for the IPC channel connecting the desktop process with the daemon
83
  // process.
84
  mojo::ScopedMessagePipeHandle daemon_channel_handle_;
85

86
  // IPC channel connecting the desktop process with the daemon process.
87
  std::unique_ptr<IPC::ChannelProxy> daemon_channel_;
88 89 90

  // Provides screen/audio capturing and input injection services for
  // the network process.
91
  scoped_refptr<DesktopSessionAgent> desktop_agent_;
92

93 94 95 96 97 98
  DISALLOW_COPY_AND_ASSIGN(DesktopProcess);
};

}  // namespace remoting

#endif  // REMOTING_HOST_DESKTOP_PROCESS_H_