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

Unified Diff: remoting/host/client_session.cc

Issue 6724033: Remove authenticated_ fields from stubs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweak. 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/client_session.cc
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index 72cd5ba518fe202209ae9a22d4e33dc5eb8fc141..ba8cff437804963e7d782522ca4a37ca4db2c256 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -6,6 +6,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/task.h"
+#include "media/base/callback.h"
#include "remoting/host/user_authenticator.h"
#include "remoting/proto/auth.pb.h"
@@ -13,9 +14,14 @@ namespace remoting {
ClientSession::ClientSession(
EventHandler* event_handler,
- scoped_refptr<protocol::ConnectionToClient> connection)
+ const base::Callback<UserAuthenticatorFactory>& auth_factory,
+ scoped_refptr<protocol::ConnectionToClient> connection,
+ protocol::InputStub* input_stub)
: event_handler_(event_handler),
- connection_(connection) {
+ auth_factory_(auth_factory),
+ connection_(connection),
+ input_stub_(input_stub),
+ authenticated_(false) {
}
ClientSession::~ClientSession() {
@@ -23,8 +29,13 @@ ClientSession::~ClientSession() {
void ClientSession::SuggestResolution(
const protocol::SuggestResolutionRequest* msg, Task* done) {
- done->Run();
- delete done;
+ media::AutoTaskRunner task_runner(done);
+
+ if (!authenticated_) {
+ LOG(WARNING) << "Invalid control message received "
+ << "(client not authenticated).";
+ return;
+ }
Wez 2011/03/30 20:24:57 If the client sends unexpected messages before hav
simonmorris 2011/03/31 11:14:00 Could be good, in another CL.
}
void ClientSession::BeginSessionRequest(
@@ -32,7 +43,7 @@ void ClientSession::BeginSessionRequest(
DCHECK(event_handler_);
bool success = false;
- scoped_ptr<UserAuthenticator> authenticator(UserAuthenticator::Create());
+ scoped_ptr<UserAuthenticator> authenticator(auth_factory_.Run());
switch (credentials->type()) {
case protocol::PASSWORD:
success = authenticator->Authenticate(credentials->username(),
@@ -45,6 +56,7 @@ void ClientSession::BeginSessionRequest(
}
if (success) {
+ authenticated_ = true;
event_handler_->LocalLoginSucceeded(connection_.get());
} else {
LOG(WARNING) << "Login failed for user " << credentials->username();
@@ -55,12 +67,29 @@ void ClientSession::BeginSessionRequest(
delete done;
}
-void ClientSession::Disconnect() {
- connection_->Disconnect();
+void ClientSession::InjectKeyEvent(const protocol::KeyEvent* event,
+ Task* done) {
+ if (authenticated_) {
+ input_stub_->InjectKeyEvent(event, done);
+ return;
+ }
+ done->Run();
garykac 2011/03/30 20:04:03 nit: The media::AutoTaskRunner task_runner(done)
simonmorris 2011/03/31 11:14:00 Done.
+ delete done;
+}
+
+void ClientSession::InjectMouseEvent(const protocol::MouseEvent* event,
+ Task* done) {
+ if (authenticated_) {
+ input_stub_->InjectMouseEvent(event, done);
+ return;
+ }
+ done->Run();
garykac 2011/03/30 20:04:03 nit: AutoTaskRunner
Wez 2011/03/30 20:24:57 As above, it's not valid for the client to send in
simonmorris 2011/03/31 11:14:00 Done.
simonmorris 2011/03/31 11:14:00 Could be good, in another CL.
+ delete done;
}
-protocol::ConnectionToClient* ClientSession::connection() const {
- return connection_.get();
+void ClientSession::Disconnect() {
+ connection_->Disconnect();
+ authenticated_ = false;
}
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698