| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/client/plugin/chromoting_scriptable_object.h" | 5 #include "remoting/client/plugin/chromoting_scriptable_object.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "ppapi/cpp/var.h" | 9 #include "ppapi/cpp/var.h" |
| 10 #include "remoting/client/client_config.h" | 10 #include "remoting/client/client_config.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 PropertyNameMap::const_iterator iter = property_names_.find(name.AsString()); | 135 PropertyNameMap::const_iterator iter = property_names_.find(name.AsString()); |
| 136 | 136 |
| 137 // No property found. | 137 // No property found. |
| 138 if (iter == property_names_.end()) { | 138 if (iter == property_names_.end()) { |
| 139 return ScriptableObject::GetProperty(name, exception); | 139 return ScriptableObject::GetProperty(name, exception); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // If this is a statistics attribute then return the value from | 142 // If this is a statistics attribute then return the value from |
| 143 // ChromotingStats structure. | 143 // ChromotingStats structure. |
| 144 ChromotingStats* stats = instance_->GetStats(); |
| 144 if (name.AsString() == kVideoBandwidthAttribute) | 145 if (name.AsString() == kVideoBandwidthAttribute) |
| 145 return instance_->GetStats()->video_bandwidth()->Rate(); | 146 return stats ? stats->video_bandwidth()->Rate() : Var(); |
| 146 if (name.AsString() == kVideoCaptureLatencyAttribute) | 147 if (name.AsString() == kVideoCaptureLatencyAttribute) |
| 147 return instance_->GetStats()->video_capture_ms()->Average(); | 148 return stats ? stats->video_capture_ms()->Average() : Var(); |
| 148 if (name.AsString() == kVideoEncodeLatencyAttribute) | 149 if (name.AsString() == kVideoEncodeLatencyAttribute) |
| 149 return instance_->GetStats()->video_encode_ms()->Average(); | 150 return stats ? stats->video_encode_ms()->Average() : Var(); |
| 150 if (name.AsString() == kVideoDecodeLatencyAttribute) | 151 if (name.AsString() == kVideoDecodeLatencyAttribute) |
| 151 return instance_->GetStats()->video_decode_ms()->Average(); | 152 return stats ? stats->video_decode_ms()->Average() : Var(); |
| 152 if (name.AsString() == kVideoRenderLatencyAttribute) | 153 if (name.AsString() == kVideoRenderLatencyAttribute) |
| 153 return instance_->GetStats()->video_paint_ms()->Average(); | 154 return stats ? stats->video_paint_ms()->Average() : Var(); |
| 154 | 155 |
| 155 // TODO(ajwong): This incorrectly return a null object if a function | 156 // TODO(ajwong): This incorrectly return a null object if a function |
| 156 // property is requested. | 157 // property is requested. |
| 157 return properties_[iter->second].attribute; | 158 return properties_[iter->second].attribute; |
| 158 } | 159 } |
| 159 | 160 |
| 160 void ChromotingScriptableObject::GetAllPropertyNames( | 161 void ChromotingScriptableObject::GetAllPropertyNames( |
| 161 std::vector<Var>* properties, | 162 std::vector<Var>* properties, |
| 162 Var* exception) { | 163 Var* exception) { |
| 163 for (size_t i = 0; i < properties_.size(); i++) { | 164 for (size_t i = 0; i < properties_.size(); i++) { |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 *exception = Var("response_xml must be a string."); | 428 *exception = Var("response_xml must be a string."); |
| 428 return Var(); | 429 return Var(); |
| 429 } | 430 } |
| 430 | 431 |
| 431 xmpp_proxy_->OnIq(args[0].AsString()); | 432 xmpp_proxy_->OnIq(args[0].AsString()); |
| 432 | 433 |
| 433 return Var(); | 434 return Var(); |
| 434 } | 435 } |
| 435 | 436 |
| 436 } // namespace remoting | 437 } // namespace remoting |
| OLD | NEW |