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 16 namespace remoting { 17 18 // Used to create audio/video capturers and event executor that work with 19 // the local console. 20 class BasicDesktopEnvironment : public DesktopEnvironment { 21 public: 22 virtual ~BasicDesktopEnvironment(); 23 24 // DesktopEnvironment implementation. 25 virtual scoped_ptr<AudioCapturer> CreateAudioCapturer() OVERRIDE; 26 virtual scoped_ptr<InputInjector> CreateInputInjector() OVERRIDE; 27 virtual scoped_ptr<ScreenControls> CreateScreenControls() OVERRIDE; 28 virtual scoped_ptr<webrtc::ScreenCapturer> CreateVideoCapturer() OVERRIDE; 29 virtual std::string GetCapabilities() const OVERRIDE; 30 virtual void SetCapabilities(const std::string& capabilities) OVERRIDE; 31 32 protected: 33 friend class BasicDesktopEnvironmentFactory; 34 35 BasicDesktopEnvironment( 36 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 37 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, 38 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); 39 caller_task_runner()40 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const { 41 return caller_task_runner_; 42 } 43 input_task_runner()44 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner() const { 45 return input_task_runner_; 46 } 47 ui_task_runner()48 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() const { 49 return ui_task_runner_; 50 } 51 52 private: 53 // Task runner on which methods of DesktopEnvironment interface should be 54 // called. 55 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; 56 57 // Used to run input-related tasks. 58 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; 59 60 // Used to run UI code. 61 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 62 63 DISALLOW_COPY_AND_ASSIGN(BasicDesktopEnvironment); 64 }; 65 66 // Used to create |BasicDesktopEnvironment| instances. 67 class BasicDesktopEnvironmentFactory : public DesktopEnvironmentFactory { 68 public: 69 BasicDesktopEnvironmentFactory( 70 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 71 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, 72 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); 73 virtual ~BasicDesktopEnvironmentFactory(); 74 75 // DesktopEnvironmentFactory implementation. 76 virtual bool SupportsAudioCapture() const OVERRIDE; 77 78 protected: caller_task_runner()79 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const { 80 return caller_task_runner_; 81 } 82 input_task_runner()83 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner() const { 84 return input_task_runner_; 85 } 86 ui_task_runner()87 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() const { 88 return ui_task_runner_; 89 } 90 91 private: 92 // Task runner on which methods of DesktopEnvironmentFactory interface should 93 // be called. 94 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; 95 96 // Used to run input-related tasks. 97 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; 98 99 // Used to run UI code. 100 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 101 102 DISALLOW_COPY_AND_ASSIGN(BasicDesktopEnvironmentFactory); 103 }; 104 105 } // namespace remoting 106 107 #endif // REMOTING_HOST_BASIC_DESKTOP_ENVIRONMENT_H_ 108