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

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

Issue 8764012: Set empty shared secret for Me2Me hosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cache parameter of SetSharedSecret() and use it when session manager is created. 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/chromoting_host.h ('k') | remoting/host/remoting_me2me_host.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/chromoting_host.h" 5 #include "remoting/host/chromoting_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/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 ChromotingHost::ChromotingHost(ChromotingHostContext* context, 44 ChromotingHost::ChromotingHost(ChromotingHostContext* context,
45 MutableHostConfig* config, 45 MutableHostConfig* config,
46 DesktopEnvironment* environment, 46 DesktopEnvironment* environment,
47 bool allow_nat_traversal) 47 bool allow_nat_traversal)
48 : context_(context), 48 : context_(context),
49 desktop_environment_(environment), 49 desktop_environment_(environment),
50 config_(config), 50 config_(config),
51 allow_nat_traversal_(allow_nat_traversal), 51 allow_nat_traversal_(allow_nat_traversal),
52 have_shared_secret_(false),
52 stopping_recorders_(0), 53 stopping_recorders_(0),
53 state_(kInitial), 54 state_(kInitial),
54 protocol_config_(protocol::CandidateSessionConfig::CreateDefault()), 55 protocol_config_(protocol::CandidateSessionConfig::CreateDefault()),
55 is_curtained_(false), 56 is_curtained_(false),
56 is_it2me_(false) { 57 is_it2me_(false) {
57 DCHECK(desktop_environment_); 58 DCHECK(desktop_environment_);
58 desktop_environment_->set_host(this); 59 desktop_environment_->set_host(this);
59 } 60 }
60 61
61 ChromotingHost::~ChromotingHost() { 62 ChromotingHost::~ChromotingHost() {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 130
130 // Stop session manager. 131 // Stop session manager.
131 if (session_manager_.get()) { 132 if (session_manager_.get()) {
132 session_manager_->Close(); 133 session_manager_->Close();
133 // It may not be safe to delete |session_manager_| here becase 134 // It may not be safe to delete |session_manager_| here becase
134 // this method may be invoked in response to a libjingle event and 135 // this method may be invoked in response to a libjingle event and
135 // libjingle's sigslot doesn't handle it properly, so postpone the 136 // libjingle's sigslot doesn't handle it properly, so postpone the
136 // deletion. 137 // deletion.
137 context_->network_message_loop()->DeleteSoon( 138 context_->network_message_loop()->DeleteSoon(
138 FROM_HERE, session_manager_.release()); 139 FROM_HERE, session_manager_.release());
140 have_shared_secret_ = false;
139 } 141 }
140 142
141 // Stop XMPP connection synchronously. 143 // Stop XMPP connection synchronously.
142 if (signal_strategy_.get()) { 144 if (signal_strategy_.get()) {
143 signal_strategy_->Close(); 145 signal_strategy_->Close();
144 signal_strategy_.reset(); 146 signal_strategy_.reset();
145 147
146 for (StatusObserverList::iterator it = status_observers_.begin(); 148 for (StatusObserverList::iterator it = status_observers_.begin();
147 it != status_observers_.end(); ++it) { 149 it != status_observers_.end(); ++it) {
148 (*it)->OnSignallingDisconnected(); 150 (*it)->OnSignallingDisconnected();
149 } 151 }
150 } 152 }
151 153
152 if (recorder_.get()) { 154 if (recorder_.get()) {
153 StopScreenRecorder(); 155 StopScreenRecorder();
154 } else { 156 } else {
155 ShutdownFinish(); 157 ShutdownFinish();
156 } 158 }
157 } 159 }
158 160
159 void ChromotingHost::AddStatusObserver(HostStatusObserver* observer) { 161 void ChromotingHost::AddStatusObserver(HostStatusObserver* observer) {
160 DCHECK_EQ(state_, kInitial); 162 DCHECK_EQ(state_, kInitial);
161 status_observers_.push_back(observer); 163 status_observers_.push_back(observer);
162 } 164 }
163 165
164 void ChromotingHost::SetSharedSecret(const std::string& shared_secret) { 166 void ChromotingHost::SetSharedSecret(const std::string& shared_secret) {
165 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); 167 DCHECK(context_->network_message_loop()->BelongsToCurrentThread());
166 session_manager_->set_authenticator_factory( 168 shared_secret_ = shared_secret;
167 new protocol::V1HostAuthenticatorFactory( 169 have_shared_secret_ = true;
168 key_pair_.GenerateCertificate(), key_pair_.private_key(), 170 if (session_manager_.get()) {
169 shared_secret)); 171 session_manager_->set_authenticator_factory(
172 new protocol::V1HostAuthenticatorFactory(
173 key_pair_.GenerateCertificate(), key_pair_.private_key(),
174 shared_secret_));
175 }
170 } 176 }
171 177
172 //////////////////////////////////////////////////////////////////////////// 178 ////////////////////////////////////////////////////////////////////////////
173 // protocol::ClientSession::EventHandler implementation. 179 // protocol::ClientSession::EventHandler implementation.
174 void ChromotingHost::OnSessionAuthenticated(ClientSession* client) { 180 void ChromotingHost::OnSessionAuthenticated(ClientSession* client) {
175 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); 181 DCHECK(context_->network_message_loop()->BelongsToCurrentThread());
176 182
177 // Disconnect all other clients. 183 // Disconnect all other clients.
178 // Iterate over a copy of the list of clients, to avoid mutating the list 184 // Iterate over a copy of the list of clients, to avoid mutating the list
179 // while iterating over it. 185 // while iterating over it.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 LOG(INFO) << "Host connected as " << local_jid_; 277 LOG(INFO) << "Host connected as " << local_jid_;
272 278
273 // Create and start session manager. 279 // Create and start session manager.
274 protocol::JingleSessionManager* server = 280 protocol::JingleSessionManager* server =
275 new protocol::JingleSessionManager(context_->network_message_loop()); 281 new protocol::JingleSessionManager(context_->network_message_loop());
276 282
277 server->Init(local_jid_, signal_strategy_.get(), 283 server->Init(local_jid_, signal_strategy_.get(),
278 this, allow_nat_traversal_); 284 this, allow_nat_traversal_);
279 285
280 session_manager_.reset(server); 286 session_manager_.reset(server);
287 if (have_shared_secret_) {
Sergey Ulanov 2011/12/01 21:10:13 nit: I don't think we need this flag. !shared_secr
Lambros 2011/12/01 21:29:21 !shared_secret_.empty() wouldn't work. remoting_m
288 session_manager_->set_authenticator_factory(
289 new protocol::V1HostAuthenticatorFactory(
290 key_pair_.GenerateCertificate(), key_pair_.private_key(),
291 shared_secret_));
292 }
281 293
282 for (StatusObserverList::iterator it = status_observers_.begin(); 294 for (StatusObserverList::iterator it = status_observers_.begin();
283 it != status_observers_.end(); ++it) { 295 it != status_observers_.end(); ++it) {
284 (*it)->OnSignallingConnected(signal_strategy_.get(), local_jid_); 296 (*it)->OnSignallingConnected(signal_strategy_.get(), local_jid_);
285 } 297 }
286 } else if (state == SignalStrategy::StatusObserver::CLOSED) { 298 } else if (state == SignalStrategy::StatusObserver::CLOSED) {
287 LOG(INFO) << "Host disconnected from talk network."; 299 LOG(INFO) << "Host disconnected from talk network.";
288 for (StatusObserverList::iterator it = status_observers_.begin(); 300 for (StatusObserverList::iterator it = status_observers_.begin();
289 it != status_observers_.end(); ++it) { 301 it != status_observers_.end(); ++it) {
290 (*it)->OnSignallingDisconnected(); 302 (*it)->OnSignallingDisconnected();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 482 }
471 483
472 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); 484 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin();
473 it != shutdown_tasks_.end(); ++it) { 485 it != shutdown_tasks_.end(); ++it) {
474 it->Run(); 486 it->Run();
475 } 487 }
476 shutdown_tasks_.clear(); 488 shutdown_tasks_.clear();
477 } 489 }
478 490
479 } // namespace remoting 491 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698