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