| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_CHROMOTING_HOST_H_ | 5 #ifndef REMOTING_CHROMOTING_HOST_H_ |
| 6 #define REMOTING_CHROMOTING_HOST_H_ | 6 #define REMOTING_CHROMOTING_HOST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/thread.h" | 10 #include "base/thread.h" |
| 11 #include "remoting/host/capturer.h" | 11 #include "remoting/host/capturer.h" |
| 12 #include "remoting/host/client_connection.h" | 12 #include "remoting/host/client_connection.h" |
| 13 #include "remoting/host/encoder.h" | 13 #include "remoting/host/encoder.h" |
| 14 #include "remoting/host/event_executor.h" | 14 #include "remoting/host/event_executor.h" |
| 15 #include "remoting/host/heartbeat_sender.h" | 15 #include "remoting/host/heartbeat_sender.h" |
| 16 #include "remoting/host/session_manager.h" | 16 #include "remoting/host/session_manager.h" |
| 17 #include "remoting/jingle_glue/jingle_client.h" | 17 #include "remoting/jingle_glue/jingle_client.h" |
| 18 #include "remoting/jingle_glue/jingle_thread.h" | 18 #include "remoting/jingle_glue/jingle_thread.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class WaitableEvent; | 21 class WaitableEvent; |
| 22 } // namespace base | 22 } // namespace base |
| 23 | 23 |
| 24 namespace remoting { | 24 namespace remoting { |
| 25 | 25 |
| 26 class HostConfig; |
| 27 |
| 26 // A class to implement the functionality of a host process. | 28 // A class to implement the functionality of a host process. |
| 27 // | 29 // |
| 28 // Here's the work flow of this class: | 30 // Here's the work flow of this class: |
| 29 // 1. We should load the saved GAIA ID token or if this is the first | 31 // 1. We should load the saved GAIA ID token or if this is the first |
| 30 // time the host process runs we should prompt user for the | 32 // time the host process runs we should prompt user for the |
| 31 // credential. We will use this token or credentials to authenicate | 33 // credential. We will use this token or credentials to authenicate |
| 32 // and register the host. | 34 // and register the host. |
| 33 // | 35 // |
| 34 // 2. We listen for incoming connection using libjingle. We will create | 36 // 2. We listen for incoming connection using libjingle. We will create |
| 35 // a ClientConnection object that wraps around linjingle for transport. Also | 37 // a ClientConnection object that wraps around linjingle for transport. Also |
| 36 // create a SessionManager with appropriate Encoder and Capturer and | 38 // create a SessionManager with appropriate Encoder and Capturer and |
| 37 // add the ClientConnection to this SessionManager for transporting the | 39 // add the ClientConnection to this SessionManager for transporting the |
| 38 // screen captures. A EventExecutor is created and registered with the | 40 // screen captures. A EventExecutor is created and registered with the |
| 39 // ClientConnection to receive mouse / keyboard events from the remote | 41 // ClientConnection to receive mouse / keyboard events from the remote |
| 40 // client. | 42 // client. |
| 41 // This is also the right time to create multiple threads to host | 43 // This is also the right time to create multiple threads to host |
| 42 // the above objects. After we have done all the initialization | 44 // the above objects. After we have done all the initialization |
| 43 // we'll start the SessionManager. We'll then enter the running state | 45 // we'll start the SessionManager. We'll then enter the running state |
| 44 // of the host process. | 46 // of the host process. |
| 45 // | 47 // |
| 46 // 3. When the user is disconencted, we will pause the SessionManager | 48 // 3. When the user is disconencted, we will pause the SessionManager |
| 47 // and try to terminate the threads we have created. This will allow | 49 // and try to terminate the threads we have created. This will allow |
| 48 // all pending tasks to complete. After all of that completed we | 50 // all pending tasks to complete. After all of that completed we |
| 49 // return to the idle state. We then go to step (2) if there a new | 51 // return to the idle state. We then go to step (2) if there a new |
| 50 // incoming connection. | 52 // incoming connection. |
| 51 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 53 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| 52 public ClientConnection::EventHandler, | 54 public ClientConnection::EventHandler, |
| 53 public JingleClient::Callback { | 55 public JingleClient::Callback { |
| 54 public: | 56 public: |
| 55 ChromotingHost(const std::string& username, const std::string& auth_token, | 57 ChromotingHost(HostConfig* config, Capturer* capturer, Encoder* encoder, |
| 56 Capturer* capturer, Encoder* encoder, EventExecutor* executor, | 58 EventExecutor* executor, base::WaitableEvent* host_done); |
| 57 base::WaitableEvent* host_done); | |
| 58 virtual ~ChromotingHost(); | 59 virtual ~ChromotingHost(); |
| 59 | 60 |
| 60 // Run the host porcess. This method returns only after the message loop | 61 // Run the host porcess. This method returns only after the message loop |
| 61 // of the host process exits. | 62 // of the host process exits. |
| 62 void Run(); | 63 void Run(); |
| 63 | 64 |
| 64 // This method is called when we need to the host process. | 65 // This method is called when we need to the host process. |
| 65 void DestroySession(); | 66 void DestroySession(); |
| 66 | 67 |
| 67 // This method talks to the cloud to register the host process. If | 68 // This method talks to the cloud to register the host process. If |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 102 |
| 102 // Used to handle the Jingle connection. | 103 // Used to handle the Jingle connection. |
| 103 JingleThread network_thread_; | 104 JingleThread network_thread_; |
| 104 | 105 |
| 105 // A thread that hosts capture operations. | 106 // A thread that hosts capture operations. |
| 106 base::Thread capture_thread_; | 107 base::Thread capture_thread_; |
| 107 | 108 |
| 108 // A thread that hosts encode operations. | 109 // A thread that hosts encode operations. |
| 109 base::Thread encode_thread_; | 110 base::Thread encode_thread_; |
| 110 | 111 |
| 111 std::string username_; | 112 scoped_refptr<HostConfig> config_; |
| 112 std::string auth_token_; | |
| 113 | 113 |
| 114 // Capturer to be used by SessionManager. Once the SessionManager is | 114 // Capturer to be used by SessionManager. Once the SessionManager is |
| 115 // constructed this is set to NULL. | 115 // constructed this is set to NULL. |
| 116 scoped_ptr<Capturer> capturer_; | 116 scoped_ptr<Capturer> capturer_; |
| 117 | 117 |
| 118 // Encoder to be used by the SessionManager. Once the SessionManager is | 118 // Encoder to be used by the SessionManager. Once the SessionManager is |
| 119 // constructed this is set to NULL. | 119 // constructed this is set to NULL. |
| 120 scoped_ptr<Encoder> encoder_; | 120 scoped_ptr<Encoder> encoder_; |
| 121 | 121 |
| 122 // EventExecutor executes input events received from the client. | 122 // EventExecutor executes input events received from the client. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 138 | 138 |
| 139 // Signals the host is ready to be destroyed. | 139 // Signals the host is ready to be destroyed. |
| 140 base::WaitableEvent* host_done_; | 140 base::WaitableEvent* host_done_; |
| 141 | 141 |
| 142 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 142 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 } // namespace remoting | 145 } // namespace remoting |
| 146 | 146 |
| 147 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 147 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
| OLD | NEW |