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

Side by Side Diff: remoting/protocol/connection_to_host.cc

Issue 8619011: Use Authenticator interface in Session and SessionManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unittests Created 9 years 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/host/simple_host_process.cc ('k') | remoting/protocol/content_description.h » ('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/protocol/connection_to_host.h" 5 #include "remoting/protocol/connection_to_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
11 #include "remoting/base/constants.h" 11 #include "remoting/base/constants.h"
12 #include "remoting/jingle_glue/javascript_signal_strategy.h" 12 #include "remoting/jingle_glue/javascript_signal_strategy.h"
13 #include "remoting/jingle_glue/xmpp_signal_strategy.h" 13 #include "remoting/jingle_glue/xmpp_signal_strategy.h"
14 #include "remoting/protocol/auth_util.h" 14 #include "remoting/protocol/auth_util.h"
15 #include "remoting/protocol/client_control_dispatcher.h" 15 #include "remoting/protocol/client_control_dispatcher.h"
16 #include "remoting/protocol/client_event_dispatcher.h" 16 #include "remoting/protocol/client_event_dispatcher.h"
17 #include "remoting/protocol/client_stub.h" 17 #include "remoting/protocol/client_stub.h"
18 #include "remoting/protocol/jingle_session_manager.h" 18 #include "remoting/protocol/jingle_session_manager.h"
19 #include "remoting/protocol/pepper_session_manager.h" 19 #include "remoting/protocol/pepper_session_manager.h"
20 #include "remoting/protocol/v1_authenticator.h"
20 #include "remoting/protocol/video_reader.h" 21 #include "remoting/protocol/video_reader.h"
21 #include "remoting/protocol/video_stub.h" 22 #include "remoting/protocol/video_stub.h"
22 #include "remoting/protocol/util.h" 23 #include "remoting/protocol/util.h"
23 24
24 namespace remoting { 25 namespace remoting {
25 namespace protocol { 26 namespace protocol {
26 27
27 ConnectionToHost::ConnectionToHost( 28 ConnectionToHost::ConnectionToHost(
28 base::MessageLoopProxy* message_loop, 29 base::MessageLoopProxy* message_loop,
29 pp::Instance* pp_instance, 30 pp::Instance* pp_instance,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 signal_strategy_.reset(); 94 signal_strategy_.reset();
94 95
95 shutdown_task.Run(); 96 shutdown_task.Run();
96 } 97 }
97 98
98 void ConnectionToHost::InitSession() { 99 void ConnectionToHost::InitSession() {
99 DCHECK(message_loop_->BelongsToCurrentThread()); 100 DCHECK(message_loop_->BelongsToCurrentThread());
100 101
101 session_manager_.reset(new PepperSessionManager(pp_instance_)); 102 session_manager_.reset(new PepperSessionManager(pp_instance_));
102 session_manager_->Init( 103 session_manager_->Init(
103 local_jid_, signal_strategy_.get(), this, NULL, "", allow_nat_traversal_); 104 local_jid_, signal_strategy_.get(), this, allow_nat_traversal_);
104 } 105 }
105 106
106 const SessionConfig& ConnectionToHost::config() { 107 const SessionConfig& ConnectionToHost::config() {
107 return session_->config(); 108 return session_->config();
108 } 109 }
109 110
110 void ConnectionToHost::OnStateChange( 111 void ConnectionToHost::OnStateChange(
111 SignalStrategy::StatusObserver::State state) { 112 SignalStrategy::StatusObserver::State state) {
112 DCHECK(message_loop_->BelongsToCurrentThread()); 113 DCHECK(message_loop_->BelongsToCurrentThread());
113 DCHECK(event_callback_); 114 DCHECK(event_callback_);
(...skipping 11 matching lines...) Expand all
125 DCHECK(message_loop_->BelongsToCurrentThread()); 126 DCHECK(message_loop_->BelongsToCurrentThread());
126 local_jid_ = full_jid; 127 local_jid_ = full_jid;
127 } 128 }
128 129
129 void ConnectionToHost::OnSessionManagerInitialized() { 130 void ConnectionToHost::OnSessionManagerInitialized() {
130 DCHECK(message_loop_->BelongsToCurrentThread()); 131 DCHECK(message_loop_->BelongsToCurrentThread());
131 132
132 // After SessionManager is initialized we can try to connect to the host. 133 // After SessionManager is initialized we can try to connect to the host.
133 CandidateSessionConfig* candidate_config = 134 CandidateSessionConfig* candidate_config =
134 CandidateSessionConfig::CreateDefault(); 135 CandidateSessionConfig::CreateDefault();
135 std::string client_token = 136 V1ClientAuthenticator* authenticator =
136 protocol::GenerateSupportAuthToken(local_jid_, access_code_); 137 new V1ClientAuthenticator(local_jid_, access_code_);
137 session_.reset(session_manager_->Connect( 138 session_.reset(session_manager_->Connect(
138 host_jid_, host_public_key_, client_token, candidate_config, 139 host_jid_, authenticator, candidate_config,
139 base::Bind(&ConnectionToHost::OnSessionStateChange, 140 base::Bind(&ConnectionToHost::OnSessionStateChange,
140 base::Unretained(this)))); 141 base::Unretained(this))));
141
142 // Set the shared-secret for securing SSL channels.
143 session_->set_shared_secret(access_code_);
144 } 142 }
145 143
146 void ConnectionToHost::OnIncomingSession( 144 void ConnectionToHost::OnIncomingSession(
147 Session* session, 145 Session* session,
148 SessionManager::IncomingSessionResponse* response) { 146 SessionManager::IncomingSessionResponse* response) {
149 DCHECK(message_loop_->BelongsToCurrentThread()); 147 DCHECK(message_loop_->BelongsToCurrentThread());
150 // Client always rejects incoming sessions. 148 // Client always rejects incoming sessions.
151 *response = SessionManager::DECLINE; 149 *response = SessionManager::DECLINE;
152 } 150 }
153 151
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 245
248 if (state != state_) { 246 if (state != state_) {
249 state_ = state; 247 state_ = state;
250 error_ = error; 248 error_ = error;
251 event_callback_->OnConnectionState(state_, error_); 249 event_callback_->OnConnectionState(state_, error_);
252 } 250 }
253 } 251 }
254 252
255 } // namespace protocol 253 } // namespace protocol
256 } // namespace remoting 254 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/simple_host_process.cc ('k') | remoting/protocol/content_description.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698