Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: remoting/client/plugin/chromoting_scriptable_object.cc

Issue 6902011: Cope gracefully with scripts querying stats before client has started. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit-picked. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/client/plugin/chromoting_instance.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 PropertyNameMap::const_iterator iter = property_names_.find(name.AsString()); 136 PropertyNameMap::const_iterator iter = property_names_.find(name.AsString());
137 137
138 // No property found. 138 // No property found.
139 if (iter == property_names_.end()) { 139 if (iter == property_names_.end()) {
140 return ScriptableObject::GetProperty(name, exception); 140 return ScriptableObject::GetProperty(name, exception);
141 } 141 }
142 142
143 // If this is a statistics attribute then return the value from 143 // If this is a statistics attribute then return the value from
144 // ChromotingStats structure. 144 // ChromotingStats structure.
145 ChromotingStats* stats = instance_->GetStats();
145 if (name.AsString() == kVideoBandwidthAttribute) 146 if (name.AsString() == kVideoBandwidthAttribute)
146 return instance_->GetStats()->video_bandwidth()->Rate(); 147 return stats ? stats->video_bandwidth()->Rate() : Var();
147 if (name.AsString() == kVideoCaptureLatencyAttribute) 148 if (name.AsString() == kVideoCaptureLatencyAttribute)
148 return instance_->GetStats()->video_capture_ms()->Average(); 149 return stats ? stats->video_capture_ms()->Average() : Var();
149 if (name.AsString() == kVideoEncodeLatencyAttribute) 150 if (name.AsString() == kVideoEncodeLatencyAttribute)
150 return instance_->GetStats()->video_encode_ms()->Average(); 151 return stats ? stats->video_encode_ms()->Average() : Var();
151 if (name.AsString() == kVideoDecodeLatencyAttribute) 152 if (name.AsString() == kVideoDecodeLatencyAttribute)
152 return instance_->GetStats()->video_decode_ms()->Average(); 153 return stats ? stats->video_decode_ms()->Average() : Var();
153 if (name.AsString() == kVideoRenderLatencyAttribute) 154 if (name.AsString() == kVideoRenderLatencyAttribute)
154 return instance_->GetStats()->video_paint_ms()->Average(); 155 return stats ? stats->video_paint_ms()->Average() : Var();
155 156
156 // TODO(ajwong): This incorrectly return a null object if a function 157 // TODO(ajwong): This incorrectly return a null object if a function
157 // property is requested. 158 // property is requested.
158 return properties_[iter->second].attribute; 159 return properties_[iter->second].attribute;
159 } 160 }
160 161
161 void ChromotingScriptableObject::GetAllPropertyNames( 162 void ChromotingScriptableObject::GetAllPropertyNames(
162 std::vector<Var>* properties, 163 std::vector<Var>* properties,
163 Var* exception) { 164 Var* exception) {
164 for (size_t i = 0; i < properties_.size(); i++) { 165 for (size_t i = 0; i < properties_.size(); i++) {
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 *exception = Var("response_xml must be a string."); 446 *exception = Var("response_xml must be a string.");
446 return Var(); 447 return Var();
447 } 448 }
448 449
449 xmpp_proxy_->OnIq(args[0].AsString()); 450 xmpp_proxy_->OnIq(args[0].AsString());
450 451
451 return Var(); 452 return Var();
452 } 453 }
453 454
454 } // namespace remoting 455 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698