Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1085)

Side by Side Diff: remoting/host/chromoting_host.h

Issue 6711033: A new authenticated connection evicts an old one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | remoting/host/chromoting_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "remoting/base/encoder.h" 12 #include "remoting/base/encoder.h"
13 #include "remoting/host/access_verifier.h" 13 #include "remoting/host/access_verifier.h"
14 #include "remoting/host/capturer.h" 14 #include "remoting/host/capturer.h"
15 #include "remoting/host/client_session.h"
15 #include "remoting/host/desktop_environment.h" 16 #include "remoting/host/desktop_environment.h"
16 #include "remoting/host/heartbeat_sender.h" 17 #include "remoting/host/heartbeat_sender.h"
17 #include "remoting/jingle_glue/jingle_client.h" 18 #include "remoting/jingle_glue/jingle_client.h"
18 #include "remoting/jingle_glue/jingle_thread.h" 19 #include "remoting/jingle_glue/jingle_thread.h"
19 #include "remoting/protocol/session_manager.h" 20 #include "remoting/protocol/session_manager.h"
20 #include "remoting/protocol/connection_to_client.h" 21 #include "remoting/protocol/connection_to_client.h"
21 22
22 class Task; 23 class Task;
23 24
24 namespace remoting { 25 namespace remoting {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // After we have done all the initialization we'll start the ScreenRecorder. 57 // After we have done all the initialization we'll start the ScreenRecorder.
57 // We'll then enter the running state of the host process. 58 // We'll then enter the running state of the host process.
58 // 59 //
59 // 3. When the user is disconnected, we will pause the ScreenRecorder 60 // 3. When the user is disconnected, we will pause the ScreenRecorder
60 // and try to terminate the threads we have created. This will allow 61 // and try to terminate the threads we have created. This will allow
61 // all pending tasks to complete. After all of that completed we 62 // all pending tasks to complete. After all of that completed we
62 // return to the idle state. We then go to step (2) if there a new 63 // return to the idle state. We then go to step (2) if there a new
63 // incoming connection. 64 // incoming connection.
64 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, 65 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
65 public protocol::ConnectionToClient::EventHandler, 66 public protocol::ConnectionToClient::EventHandler,
66 public DesktopEnvironment::EventHandler, 67 public ClientSession::EventHandler,
67 public JingleClient::Callback { 68 public JingleClient::Callback {
68 public: 69 public:
69 // Factory methods that must be used to create ChromotingHost instances. 70 // Factory methods that must be used to create ChromotingHost instances.
70 // Default capturer and input stub are used if it is not specified. 71 // Default capturer and input stub are used if it is not specified.
71 static ChromotingHost* Create(ChromotingHostContext* context, 72 static ChromotingHost* Create(ChromotingHostContext* context,
72 MutableHostConfig* config); 73 MutableHostConfig* config);
73 static ChromotingHost* Create(ChromotingHostContext* context, 74 static ChromotingHost* Create(ChromotingHostContext* context,
74 MutableHostConfig* config, 75 MutableHostConfig* config,
75 DesktopEnvironment* environment); 76 DesktopEnvironment* environment);
76 77
(...skipping 21 matching lines...) Expand all
98 // protocol::ConnectionToClient::EventHandler implementations 99 // protocol::ConnectionToClient::EventHandler implementations
99 virtual void OnConnectionOpened(protocol::ConnectionToClient* client); 100 virtual void OnConnectionOpened(protocol::ConnectionToClient* client);
100 virtual void OnConnectionClosed(protocol::ConnectionToClient* client); 101 virtual void OnConnectionClosed(protocol::ConnectionToClient* client);
101 virtual void OnConnectionFailed(protocol::ConnectionToClient* client); 102 virtual void OnConnectionFailed(protocol::ConnectionToClient* client);
102 103
103 //////////////////////////////////////////////////////////////////////////// 104 ////////////////////////////////////////////////////////////////////////////
104 // JingleClient::Callback implementations 105 // JingleClient::Callback implementations
105 virtual void OnStateChange(JingleClient* client, JingleClient::State state); 106 virtual void OnStateChange(JingleClient* client, JingleClient::State state);
106 107
107 //////////////////////////////////////////////////////////////////////////// 108 ////////////////////////////////////////////////////////////////////////////
108 // DesktopEnvironment::EventHandler implementations 109 // ClientSession::EventHandler implementations
109 virtual void LocalLoginSucceeded(); 110 virtual void LocalLoginSucceeded(
110 virtual void LocalLoginFailed(); 111 scoped_refptr<protocol::ConnectionToClient> client);
112 virtual void LocalLoginFailed(
113 scoped_refptr<protocol::ConnectionToClient> client);
111 114
112 // Callback for ChromotingServer. 115 // Callback for ChromotingServer.
113 void OnNewClientSession( 116 void OnNewClientSession(
114 protocol::Session* session, 117 protocol::Session* session,
115 protocol::SessionManager::IncomingSessionResponse* response); 118 protocol::SessionManager::IncomingSessionResponse* response);
116 119
117 // Sets desired configuration for the protocol. Ownership of the 120 // Sets desired configuration for the protocol. Ownership of the
118 // |config| is transferred to the object. Must be called before Start(). 121 // |config| is transferred to the object. Must be called before Start().
119 void set_protocol_config(protocol::CandidateSessionConfig* config); 122 void set_protocol_config(protocol::CandidateSessionConfig* config);
120 123
121 // This getter is only used in unit test.
122 protocol::HostStub* host_stub() const;
123
124 // This setter is only used in unit test to simulate client connection. 124 // This setter is only used in unit test to simulate client connection.
125 void set_connection(protocol::ConnectionToClient* conn) { 125 void AddClient(ClientSession* client);
126 connection_ = conn;
127 }
128 126
129 private: 127 private:
130 friend class base::RefCountedThreadSafe<ChromotingHost>; 128 friend class base::RefCountedThreadSafe<ChromotingHost>;
131 129
132 ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config, 130 ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config,
133 DesktopEnvironment* environment); 131 DesktopEnvironment* environment);
134 virtual ~ChromotingHost(); 132 virtual ~ChromotingHost();
135 133
136 enum State { 134 enum State {
137 kInitial, 135 kInitial,
(...skipping 22 matching lines...) Expand all
160 // receive connection requests from chromoting client. 158 // receive connection requests from chromoting client.
161 scoped_refptr<JingleClient> jingle_client_; 159 scoped_refptr<JingleClient> jingle_client_;
162 160
163 scoped_refptr<protocol::SessionManager> session_manager_; 161 scoped_refptr<protocol::SessionManager> session_manager_;
164 162
165 // Objects that takes care of sending heartbeats to the chromoting bot. 163 // Objects that takes care of sending heartbeats to the chromoting bot.
166 scoped_refptr<HeartbeatSender> heartbeat_sender_; 164 scoped_refptr<HeartbeatSender> heartbeat_sender_;
167 165
168 AccessVerifier access_verifier_; 166 AccessVerifier access_verifier_;
169 167
170 // A ConnectionToClient manages the connectino to a remote client. 168 // The connections to remote clients.
171 // TODO(hclam): Expand this to a list of clients. 169 std::vector<scoped_refptr<ClientSession> > clients_;
172 scoped_refptr<protocol::ConnectionToClient> connection_;
173 170
174 // Session manager for the host process. 171 // Session manager for the host process.
175 scoped_refptr<ScreenRecorder> recorder_; 172 scoped_refptr<ScreenRecorder> recorder_;
176 173
177 // This task gets executed when this object fails to connect to the 174 // This task gets executed when this object fails to connect to the
178 // talk network or Shutdown() is called. 175 // talk network or Shutdown() is called.
179 scoped_ptr<Task> shutdown_task_; 176 scoped_ptr<Task> shutdown_task_;
180 177
181 // Tracks the internal state of the host. 178 // Tracks the internal state of the host.
182 // This variable is written on the main thread of ChromotingHostContext 179 // This variable is written on the main thread of ChromotingHostContext
183 // and read by jingle thread. 180 // and read by jingle thread.
184 State state_; 181 State state_;
185 182
186 // Lock is to lock the access to |state_|. 183 // Lock is to lock the access to |state_|.
187 base::Lock lock_; 184 base::Lock lock_;
188 185
189 // Configuration of the protocol. 186 // Configuration of the protocol.
190 scoped_ptr<protocol::CandidateSessionConfig> protocol_config_; 187 scoped_ptr<protocol::CandidateSessionConfig> protocol_config_;
191 188
192 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); 189 DISALLOW_COPY_AND_ASSIGN(ChromotingHost);
193 }; 190 };
194 191
195 } // namespace remoting 192 } // namespace remoting
196 193
197 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ 194 #endif // REMOTING_HOST_CHROMOTING_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/host/chromoting_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698