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 14 matching lines...) Expand all Loading... |
25 const char kDesktopSizeUpdate[] = "desktopSizeUpdate"; | 25 const char kDesktopSizeUpdate[] = "desktopSizeUpdate"; |
26 const char kLoginChallenge[] = "loginChallenge"; | 26 const char kLoginChallenge[] = "loginChallenge"; |
27 const char kSendIq[] = "sendIq"; | 27 const char kSendIq[] = "sendIq"; |
28 const char kQualityAttribute[] = "quality"; | 28 const char kQualityAttribute[] = "quality"; |
29 const char kStatusAttribute[] = "status"; | 29 const char kStatusAttribute[] = "status"; |
30 const char kVideoBandwidthAttribute[] = "videoBandwidth"; | 30 const char kVideoBandwidthAttribute[] = "videoBandwidth"; |
31 const char kVideoCaptureLatencyAttribute[] = "videoCaptureLatency"; | 31 const char kVideoCaptureLatencyAttribute[] = "videoCaptureLatency"; |
32 const char kVideoEncodeLatencyAttribute[] = "videoEncodeLatency"; | 32 const char kVideoEncodeLatencyAttribute[] = "videoEncodeLatency"; |
33 const char kVideoDecodeLatencyAttribute[] = "videoDecodeLatency"; | 33 const char kVideoDecodeLatencyAttribute[] = "videoDecodeLatency"; |
34 const char kVideoRenderLatencyAttribute[] = "videoRenderLatency"; | 34 const char kVideoRenderLatencyAttribute[] = "videoRenderLatency"; |
| 35 const char kRoundTripLatencyAttribute[] = "roundTripLatency"; |
35 | 36 |
36 } // namespace | 37 } // namespace |
37 | 38 |
38 ChromotingScriptableObject::ChromotingScriptableObject( | 39 ChromotingScriptableObject::ChromotingScriptableObject( |
39 ChromotingInstance* instance) | 40 ChromotingInstance* instance) |
40 : instance_(instance) { | 41 : instance_(instance) { |
41 } | 42 } |
42 | 43 |
43 ChromotingScriptableObject::~ChromotingScriptableObject() { | 44 ChromotingScriptableObject::~ChromotingScriptableObject() { |
44 } | 45 } |
(...skipping 29 matching lines...) Expand all Loading... |
74 AddAttribute(kSendIq, Var()); | 75 AddAttribute(kSendIq, Var()); |
75 AddAttribute(kDesktopWidth, Var(0)); | 76 AddAttribute(kDesktopWidth, Var(0)); |
76 AddAttribute(kDesktopHeight, Var(0)); | 77 AddAttribute(kDesktopHeight, Var(0)); |
77 | 78 |
78 // Statistics. | 79 // Statistics. |
79 AddAttribute(kVideoBandwidthAttribute, Var()); | 80 AddAttribute(kVideoBandwidthAttribute, Var()); |
80 AddAttribute(kVideoCaptureLatencyAttribute, Var()); | 81 AddAttribute(kVideoCaptureLatencyAttribute, Var()); |
81 AddAttribute(kVideoEncodeLatencyAttribute, Var()); | 82 AddAttribute(kVideoEncodeLatencyAttribute, Var()); |
82 AddAttribute(kVideoDecodeLatencyAttribute, Var()); | 83 AddAttribute(kVideoDecodeLatencyAttribute, Var()); |
83 AddAttribute(kVideoRenderLatencyAttribute, Var()); | 84 AddAttribute(kVideoRenderLatencyAttribute, Var()); |
| 85 AddAttribute(kRoundTripLatencyAttribute, Var()); |
84 | 86 |
85 AddMethod("connect", &ChromotingScriptableObject::DoConnect); | 87 AddMethod("connect", &ChromotingScriptableObject::DoConnect); |
86 AddMethod("connectSandboxed", | 88 AddMethod("connectSandboxed", |
87 &ChromotingScriptableObject::DoConnectSandboxed); | 89 &ChromotingScriptableObject::DoConnectSandboxed); |
88 AddMethod("disconnect", &ChromotingScriptableObject::DoDisconnect); | 90 AddMethod("disconnect", &ChromotingScriptableObject::DoDisconnect); |
89 AddMethod("submitLoginInfo", &ChromotingScriptableObject::DoSubmitLogin); | 91 AddMethod("submitLoginInfo", &ChromotingScriptableObject::DoSubmitLogin); |
90 AddMethod("onIq", &ChromotingScriptableObject::DoOnIq); | 92 AddMethod("onIq", &ChromotingScriptableObject::DoOnIq); |
91 } | 93 } |
92 | 94 |
93 bool ChromotingScriptableObject::HasProperty(const Var& name, Var* exception) { | 95 bool ChromotingScriptableObject::HasProperty(const Var& name, Var* exception) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 if (name.AsString() == kVideoBandwidthAttribute) | 146 if (name.AsString() == kVideoBandwidthAttribute) |
145 return instance_->GetStats()->video_bandwidth()->Rate(); | 147 return instance_->GetStats()->video_bandwidth()->Rate(); |
146 if (name.AsString() == kVideoCaptureLatencyAttribute) | 148 if (name.AsString() == kVideoCaptureLatencyAttribute) |
147 return instance_->GetStats()->video_capture_ms()->Average(); | 149 return instance_->GetStats()->video_capture_ms()->Average(); |
148 if (name.AsString() == kVideoEncodeLatencyAttribute) | 150 if (name.AsString() == kVideoEncodeLatencyAttribute) |
149 return instance_->GetStats()->video_encode_ms()->Average(); | 151 return instance_->GetStats()->video_encode_ms()->Average(); |
150 if (name.AsString() == kVideoDecodeLatencyAttribute) | 152 if (name.AsString() == kVideoDecodeLatencyAttribute) |
151 return instance_->GetStats()->video_decode_ms()->Average(); | 153 return instance_->GetStats()->video_decode_ms()->Average(); |
152 if (name.AsString() == kVideoRenderLatencyAttribute) | 154 if (name.AsString() == kVideoRenderLatencyAttribute) |
153 return instance_->GetStats()->video_paint_ms()->Average(); | 155 return instance_->GetStats()->video_paint_ms()->Average(); |
| 156 if (name.AsString() == kRoundTripLatencyAttribute) |
| 157 return instance_->GetStats()->round_trip_ms()->Average(); |
154 | 158 |
155 // TODO(ajwong): This incorrectly return a null object if a function | 159 // TODO(ajwong): This incorrectly return a null object if a function |
156 // property is requested. | 160 // property is requested. |
157 return properties_[iter->second].attribute; | 161 return properties_[iter->second].attribute; |
158 } | 162 } |
159 | 163 |
160 void ChromotingScriptableObject::GetAllPropertyNames( | 164 void ChromotingScriptableObject::GetAllPropertyNames( |
161 std::vector<Var>* properties, | 165 std::vector<Var>* properties, |
162 Var* exception) { | 166 Var* exception) { |
163 for (size_t i = 0; i < properties_.size(); i++) { | 167 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."); | 431 *exception = Var("response_xml must be a string."); |
428 return Var(); | 432 return Var(); |
429 } | 433 } |
430 | 434 |
431 xmpp_proxy_->OnIq(args[0].AsString()); | 435 xmpp_proxy_->OnIq(args[0].AsString()); |
432 | 436 |
433 return Var(); | 437 return Var(); |
434 } | 438 } |
435 | 439 |
436 } // namespace remoting | 440 } // namespace remoting |
OLD | NEW |