Show connection type in web-app.

This is mostly boilerplate to get the OnSessionRouteChange notification up to the web-app. The web-app then includes it in the stats panel. In the common case where all channels have the same type, it displays it as "connection: <type>"; if the types differ they are displayed individually.

BUG=134528

Review URL: https://codereview.chromium.org/126123002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243947 0039d316-1c4b-4281-b951-d872f2087c98
parent 3f3a65fe
......@@ -159,6 +159,13 @@ void ChromotingClient::OnConnectionReady(bool ready) {
user_interface_->OnConnectionReady(ready);
}
void ChromotingClient::OnRouteChanged(const std::string& channel_name,
const protocol::TransportRoute& route) {
VLOG(0) << "Using " << protocol::TransportRoute::GetTypeString(route.type)
<< " connection for " << channel_name << " channel";
user_interface_->OnRouteChanged(channel_name, route);
}
void ChromotingClient::OnAuthenticated() {
DCHECK(task_runner_->BelongsToCurrentThread());
......
......@@ -83,6 +83,8 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
protocol::ConnectionToHost::State state,
protocol::ErrorCode error) OVERRIDE;
virtual void OnConnectionReady(bool ready) OVERRIDE;
virtual void OnRouteChanged(const std::string& channel_name,
const protocol::TransportRoute& route) OVERRIDE;
private:
// Called when the connection is authenticated.
......
......@@ -33,6 +33,8 @@ class ClientUserInterface {
virtual void OnConnectionState(protocol::ConnectionToHost::State state,
protocol::ErrorCode error) = 0;
virtual void OnConnectionReady(bool ready) = 0;
virtual void OnRouteChanged(const std::string& channel_name,
const protocol::TransportRoute& route) = 0;
// Passes the final set of capabilities negotiated between the client and host
// to the application.
......
......@@ -216,6 +216,14 @@ void ChromotingJniInstance::OnConnectionReady(bool ready) {
// We ignore this message, since OnConnectionState tells us the same thing.
}
void ChromotingJniInstance::OnRouteChanged(
const std::string& channel_name,
const protocol::TransportRoute& route) {
std::string message = "Channel " + channel_name + " using " +
protocol::TransportRoute::GetTypeString(route.type) + " connection.";
__android_log_print(ANDROID_LOG_INFO, "route", "%s", message.c_str());
}
void ChromotingJniInstance::SetCapabilities(const std::string& capabilities) {
NOTIMPLEMENTED();
}
......
......@@ -80,6 +80,8 @@ class ChromotingJniInstance
protocol::ConnectionToHost::State state,
protocol::ErrorCode error) OVERRIDE;
virtual void OnConnectionReady(bool ready) OVERRIDE;
virtual void OnRouteChanged(const std::string& channel_name,
const protocol::TransportRoute& route) OVERRIDE;
virtual void SetCapabilities(const std::string& capabilities) OVERRIDE;
virtual void SetPairingResponse(
const protocol::PairingResponse& response) OVERRIDE;
......
......@@ -436,6 +436,15 @@ void ChromotingInstance::OnConnectionReady(bool ready) {
PostChromotingMessage("onConnectionReady", data.Pass());
}
void ChromotingInstance::OnRouteChanged(const std::string& channel_name,
const protocol::TransportRoute& route) {
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
std::string message = "Channel " + channel_name + " using " +
protocol::TransportRoute::GetTypeString(route.type) + " connection.";
data->SetString("message", message);
PostChromotingMessage("logDebugMessage", data.Pass());
}
void ChromotingInstance::SetCapabilities(const std::string& capabilities) {
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
data->SetString("capabilities", capabilities);
......
......@@ -116,6 +116,8 @@ class ChromotingInstance :
virtual void OnConnectionState(protocol::ConnectionToHost::State state,
protocol::ErrorCode error) OVERRIDE;
virtual void OnConnectionReady(bool ready) OVERRIDE;
virtual void OnRouteChanged(const std::string& channel_name,
const protocol::TransportRoute& route) OVERRIDE;
virtual void SetCapabilities(const std::string& capabilities) OVERRIDE;
virtual void SetPairingResponse(
const protocol::PairingResponse& pairing_response) OVERRIDE;
......
......@@ -212,8 +212,7 @@ void ConnectionToHost::OnSessionStateChange(
void ConnectionToHost::OnSessionRouteChange(const std::string& channel_name,
const TransportRoute& route) {
VLOG(0) << "Using " << TransportRoute::GetTypeString(route.type)
<< " connection for " << channel_name << " channel";
event_callback_->OnRouteChanged(channel_name, route);
}
void ConnectionToHost::OnSessionChannelReady(const std::string& channel_name,
......
......@@ -77,6 +77,10 @@ class ConnectionToHost : public SignalStrategy::Listener,
// delayed. This is used to indicate in the UI when connection is
// temporarily broken.
virtual void OnConnectionReady(bool ready) = 0;
// Called when the route type (direct vs. STUN vs. proxied) changes.
virtual void OnRouteChanged(const std::string& channel_name,
const protocol::TransportRoute& route) = 0;
};
ConnectionToHost(bool allow_nat_traversal);
......
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