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

Side by Side Diff: remoting/host/client_session.cc

Issue 7062013: Move media library AutoTaskRunner to base and rename ScopedTaskRunner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add innocuous but critical BASE_API modifier to ScopedTaskRunner declaration. Created 9 years, 7 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 | « remoting/client/rectangle_update_decoder.cc ('k') | remoting/host/event_executor_linux.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 #include "remoting/host/client_session.h" 5 #include "remoting/host/client_session.h"
6 6
7 #include "base/task.h" 7 #include "base/task.h"
8 #include "media/base/callback.h"
9 #include "remoting/host/user_authenticator.h" 8 #include "remoting/host/user_authenticator.h"
10 #include "remoting/proto/auth.pb.h" 9 #include "remoting/proto/auth.pb.h"
11 10
12 namespace remoting { 11 namespace remoting {
13 12
14 ClientSession::ClientSession( 13 ClientSession::ClientSession(
15 EventHandler* event_handler, 14 EventHandler* event_handler,
16 UserAuthenticator* user_authenticator, 15 UserAuthenticator* user_authenticator,
17 scoped_refptr<protocol::ConnectionToClient> connection, 16 scoped_refptr<protocol::ConnectionToClient> connection,
18 protocol::InputStub* input_stub) 17 protocol::InputStub* input_stub)
19 : event_handler_(event_handler), 18 : event_handler_(event_handler),
20 user_authenticator_(user_authenticator), 19 user_authenticator_(user_authenticator),
21 connection_(connection), 20 connection_(connection),
22 input_stub_(input_stub), 21 input_stub_(input_stub),
23 authenticated_(false) { 22 authenticated_(false) {
24 } 23 }
25 24
26 ClientSession::~ClientSession() { 25 ClientSession::~ClientSession() {
27 } 26 }
28 27
29 void ClientSession::SuggestResolution( 28 void ClientSession::SuggestResolution(
30 const protocol::SuggestResolutionRequest* msg, Task* done) { 29 const protocol::SuggestResolutionRequest* msg, Task* done) {
31 media::AutoTaskRunner done_runner(done); 30 base::ScopedTaskRunner done_runner(done);
32 31
33 if (!authenticated_) { 32 if (!authenticated_) {
34 LOG(WARNING) << "Invalid control message received " 33 LOG(WARNING) << "Invalid control message received "
35 << "(client not authenticated)."; 34 << "(client not authenticated).";
36 return; 35 return;
37 } 36 }
38 } 37 }
39 38
40 void ClientSession::BeginSessionRequest( 39 void ClientSession::BeginSessionRequest(
41 const protocol::LocalLoginCredentials* credentials, Task* done) { 40 const protocol::LocalLoginCredentials* credentials, Task* done) {
42 DCHECK(event_handler_); 41 DCHECK(event_handler_);
43 42
44 media::AutoTaskRunner done_runner(done); 43 base::ScopedTaskRunner done_runner(done);
45 44
46 bool success = false; 45 bool success = false;
47 switch (credentials->type()) { 46 switch (credentials->type()) {
48 case protocol::PASSWORD: 47 case protocol::PASSWORD:
49 success = user_authenticator_->Authenticate(credentials->username(), 48 success = user_authenticator_->Authenticate(credentials->username(),
50 credentials->credential()); 49 credentials->credential());
51 break; 50 break;
52 51
53 default: 52 default:
54 LOG(ERROR) << "Invalid credentials type " << credentials->type(); 53 LOG(ERROR) << "Invalid credentials type " << credentials->type();
55 break; 54 break;
56 } 55 }
57 56
58 OnAuthorizationComplete(success); 57 OnAuthorizationComplete(success);
59 } 58 }
60 59
61 void ClientSession::OnAuthorizationComplete(bool success) { 60 void ClientSession::OnAuthorizationComplete(bool success) {
62 if (success) { 61 if (success) {
63 authenticated_ = true; 62 authenticated_ = true;
64 event_handler_->LocalLoginSucceeded(connection_.get()); 63 event_handler_->LocalLoginSucceeded(connection_.get());
65 } else { 64 } else {
66 LOG(WARNING) << "Login failed"; 65 LOG(WARNING) << "Login failed";
67 event_handler_->LocalLoginFailed(connection_.get()); 66 event_handler_->LocalLoginFailed(connection_.get());
68 } 67 }
69 } 68 }
70 69
71 void ClientSession::InjectKeyEvent(const protocol::KeyEvent* event, 70 void ClientSession::InjectKeyEvent(const protocol::KeyEvent* event,
72 Task* done) { 71 Task* done) {
73 media::AutoTaskRunner done_runner(done); 72 base::ScopedTaskRunner done_runner(done);
74 if (authenticated_) { 73 if (authenticated_) {
75 done_runner.release(); 74 input_stub_->InjectKeyEvent(event, done_runner.Release());
76 input_stub_->InjectKeyEvent(event, done);
77 } 75 }
78 } 76 }
79 77
80 void ClientSession::InjectMouseEvent(const protocol::MouseEvent* event, 78 void ClientSession::InjectMouseEvent(const protocol::MouseEvent* event,
81 Task* done) { 79 Task* done) {
82 media::AutoTaskRunner done_runner(done); 80 base::ScopedTaskRunner done_runner(done);
83 if (authenticated_) { 81 if (authenticated_) {
84 done_runner.release(); 82 input_stub_->InjectMouseEvent(event, done_runner.Release());
85 input_stub_->InjectMouseEvent(event, done);
86 } 83 }
87 } 84 }
88 85
89 void ClientSession::Disconnect() { 86 void ClientSession::Disconnect() {
90 connection_->Disconnect(); 87 connection_->Disconnect();
91 authenticated_ = false; 88 authenticated_ = false;
92 } 89 }
93 90
94 } // namespace remoting 91 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/rectangle_update_decoder.cc ('k') | remoting/host/event_executor_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698