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

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: Address reviewer's comments. 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
« no previous file with comments | « remoting/host/client_session.h ('k') | remoting/host/client_session_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/client_session.cc
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index 72cd5ba518fe202209ae9a22d4e33dc5eb8fc141..b946a0a772abbe088d7cd08914aa8f5134a3fe65 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,16 +29,23 @@ ClientSession::~ClientSession() {
void ClientSession::SuggestResolution(
const protocol::SuggestResolutionRequest* msg, Task* done) {
- done->Run();
- delete done;
+ media::AutoTaskRunner done_runner(done);
+
+ if (!authenticated_) {
+ LOG(WARNING) << "Invalid control message received "
+ << "(client not authenticated).";
+ return;
+ }
}
void ClientSession::BeginSessionRequest(
const protocol::LocalLoginCredentials* credentials, Task* done) {
DCHECK(event_handler_);
+ media::AutoTaskRunner done_runner(done);
+
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,22 +58,35 @@ void ClientSession::BeginSessionRequest(
}
if (success) {
+ authenticated_ = true;
event_handler_->LocalLoginSucceeded(connection_.get());
} else {
LOG(WARNING) << "Login failed for user " << credentials->username();
event_handler_->LocalLoginFailed(connection_.get());
}
+}
+
+void ClientSession::InjectKeyEvent(const protocol::KeyEvent* event,
+ Task* done) {
+ media::AutoTaskRunner done_runner(done);
+ if (authenticated_) {
+ done_runner.release();
+ input_stub_->InjectKeyEvent(event, done);
+ }
+}
- done->Run();
- delete done;
+void ClientSession::InjectMouseEvent(const protocol::MouseEvent* event,
+ Task* done) {
+ media::AutoTaskRunner done_runner(done);
+ if (authenticated_) {
+ done_runner.release();
+ input_stub_->InjectMouseEvent(event, done);
+ }
}
void ClientSession::Disconnect() {
connection_->Disconnect();
-}
-
-protocol::ConnectionToClient* ClientSession::connection() const {
- return connection_.get();
+ authenticated_ = false;
}
} // namespace remoting
« no previous file with comments | « remoting/host/client_session.h ('k') | remoting/host/client_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698