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

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

Issue 7796026: Pass SessionConfig by reference instead of pointer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // Close existing sessions and shutdown the host. 270 // Close existing sessions and shutdown the host.
271 Shutdown(NULL); 271 Shutdown(NULL);
272 return; 272 return;
273 } 273 }
274 274
275 // TODO(simonmorris): The resolution is set in the video stream now, 275 // TODO(simonmorris): The resolution is set in the video stream now,
276 // so it doesn't need to be set here. 276 // so it doesn't need to be set here.
277 *protocol_config_->mutable_initial_resolution() = 277 *protocol_config_->mutable_initial_resolution() =
278 protocol::ScreenResolution(2048, 2048); 278 protocol::ScreenResolution(2048, 2048);
279 // TODO(sergeyu): Respect resolution requested by the client if supported. 279 // TODO(sergeyu): Respect resolution requested by the client if supported.
280 protocol::SessionConfig* config = protocol_config_->Select( 280 protocol::SessionConfig config;
281 session->candidate_config(), true /* force_host_resolution */); 281 if (!protocol_config_->Select(session->candidate_config(),
282 282 true /* force_host_resolution */, &config)) {
283 if (!config) {
284 LOG(WARNING) << "Rejecting connection from " << session->jid() 283 LOG(WARNING) << "Rejecting connection from " << session->jid()
285 << " because no compatible configuration has been found."; 284 << " because no compatible configuration has been found.";
286 *response = protocol::SessionManager::INCOMPATIBLE; 285 *response = protocol::SessionManager::INCOMPATIBLE;
287 return; 286 return;
288 } 287 }
289 288
290 session->set_config(config); 289 session->set_config(config);
291 session->set_receiver_token( 290 session->set_receiver_token(
292 GenerateHostAuthToken(session->initiator_token())); 291 GenerateHostAuthToken(session->initiator_token()));
293 292
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // Disable the "curtain" if there are no more active clients. 398 // Disable the "curtain" if there are no more active clients.
400 if (AuthenticatedClientsCount() == 0) { 399 if (AuthenticatedClientsCount() == 0) {
401 EnableCurtainMode(false); 400 EnableCurtainMode(false);
402 if (is_it2me_) { 401 if (is_it2me_) {
403 desktop_environment_->OnLastDisconnect(); 402 desktop_environment_->OnLastDisconnect();
404 } 403 }
405 } 404 }
406 } 405 }
407 406
408 // TODO(sergeyu): Move this to SessionManager? 407 // TODO(sergeyu): Move this to SessionManager?
409 Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig* config) { 408 Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig& config) {
410 const protocol::ChannelConfig& video_config = config->video_config(); 409 const protocol::ChannelConfig& video_config = config.video_config();
411 410
412 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { 411 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) {
413 return EncoderRowBased::CreateVerbatimEncoder(); 412 return EncoderRowBased::CreateVerbatimEncoder();
414 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { 413 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) {
415 return EncoderRowBased::CreateZlibEncoder(); 414 return EncoderRowBased::CreateZlibEncoder();
416 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { 415 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) {
417 return new remoting::EncoderVp8(); 416 return new remoting::EncoderVp8();
418 } 417 }
419 418
420 return NULL; 419 return NULL;
(...skipping 27 matching lines...) Expand all
448 447
449 void ChromotingHost::LocalLoginSucceeded( 448 void ChromotingHost::LocalLoginSucceeded(
450 scoped_refptr<ConnectionToClient> connection) { 449 scoped_refptr<ConnectionToClient> connection) {
451 if (MessageLoop::current() != context_->main_message_loop()) { 450 if (MessageLoop::current() != context_->main_message_loop()) {
452 context_->main_message_loop()->PostTask( 451 context_->main_message_loop()->PostTask(
453 FROM_HERE, base::Bind(&ChromotingHost::LocalLoginSucceeded, this, 452 FROM_HERE, base::Bind(&ChromotingHost::LocalLoginSucceeded, this,
454 connection)); 453 connection));
455 return; 454 return;
456 } 455 }
457 456
457 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
Wez 2011/09/10 01:04:29 We don't need this, surely, since the preceding li
Sergey Ulanov 2011/09/10 06:45:58 Right. Added it by mistake.
458
458 protocol::LocalLoginStatus* status = new protocol::LocalLoginStatus(); 459 protocol::LocalLoginStatus* status = new protocol::LocalLoginStatus();
459 status->set_success(true); 460 status->set_success(true);
460 connection->client_stub()->BeginSessionResponse( 461 connection->client_stub()->BeginSessionResponse(
461 status, new DeleteTask<protocol::LocalLoginStatus>(status)); 462 status, new DeleteTask<protocol::LocalLoginStatus>(status));
462 463
463 // Disconnect all other clients. 464 // Disconnect all other clients.
464 // Iterate over a copy of the list of clients, to avoid mutating the list 465 // Iterate over a copy of the list of clients, to avoid mutating the list
465 // while iterating over it. 466 // while iterating over it.
466 ClientList clients_copy(clients_); 467 ClientList clients_copy(clients_);
467 for (ClientList::const_iterator client = clients_copy.begin(); 468 for (ClientList::const_iterator client = clients_copy.begin();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 630
630 for (std::vector<Task*>::iterator it = shutdown_tasks_.begin(); 631 for (std::vector<Task*>::iterator it = shutdown_tasks_.begin();
631 it != shutdown_tasks_.end(); ++it) { 632 it != shutdown_tasks_.end(); ++it) {
632 (*it)->Run(); 633 (*it)->Run();
633 delete *it; 634 delete *it;
634 } 635 }
635 shutdown_tasks_.clear(); 636 shutdown_tasks_.clear();
636 } 637 }
637 638
638 } // namespace remoting 639 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698