diff options
author | hclam@google.com <hclam@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 18:03:31 +0000 |
---|---|---|
committer | hclam@google.com <hclam@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 18:03:31 +0000 |
commit | 778d599df45c985286cd70898187ecf7a6284eeb (patch) | |
tree | e4518f5d17d84f6613e0507c1dddc05ab1ddf23b /remoting/client | |
parent | 6ca1745021ac1b7822eb23a58c3985b2a91b293d (diff) | |
download | chromium_src-778d599df45c985286cd70898187ecf7a6284eeb.zip chromium_src-778d599df45c985286cd70898187ecf7a6284eeb.tar.gz chromium_src-778d599df45c985286cd70898187ecf7a6284eeb.tar.bz2 |
Measure bandwidth for chromoting video channel
Define RunningAverage, TimedRunningAverage and use that to record
video bandwidth.
This doesn't account for overhead of protobuf envelop. However the number
should be small that can be ignored.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/6736009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client')
-rw-r--r-- | remoting/client/chromoting_client.cc | 7 | ||||
-rw-r--r-- | remoting/client/chromoting_client.h | 13 | ||||
-rw-r--r-- | remoting/client/chromoting_stats.cc | 20 | ||||
-rw-r--r-- | remoting/client/chromoting_stats.h | 29 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 4 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.h | 4 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_scriptable_object.cc | 11 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_scriptable_object.h | 5 |
8 files changed, 90 insertions, 3 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index aee6df4..bf1ad39 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -92,6 +92,10 @@ void ChromotingClient::ClientDone() { } } +ChromotingStats* ChromotingClient::GetStats() { + return &stats_; +} + void ChromotingClient::Repaint() { if (message_loop() != MessageLoop::current()) { message_loop()->PostTask( @@ -125,6 +129,9 @@ void ChromotingClient::ProcessVideoPacket(const VideoPacket* packet, return; } + // Record size of the packet for statistics. + stats_.video_bandwidth()->Record(packet->data().size()); + received_packets_.push_back(QueuedVideoPacket(packet, done)); if (!packet_being_processed_) DispatchPacket(); diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h index 83702db..f936ddb 100644 --- a/remoting/client/chromoting_client.h +++ b/remoting/client/chromoting_client.h @@ -4,13 +4,14 @@ // ChromotingClient is the controller for the Client implementation. -#ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_H -#define REMOTING_CLIENT_CHROMOTING_CLIENT_H +#ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_H_ +#define REMOTING_CLIENT_CHROMOTING_CLIENT_H_ #include <list> #include "base/task.h" #include "remoting/client/client_config.h" +#include "remoting/client/chromoting_stats.h" #include "remoting/client/chromoting_view.h" #include "remoting/protocol/client_stub.h" #include "remoting/protocol/connection_to_host.h" @@ -53,6 +54,9 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, void Stop(); void ClientDone(); + // Return the stats recorded by this client. + ChromotingStats* GetStats(); + // Signals that the associated view may need updating. virtual void Repaint(); @@ -125,6 +129,9 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, // safe to dispatch another message. bool packet_being_processed_; + // Record the statistics of the connection. + ChromotingStats stats_; + DISALLOW_COPY_AND_ASSIGN(ChromotingClient); }; @@ -132,4 +139,4 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::ChromotingClient); -#endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H +#endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ diff --git a/remoting/client/chromoting_stats.cc b/remoting/client/chromoting_stats.cc new file mode 100644 index 0000000..33f10173bf --- /dev/null +++ b/remoting/client/chromoting_stats.cc @@ -0,0 +1,20 @@ +// Copyright (c) 2011 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. + +#include "remoting/client/chromoting_stats.h" + +namespace { + +// The default window of bandwidth in seconds. +static const int kBandwidthWindow = 3; + +} // namespace + +namespace remoting { + +ChromotingStats::ChromotingStats() + : video_bandwidth_(base::TimeDelta::FromSeconds(kBandwidthWindow)) { +} + +} // namespace remoting diff --git a/remoting/client/chromoting_stats.h b/remoting/client/chromoting_stats.h new file mode 100644 index 0000000..171c46e --- /dev/null +++ b/remoting/client/chromoting_stats.h @@ -0,0 +1,29 @@ +// Copyright (c) 2011 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. + +// ChromotingStats defines a bundle of performance counters and statistics +// for chromoting. + +#ifndef REMOTING_CLIENT_CHROMOTING_STATS_H_ +#define REMOTING_CLIENT_CHROMOTING_STATS_H_ + +#include "remoting/base/rate_counter.h" + +namespace remoting { + +class ChromotingStats { + public: + ChromotingStats(); + + RateCounter* video_bandwidth() { return &video_bandwidth_; } + + private: + RateCounter video_bandwidth_; + + DISALLOW_COPY_AND_ASSIGN(ChromotingStats); +}; + +} // namespace remoting + +#endif // REMOTING_CLIENT_CHROMOTING_STATS_H_ diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index 45497c5..a23598c 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -277,4 +277,8 @@ pp::Var ChromotingInstance::GetInstanceObject() { return instance_object_; } +ChromotingStats* ChromotingInstance::GetStats() { + return client_->GetStats(); +} + } // namespace remoting diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h index 44c4c18..8c5aee8 100644 --- a/remoting/client/plugin/chromoting_instance.h +++ b/remoting/client/plugin/chromoting_instance.h @@ -39,6 +39,7 @@ class ConnectionToHost; } // namespace protocol class ChromotingClient; +class ChromotingStats; class ClientContext; class InputHandler; class JingleThread; @@ -78,6 +79,9 @@ class ChromotingInstance : public pp::Instance { void LogDebugInfo(const std::string& info); + // Return statistics record by ChromotingClient. + ChromotingStats* GetStats(); + private: FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup); diff --git a/remoting/client/plugin/chromoting_scriptable_object.cc b/remoting/client/plugin/chromoting_scriptable_object.cc index 9a3e2c0..64d6cd5 100644 --- a/remoting/client/plugin/chromoting_scriptable_object.cc +++ b/remoting/client/plugin/chromoting_scriptable_object.cc @@ -8,6 +8,7 @@ #include "base/stringprintf.h" #include "ppapi/cpp/var.h" #include "remoting/client/client_config.h" +#include "remoting/client/chromoting_stats.h" #include "remoting/client/plugin/chromoting_instance.h" #include "remoting/client/plugin/pepper_xmpp_proxy.h" @@ -26,6 +27,7 @@ const char kLoginChallenge[] = "loginChallenge"; const char kSendIq[] = "sendIq"; const char kQualityAttribute[] = "quality"; const char kStatusAttribute[] = "status"; +const char kVideoBandwidthAttribute[] = "videoBandwidth"; } // namespace @@ -69,6 +71,9 @@ void ChromotingScriptableObject::Init() { AddAttribute(kDesktopWidth, Var(0)); AddAttribute(kDesktopHeight, Var(0)); + // Statistics. + AddAttribute(kVideoBandwidthAttribute, Var()); + AddMethod("connect", &ChromotingScriptableObject::DoConnect); AddMethod("connectSandboxed", &ChromotingScriptableObject::DoConnectSandboxed); @@ -126,6 +131,12 @@ Var ChromotingScriptableObject::GetProperty(const Var& name, Var* exception) { return ScriptableObject::GetProperty(name, exception); } + // If this is a statistics attribute then return the value from + // ChromotingStats structure. + if (name.AsString() == kVideoBandwidthAttribute) { + return instance_->GetStats()->video_bandwidth()->Rate(); + } + // TODO(ajwong): This incorrectly return a null object if a function // property is requested. return properties_[iter->second].attribute; diff --git a/remoting/client/plugin/chromoting_scriptable_object.h b/remoting/client/plugin/chromoting_scriptable_object.h index 09ac054..399fb6d 100644 --- a/remoting/client/plugin/chromoting_scriptable_object.h +++ b/remoting/client/plugin/chromoting_scriptable_object.h @@ -13,6 +13,11 @@ // // // Connection status. // readonly attribute unsigned short status; +// +// // Statistics. +// // Video Bandwidth in bytes per second. +// readonly attribute float videoBandwidth; +// // // Constants for connection status. // const unsigned short STATUS_UNKNOWN = 0; // const unsigned short STATUS_CONNECTING = 1; |