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

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

Issue 8476018: Move ConnectionToClient::EventHandler from ChromotingHost to ClientSession (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month 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') | remoting/host/chromoting_host.cc » ('J')
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/memory/scoped_ptr.h" 10 #include "base/memory/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/client_session.h"
16 #include "remoting/host/desktop_environment.h" 16 #include "remoting/host/desktop_environment.h"
17 #include "remoting/host/host_status_observer.h" 17 #include "remoting/host/host_status_observer.h"
18 #include "remoting/host/ui_strings.h" 18 #include "remoting/host/ui_strings.h"
19 #include "remoting/jingle_glue/jingle_thread.h" 19 #include "remoting/jingle_glue/jingle_thread.h"
20 #include "remoting/jingle_glue/signal_strategy.h" 20 #include "remoting/jingle_glue/signal_strategy.h"
21 #include "remoting/protocol/session_manager.h" 21 #include "remoting/protocol/session_manager.h"
22 #include "remoting/protocol/connection_to_client.h" 22 #include "remoting/protocol/connection_to_client.h"
23 23
24 class Task; 24 class Task;
25 25
26 namespace remoting { 26 namespace remoting {
27 27
28 namespace protocol { 28 namespace protocol {
29 class ConnectionToClient;
30 class HostStub; 29 class HostStub;
31 class InputStub; 30 class InputStub;
32 class SessionConfig; 31 class SessionConfig;
33 class CandidateSessionConfig; 32 class CandidateSessionConfig;
34 } // namespace protocol 33 } // namespace protocol
35 34
36 class Capturer; 35 class Capturer;
37 class ChromotingHostContext; 36 class ChromotingHostContext;
38 class DesktopEnvironment; 37 class DesktopEnvironment;
39 class Encoder; 38 class Encoder;
(...skipping 17 matching lines...) Expand all
57 // client. 56 // client.
58 // 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.
59 // We'll then enter the running state of the host process. 58 // We'll then enter the running state of the host process.
60 // 59 //
61 // 3. When the user is disconnected, we will pause the ScreenRecorder 60 // 3. When the user is disconnected, we will pause the ScreenRecorder
62 // 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
63 // all pending tasks to complete. After all of that completed we 62 // all pending tasks to complete. After all of that completed we
64 // 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
65 // incoming connection. 64 // incoming connection.
66 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, 65 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
67 public protocol::ConnectionToClient::EventHandler,
68 public ClientSession::EventHandler, 66 public ClientSession::EventHandler,
69 public SignalStrategy::StatusObserver, 67 public SignalStrategy::StatusObserver,
70 public protocol::SessionManager::Listener { 68 public protocol::SessionManager::Listener {
71 public: 69 public:
72 // Factory methods that must be used to create ChromotingHost 70 // Factory methods that must be used to create ChromotingHost
73 // instances. Returned instance takes ownership of 71 // instances. Returned instance takes ownership of
74 // |access_verifier|. It does NOT take ownership of |context|, 72 // |access_verifier|. It does NOT take ownership of |context|,
75 // and |environment|, but they should not be deleted until 73 // and |environment|, but they should not be deleted until
76 // returned host is destroyed. 74 // returned host is destroyed.
77 static ChromotingHost* Create(ChromotingHostContext* context, 75 static ChromotingHost* Create(ChromotingHostContext* context,
(...skipping 14 matching lines...) Expand all
92 // called after shutdown is completed. 90 // called after shutdown is completed.
93 void Shutdown(Task* shutdown_task); 91 void Shutdown(Task* shutdown_task);
94 92
95 // Adds |observer| to the list of status observers. Doesn't take 93 // Adds |observer| to the list of status observers. Doesn't take
96 // ownership of |observer|, so |observer| must outlive this 94 // ownership of |observer|, so |observer| must outlive this
97 // object. All status observers must be added before the host is 95 // object. All status observers must be added before the host is
98 // started. 96 // started.
99 void AddStatusObserver(HostStatusObserver* observer); 97 void AddStatusObserver(HostStatusObserver* observer);
100 98
101 //////////////////////////////////////////////////////////////////////////// 99 ////////////////////////////////////////////////////////////////////////////
102 // protocol::ConnectionToClient::EventHandler implementation.
103 // TODO(sergeyu): Move this to ClientSession.
104 virtual void OnConnectionOpened(protocol::ConnectionToClient* client);
105 virtual void OnConnectionClosed(protocol::ConnectionToClient* client);
106 virtual void OnConnectionFailed(protocol::ConnectionToClient* client);
107 virtual void OnSequenceNumberUpdated(protocol::ConnectionToClient* client,
108 int64 sequence_number);
109
110 ////////////////////////////////////////////////////////////////////////////
111 // SignalStrategy::StatusObserver implementation. 100 // SignalStrategy::StatusObserver implementation.
112 virtual void OnStateChange( 101 virtual void OnStateChange(
113 SignalStrategy::StatusObserver::State state) OVERRIDE; 102 SignalStrategy::StatusObserver::State state) OVERRIDE;
114 virtual void OnJidChange(const std::string& full_jid) OVERRIDE; 103 virtual void OnJidChange(const std::string& full_jid) OVERRIDE;
115 104
116 //////////////////////////////////////////////////////////////////////////// 105 ////////////////////////////////////////////////////////////////////////////
117 // ClientSession::EventHandler implementation. 106 // ClientSession::EventHandler implementation.
118 virtual void OnAuthenticationComplete( 107 virtual void OnSessionAuthenticated(ClientSession* client) OVERRIDE;
119 scoped_refptr<protocol::ConnectionToClient> client); 108 virtual void OnSessionClosed(ClientSession* session) OVERRIDE;
109 virtual void OnSessionSequenceNumber(ClientSession* session,
110 int64 sequence_number) OVERRIDE;
120 111
121 // SessionManager::Listener implementation. 112 // SessionManager::Listener implementation.
122 virtual void OnSessionManagerInitialized() OVERRIDE; 113 virtual void OnSessionManagerInitialized() OVERRIDE;
123 virtual void OnIncomingSession( 114 virtual void OnIncomingSession(
124 protocol::Session* session, 115 protocol::Session* session,
125 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; 116 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE;
126 117
127 void AddAuthenticatedClient( 118 void AddAuthenticatedClient(ClientSession* client,
Wez 2011/11/09 01:35:07 Does this belong in the public interface, since it
Sergey Ulanov 2011/11/09 19:26:13 Made it private. I either case I removed this meth
128 scoped_refptr<protocol::ConnectionToClient> connection, 119 const protocol::SessionConfig& config,
129 const protocol::SessionConfig& config, 120 const std::string& jid);
130 const std::string& jid);
131 121
132 // Sets desired configuration for the protocol. Ownership of the 122 // Sets desired configuration for the protocol. Ownership of the
133 // |config| is transferred to the object. Must be called before Start(). 123 // |config| is transferred to the object. Must be called before Start().
134 void set_protocol_config(protocol::CandidateSessionConfig* config); 124 void set_protocol_config(protocol::CandidateSessionConfig* config);
135 125
136 // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. 126 // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom.
137 void set_it2me(bool is_it2me) { 127 void set_it2me(bool is_it2me) {
138 is_it2me_ = is_it2me; 128 is_it2me_ = is_it2me;
139 } 129 }
140 void set_access_code(const std::string& access_code) { 130 void set_access_code(const std::string& access_code) {
(...skipping 30 matching lines...) Expand all
171 // Takes ownership of |access_verifier|, and adds a reference to 161 // Takes ownership of |access_verifier|, and adds a reference to
172 // |config|. Caller keeps ownership of |context| and |environment|. 162 // |config|. Caller keeps ownership of |context| and |environment|.
173 ChromotingHost(ChromotingHostContext* context, 163 ChromotingHost(ChromotingHostContext* context,
174 MutableHostConfig* config, 164 MutableHostConfig* config,
175 DesktopEnvironment* environment, 165 DesktopEnvironment* environment,
176 AccessVerifier* access_verifier, 166 AccessVerifier* access_verifier,
177 bool allow_nat_traversal); 167 bool allow_nat_traversal);
178 virtual ~ChromotingHost(); 168 virtual ~ChromotingHost();
179 169
180 // This method is called if a client is disconnected from the host. 170 // This method is called if a client is disconnected from the host.
181 void OnClientDisconnected(protocol::ConnectionToClient* client); 171 void OnClientDisconnected(ClientSession* client);
Wez 2011/11/09 01:35:07 nit: Perhaps it would be clearer to call this OnSe
Sergey Ulanov 2011/11/09 19:26:13 This method is removed in the next CL.
182 172
183 // Creates encoder for the specified configuration. 173 // Creates encoder for the specified configuration.
184 Encoder* CreateEncoder(const protocol::SessionConfig& config); 174 Encoder* CreateEncoder(const protocol::SessionConfig& config);
185 175
186 std::string GenerateHostAuthToken(const std::string& encoded_client_token); 176 std::string GenerateHostAuthToken(const std::string& encoded_client_token);
187 177
188 int AuthenticatedClientsCount() const; 178 int AuthenticatedClientsCount() const;
189 179
190 void EnableCurtainMode(bool enable); 180 void EnableCurtainMode(bool enable);
191 181
192 void ProcessPreAuthentication(
193 const scoped_refptr<protocol::ConnectionToClient>& connection);
194
195 void StopScreenRecorder(); 182 void StopScreenRecorder();
196 void OnScreenRecorderStopped(); 183 void OnScreenRecorderStopped();
197 184
198 // The following methods are called during shutdown. 185 // The following methods are called during shutdown.
199 void ShutdownNetwork(); 186 void ShutdownNetwork();
200 void ShutdownRecorder(); 187 void ShutdownRecorder();
201 void ShutdownFinish(); 188 void ShutdownFinish();
202 189
203 // Parameters specified when the host was created. 190 // Parameters specified when the host was created.
204 ChromotingHostContext* context_; 191 ChromotingHostContext* context_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 std::vector<Task*> shutdown_tasks_; 237 std::vector<Task*> shutdown_tasks_;
251 238
252 UiStrings ui_strings_; 239 UiStrings ui_strings_;
253 240
254 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); 241 DISALLOW_COPY_AND_ASSIGN(ChromotingHost);
255 }; 242 };
256 243
257 } // namespace remoting 244 } // namespace remoting
258 245
259 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ 246 #endif // REMOTING_HOST_CHROMOTING_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/host/chromoting_host.cc » ('j') | remoting/host/chromoting_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698