diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 01:45:51 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 01:45:51 +0000 |
commit | 1b19d9ee1bc2f78c12a393bf9995532f35e38e4c (patch) | |
tree | 7f7f16e4312515340faed1171b9a5e667d8f67ce /remoting/client | |
parent | 06a83a96034fc5522c0c8f885d5df903549a9f14 (diff) | |
download | chromium_src-1b19d9ee1bc2f78c12a393bf9995532f35e38e4c.zip chromium_src-1b19d9ee1bc2f78c12a393bf9995532f35e38e4c.tar.gz chromium_src-1b19d9ee1bc2f78c12a393bf9995532f35e38e4c.tar.bz2 |
Cope gracefully with scripts querying stats before client has started.
BUG=80185
TEST=Connect sandboxed from ChromeOS, OR add a delay in ConnectSandboxed in a dev build and use it to connect sandboxed.
Review URL: http://codereview.chromium.org/6902011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82973 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client')
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 2 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.h | 1 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_scriptable_object.cc | 11 |
3 files changed, 9 insertions, 5 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index 874e336..270a71e 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -291,6 +291,8 @@ pp::Var ChromotingInstance::GetInstanceObject() { } ChromotingStats* ChromotingInstance::GetStats() { + if (!client_.get()) + return NULL; return client_->GetStats(); } diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h index 3458c78..23d9ca2 100644 --- a/remoting/client/plugin/chromoting_instance.h +++ b/remoting/client/plugin/chromoting_instance.h @@ -87,6 +87,7 @@ class ChromotingInstance : public pp::Instance { void LogDebugInfo(const std::string& info); // Return statistics record by ChromotingClient. + // If no connection is currently active then NULL will be returned. ChromotingStats* GetStats(); private: diff --git a/remoting/client/plugin/chromoting_scriptable_object.cc b/remoting/client/plugin/chromoting_scriptable_object.cc index e2b5fe9..e2c4126 100644 --- a/remoting/client/plugin/chromoting_scriptable_object.cc +++ b/remoting/client/plugin/chromoting_scriptable_object.cc @@ -142,16 +142,17 @@ Var ChromotingScriptableObject::GetProperty(const Var& name, Var* exception) { // If this is a statistics attribute then return the value from // ChromotingStats structure. + ChromotingStats* stats = instance_->GetStats(); if (name.AsString() == kVideoBandwidthAttribute) - return instance_->GetStats()->video_bandwidth()->Rate(); + return stats ? stats->video_bandwidth()->Rate() : Var(); if (name.AsString() == kVideoCaptureLatencyAttribute) - return instance_->GetStats()->video_capture_ms()->Average(); + return stats ? stats->video_capture_ms()->Average() : Var(); if (name.AsString() == kVideoEncodeLatencyAttribute) - return instance_->GetStats()->video_encode_ms()->Average(); + return stats ? stats->video_encode_ms()->Average() : Var(); if (name.AsString() == kVideoDecodeLatencyAttribute) - return instance_->GetStats()->video_decode_ms()->Average(); + return stats ? stats->video_decode_ms()->Average() : Var(); if (name.AsString() == kVideoRenderLatencyAttribute) - return instance_->GetStats()->video_paint_ms()->Average(); + return stats ? stats->video_paint_ms()->Average() : Var(); // TODO(ajwong): This incorrectly return a null object if a function // property is requested. |