basic_desktop_environment.h revision b2df76ea8fec9e32f6f3718986dba0d95315b29c
1// Copyright (c) 2012 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_BASIC_DESKTOP_ENVIRONMENT_H_
6#define REMOTING_HOST_BASIC_DESKTOP_ENVIRONMENT_H_
7
8#include <string>
9
10#include "base/basictypes.h"
11#include "base/compiler_specific.h"
12#include "base/memory/ref_counted.h"
13#include "base/memory/scoped_ptr.h"
14#include "remoting/host/desktop_environment.h"
15#include "remoting/host/ui_strings.h"
16
17namespace remoting {
18
19// Used to create audio/video capturers and event executor that work with
20// the local console.
21class BasicDesktopEnvironment : public DesktopEnvironment {
22 public:
23  virtual ~BasicDesktopEnvironment();
24
25  // DesktopEnvironment implementation.
26  virtual scoped_ptr<AudioCapturer> CreateAudioCapturer() OVERRIDE;
27  virtual scoped_ptr<InputInjector> CreateInputInjector() OVERRIDE;
28  virtual scoped_ptr<ScreenControls> CreateScreenControls() OVERRIDE;
29  virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer() OVERRIDE;
30  virtual std::string GetCapabilities() const OVERRIDE;
31  virtual void SetCapabilities(const std::string& capabilities) OVERRIDE;
32
33 protected:
34  friend class BasicDesktopEnvironmentFactory;
35
36  // |ui_strings| are hosted by the BasicDesktopEnvironmentFactory instance that
37  // created |this|. |ui_strings| must outlive this object.
38  BasicDesktopEnvironment(
39      scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
40      scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
41      scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
42
43  scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const {
44    return caller_task_runner_;
45  }
46
47  scoped_refptr<base::SingleThreadTaskRunner> input_task_runner() const {
48    return input_task_runner_;
49  }
50
51  scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() const {
52    return ui_task_runner_;
53  }
54
55 private:
56  // Task runner on which methods of DesktopEnvironment interface should be
57  // called.
58  scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
59
60  // Used to run input-related tasks.
61  scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_;
62
63  // Used to run UI code.
64  scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
65
66  DISALLOW_COPY_AND_ASSIGN(BasicDesktopEnvironment);
67};
68
69// Used to create |BasicDesktopEnvironment| instances.
70class BasicDesktopEnvironmentFactory : public DesktopEnvironmentFactory {
71 public:
72  BasicDesktopEnvironmentFactory(
73      scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
74      scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
75      scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
76      const UiStrings& ui_strings);
77  virtual ~BasicDesktopEnvironmentFactory();
78
79  // DesktopEnvironmentFactory implementation.
80  virtual bool SupportsAudioCapture() const OVERRIDE;
81
82 protected:
83  scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const {
84    return caller_task_runner_;
85  }
86
87  scoped_refptr<base::SingleThreadTaskRunner> input_task_runner() const {
88    return input_task_runner_;
89  }
90
91  scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() const {
92    return ui_task_runner_;
93  }
94
95  const UiStrings& ui_strings() const { return ui_strings_; }
96
97 private:
98  // Task runner on which methods of DesktopEnvironmentFactory interface should
99  // be called.
100  scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
101
102  // Used to run input-related tasks.
103  scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_;
104
105  // Used to run UI code.
106  scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
107
108  // Contains a copy of the localized UI strings.
109  const UiStrings ui_strings_;
110
111  DISALLOW_COPY_AND_ASSIGN(BasicDesktopEnvironmentFactory);
112};
113
114}  // namespace remoting
115
116#endif  // REMOTING_HOST_BASIC_DESKTOP_ENVIRONMENT_H_
117