Commit 516f86c6 authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

Use P2P Transport API by default.

BUG=51198
TEST=chromoting client still works.

Review URL: http://codereview.chromium.org/7981025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102297 0039d316-1c4b-4281-b951-d872f2087c98
parent 34a14c0e
...@@ -156,7 +156,7 @@ bool ChromotingInstance::Init(uint32_t argc, ...@@ -156,7 +156,7 @@ bool ChromotingInstance::Init(uint32_t argc,
return true; return true;
} }
void ChromotingInstance::Connect(const ClientConfig& config, bool use_p2p_api) { void ChromotingInstance::Connect(const ClientConfig& config) {
DCHECK(plugin_message_loop_->BelongsToCurrentThread()); DCHECK(plugin_message_loop_->BelongsToCurrentThread());
// This can only happen at initialization if the Javascript connect call // This can only happen at initialization if the Javascript connect call
...@@ -165,42 +165,13 @@ void ChromotingInstance::Connect(const ClientConfig& config, bool use_p2p_api) { ...@@ -165,42 +165,13 @@ void ChromotingInstance::Connect(const ClientConfig& config, bool use_p2p_api) {
if (!initial_policy_received_) { if (!initial_policy_received_) {
LOG(INFO) << "Delaying connect until initial policy is read."; LOG(INFO) << "Delaying connect until initial policy is read.";
delayed_connect_.reset( delayed_connect_.reset(
task_factory_.NewRunnableMethod(&ChromotingInstance::Connect, task_factory_.NewRunnableMethod(&ChromotingInstance::Connect, config));
config, use_p2p_api));
return; return;
} }
webkit::ppapi::PluginInstance* plugin_instance = host_connection_.reset(new protocol::ConnectionToHost(
webkit::ppapi::ResourceTracker::Get()->GetInstance(pp_instance()); context_.network_message_loop(), this, NULL, NULL, NULL, NULL,
enable_client_nat_traversal_));
if (use_p2p_api) {
host_connection_.reset(new protocol::ConnectionToHost(
context_.network_message_loop(), this, NULL, NULL, NULL, NULL,
enable_client_nat_traversal_));
} else {
content::P2PSocketDispatcher* socket_dispatcher =
plugin_instance->delegate()->GetP2PSocketDispatcher();
content::IpcNetworkManager* network_manager = NULL;
content::IpcPacketSocketFactory* socket_factory = NULL;
HostResolverFactory* host_resolver_factory = NULL;
PortAllocatorSessionFactory* session_factory =
CreatePepperPortAllocatorSessionFactory(
this, plugin_message_loop_, context_.network_message_loop());
// If we don't have socket dispatcher for IPC (e.g. P2P API is
// disabled), then JingleSessionManager will try to use physical sockets.
if (socket_dispatcher) {
VLOG(1) << "Creating IpcNetworkManager and IpcPacketSocketFactory.";
network_manager = new content::IpcNetworkManager(socket_dispatcher);
socket_factory = new content::IpcPacketSocketFactory(socket_dispatcher);
host_resolver_factory = new IpcHostResolverFactory(socket_dispatcher);
}
host_connection_.reset(new protocol::ConnectionToHost(
context_.network_message_loop(), NULL, network_manager, socket_factory,
host_resolver_factory, session_factory, enable_client_nat_traversal_));
}
input_handler_.reset(new PepperInputHandler(&context_, input_handler_.reset(new PepperInputHandler(&context_,
host_connection_.get(), host_connection_.get(),
......
...@@ -77,7 +77,7 @@ class ChromotingInstance : public pp::InstancePrivate { ...@@ -77,7 +77,7 @@ class ChromotingInstance : public pp::InstancePrivate {
ChromotingScriptableObject* GetScriptableObject(); ChromotingScriptableObject* GetScriptableObject();
// Initiates and cancels connections. // Initiates and cancels connections.
void Connect(const ClientConfig& config, bool use_p2p_api); void Connect(const ClientConfig& config);
void Disconnect(); void Disconnect();
// Called by ChromotingScriptableObject to provide username and password. // Called by ChromotingScriptableObject to provide username and password.
......
...@@ -365,7 +365,6 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, ...@@ -365,7 +365,6 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args,
// host_public_key // host_public_key
// client_jid // client_jid
// access_code (optional) // access_code (optional)
// use_p2p_api (optional)
unsigned int arg = 0; unsigned int arg = 0;
if (!args[arg].is_string()) { if (!args[arg].is_string()) {
*exception = Var("The host_jid must be a string."); *exception = Var("The host_jid must be a string.");
...@@ -394,15 +393,6 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, ...@@ -394,15 +393,6 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args,
access_code = args[arg++].AsString(); access_code = args[arg++].AsString();
} }
bool use_p2p_api = false;
if (args.size() > arg) {
if (!args[arg].is_bool()) {
*exception = Var("The use_p2p_api parameter must be a boolean.");
return Var();
}
use_p2p_api = args[arg++].AsBool();
}
if (args.size() != arg) { if (args.size() != arg) {
*exception = Var("Too many agruments passed to connect()."); *exception = Var("Too many agruments passed to connect().");
return Var(); return Var();
...@@ -416,7 +406,7 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, ...@@ -416,7 +406,7 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args,
config.host_jid = host_jid; config.host_jid = host_jid;
config.host_public_key = host_public_key; config.host_public_key = host_public_key;
config.access_code = access_code; config.access_code = access_code;
instance_->Connect(config, use_p2p_api); instance_->Connect(config);
return Var(); return Var();
} }
......
...@@ -254,13 +254,8 @@ remoting.ClientSession.prototype.connectPluginToWcs_ = ...@@ -254,13 +254,8 @@ remoting.ClientSession.prototype.connectPluginToWcs_ =
remoting.debug.log('Receiving Iq: ' + stanza); remoting.debug.log('Receiving Iq: ' + stanza);
that.plugin.onIq(stanza); that.plugin.onIq(stanza);
}); });
if (remoting.useP2pApi) { that.plugin.connect(this.hostJid, this.hostPublicKey, this.clientJid,
this.plugin.connect(this.hostJid, this.hostPublicKey, this.clientJid, this.accessCode);
this.accessCode, remoting.useP2pApi);
} else {
that.plugin.connect(this.hostJid, this.hostPublicKey, this.clientJid,
this.accessCode);
}
}; };
/** /**
......
...@@ -54,14 +54,6 @@ remoting.ClientError = { ...@@ -54,14 +54,6 @@ remoting.ClientError = {
*/ */
remoting.scaleToFit = false; remoting.scaleToFit = false;
/**
* Whether or not the P2P Transport API should be used. This flag is an interim
* measure to allow testing by early adopters, and will be removed when P2P API
* is enabled by default. See http://crbug.com/51198 for details.
* @type {boolean}
*/
remoting.useP2pApi = false;
// Constants representing keys used for storing persistent application state. // Constants representing keys used for storing persistent application state.
var KEY_APP_MODE_ = 'remoting-app-mode'; var KEY_APP_MODE_ = 'remoting-app-mode';
var KEY_EMAIL_ = 'remoting-email'; var KEY_EMAIL_ = 'remoting-email';
...@@ -180,8 +172,6 @@ remoting.init = function() { ...@@ -180,8 +172,6 @@ remoting.init = function() {
document.getElementById('client-footer-text-cros').id = document.getElementById('client-footer-text-cros').id =
'client-footer-text'; 'client-footer-text';
} }
remoting.useP2pApi = !(window.localStorage.getItem(KEY_USE_P2P_API_) == null);
} }
/** /**
...@@ -729,15 +719,6 @@ remoting.checkHotkeys = function(event) { ...@@ -729,15 +719,6 @@ remoting.checkHotkeys = function(event) {
} }
} }
remoting.setUseP2pApi = function(use) {
remoting.useP2pApi = use;
if (use) {
window.localStorage.setItem(KEY_USE_P2P_API_, 'true');
} else {
window.localStorage.removeItem(KEY_USE_P2P_API_);
}
}
function recenterToolbar_() { function recenterToolbar_() {
var toolbar = document.getElementById('session-toolbar'); var toolbar = document.getElementById('session-toolbar');
var toolbarX = (window.innerWidth - toolbar.clientWidth) / 2; var toolbarX = (window.innerWidth - toolbar.clientWidth) / 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment