diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-04 01:10:11 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-04 01:10:11 +0000 |
commit | 988dfc3c6ce0ee36d607a957c2447fa45488c745 (patch) | |
tree | 03ae5fcdfeda3fd64376545372beea4b8e644aab /remoting/host/remoting_me2me_host.cc | |
parent | 7362b51c76a0b6c0f7ed21382333ef4aed1b4a88 (diff) | |
download | chromium_src-988dfc3c6ce0ee36d607a957c2447fa45488c745.zip chromium_src-988dfc3c6ce0ee36d607a957c2447fa45488c745.tar.gz chromium_src-988dfc3c6ce0ee36d607a957c2447fa45488c745.tar.bz2 |
Move signaling connection creation out of ChromotingHost.
Also removed signaling-related events from ChromotingHostObserver interface
and changes host observers to listen for notifications from SignalStrategy
directly.
BUG=107276
Review URL: http://codereview.chromium.org/9004050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/remoting_me2me_host.cc')
-rw-r--r-- | remoting/host/remoting_me2me_host.cc | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 8a10c7b..c37fc71 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -29,6 +29,7 @@ #include "remoting/host/heartbeat_sender.h" #include "remoting/host/host_config.h" #include "remoting/host/json_host_config.h" +#include "remoting/jingle_glue/xmpp_signal_strategy.h" #if defined(TOOLKIT_USES_GTK) #include "ui/gfx/gtk_util.h" @@ -91,22 +92,50 @@ class HostProcess { return 1; } + // Use an XMPP connection to the Talk network for session signalling. + std::string xmpp_login; + std::string xmpp_auth_token; + if (!auth_config_->GetString(kXmppLoginConfigPath, &xmpp_login) || + !auth_config_->GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token)) { + LOG(ERROR) << "XMPP credentials are not defined in the config."; + return 1; + } + + std::string xmpp_auth_service; + if (!auth_config_->GetString(remoting::kXmppAuthServiceConfigPath, + &xmpp_auth_service)) { + // For the me2me host, we assume we use the ClientLogin token for + // chromiumsync because we do not have an HTTP stack with which we can + // easily request an OAuth2 access token even if we had a RefreshToken for + // the account. + xmpp_auth_service = remoting::kChromotingTokenDefaultServiceName; + } + + // Create and start XMPP connection. + scoped_ptr<SignalStrategy> signal_strategy( + new XmppSignalStrategy(context.jingle_thread(), xmpp_login, + xmpp_auth_token, xmpp_auth_service)); + // Create the DesktopEnvironment and ChromotingHost. scoped_ptr<DesktopEnvironment> desktop_environment( DesktopEnvironment::Create(&context)); - host_ = ChromotingHost::Create( - &context, host_config_, desktop_environment.get(), false); + host_ = new ChromotingHost( + &context, host_config_, signal_strategy.get(), + desktop_environment.get(), false); // Initialize HeartbeatSender. scoped_ptr<remoting::HeartbeatSender> heartbeat_sender( - new remoting::HeartbeatSender(context.network_message_loop(), - host_config_)); - if (!heartbeat_sender->Init()) { + new remoting::HeartbeatSender()); + if (!heartbeat_sender->Init(signal_strategy.get(), host_config_)) { context.Stop(); return 1; } - host_->AddStatusObserver(heartbeat_sender.get()); + + // Post a task to start XMPP connection. + context.network_message_loop()->PostTask( + FROM_HERE, base::Bind(&remoting::SignalStrategy::Connect, + base::Unretained(signal_strategy.get()))); // Run the ChromotingHost until the shutdown task is executed. host_->Start(); @@ -134,13 +163,13 @@ class HostProcess { bool LoadConfig(base::MessageLoopProxy* message_loop_proxy) { host_config_ = new remoting::JsonHostConfig(host_config_path_, message_loop_proxy); - scoped_refptr<remoting::JsonHostConfig> auth_config = + auth_config_ = new remoting::JsonHostConfig(auth_config_path_, message_loop_proxy); std::string failed_path; if (!host_config_->Read()) { failed_path = host_config_path_.value(); - } else if (!auth_config->Read()) { + } else if (!auth_config_->Read()) { failed_path = auth_config_path_.value(); } if (!failed_path.empty()) { @@ -148,25 +177,13 @@ class HostProcess { return false; } - // Copy the needed keys from |auth_config| into |host_config|. - std::string value; - auth_config->GetString(kXmppAuthTokenConfigPath, &value); - host_config_->SetString(kXmppAuthTokenConfigPath, value); - auth_config->GetString(kXmppLoginConfigPath, &value); - host_config_->SetString(kXmppLoginConfigPath, value); - - // For the Me2Me host, we assume we always use the ClientLogin token for - // chromiumsync because we do not have an HTTP stack with which we can - // easily request an OAuth2 access token even if we had a RefreshToken for - // the account. - host_config_->SetString(kXmppAuthServiceConfigPath, - kChromotingTokenDefaultServiceName); return true; } FilePath auth_config_path_; FilePath host_config_path_; + scoped_refptr<remoting::JsonHostConfig> auth_config_; scoped_refptr<remoting::JsonHostConfig> host_config_; scoped_refptr<ChromotingHost> host_; |