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

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

Issue 10454018: MessageLoopProxy cleanups in remoting client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/string_split.h" 11 #include "base/string_split.h"
12 #include "ppapi/cpp/private/var_private.h" 12 #include "ppapi/cpp/private/var_private.h"
13 #include "remoting/base/auth_token_util.h" 13 #include "remoting/base/auth_token_util.h"
14 #include "remoting/client/client_config.h" 14 #include "remoting/client/client_config.h"
15 #include "remoting/client/chromoting_stats.h" 15 #include "remoting/client/chromoting_stats.h"
16 #include "remoting/client/plugin/chromoting_instance.h" 16 #include "remoting/client/plugin/chromoting_instance.h"
17 #include "remoting/client/plugin/pepper_xmpp_proxy.h" 17 #include "remoting/client/plugin/pepper_xmpp_proxy.h"
18 18
19 using pp::Var; 19 using pp::Var;
20 using pp::VarPrivate; 20 using pp::VarPrivate;
(...skipping 16 matching lines...) Expand all
37 const char kVideoFrameRateAttribute[] = "videoFrameRate"; 37 const char kVideoFrameRateAttribute[] = "videoFrameRate";
38 const char kVideoCaptureLatencyAttribute[] = "videoCaptureLatency"; 38 const char kVideoCaptureLatencyAttribute[] = "videoCaptureLatency";
39 const char kVideoEncodeLatencyAttribute[] = "videoEncodeLatency"; 39 const char kVideoEncodeLatencyAttribute[] = "videoEncodeLatency";
40 const char kVideoDecodeLatencyAttribute[] = "videoDecodeLatency"; 40 const char kVideoDecodeLatencyAttribute[] = "videoDecodeLatency";
41 const char kVideoRenderLatencyAttribute[] = "videoRenderLatency"; 41 const char kVideoRenderLatencyAttribute[] = "videoRenderLatency";
42 const char kRoundTripLatencyAttribute[] = "roundTripLatency"; 42 const char kRoundTripLatencyAttribute[] = "roundTripLatency";
43 43
44 } // namespace 44 } // namespace
45 45
46 ChromotingScriptableObject::ChromotingScriptableObject( 46 ChromotingScriptableObject::ChromotingScriptableObject(
47 ChromotingInstance* instance, base::MessageLoopProxy* plugin_message_loop) 47 ChromotingInstance* instance,
48 base::SingleThreadTaskRunner* plugin_task_runner)
48 : instance_(instance), 49 : instance_(instance),
49 plugin_message_loop_(plugin_message_loop) { 50 plugin_task_runner_(plugin_task_runner) {
50 } 51 }
51 52
52 ChromotingScriptableObject::~ChromotingScriptableObject() { 53 ChromotingScriptableObject::~ChromotingScriptableObject() {
53 } 54 }
54 55
55 void ChromotingScriptableObject::Init() { 56 void ChromotingScriptableObject::Init() {
56 // Property addition order should match the interface description at the 57 // Property addition order should match the interface description at the
57 // top of chromoting_scriptable_object.h. 58 // top of chromoting_scriptable_object.h.
58 59
59 AddAttribute(kApiVersionAttribute, Var(ChromotingInstance::kApiVersion)); 60 AddAttribute(kApiVersionAttribute, Var(ChromotingInstance::kApiVersion));
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 signal = true; 248 signal = true;
248 } 249 }
249 250
250 int error_index = property_names_[kErrorAttribute]; 251 int error_index = property_names_[kErrorAttribute];
251 if (properties_[error_index].attribute.AsInt() != error) { 252 if (properties_[error_index].attribute.AsInt() != error) {
252 properties_[error_index].attribute = Var(error); 253 properties_[error_index].attribute = Var(error);
253 signal = true; 254 signal = true;
254 } 255 }
255 256
256 if (signal) { 257 if (signal) {
257 plugin_message_loop_->PostTask( 258 plugin_task_runner_->PostTask(
258 FROM_HERE, base::Bind( 259 FROM_HERE, base::Bind(
259 &ChromotingScriptableObject::DoSignalConnectionInfoChange, 260 &ChromotingScriptableObject::DoSignalConnectionInfoChange,
260 AsWeakPtr(), state, error)); 261 AsWeakPtr(), state, error));
261 } 262 }
262 } 263 }
263 264
264 void ChromotingScriptableObject::LogDebugInfo(const std::string& info) { 265 void ChromotingScriptableObject::LogDebugInfo(const std::string& info) {
265 Var exception; 266 Var exception;
266 VarPrivate cb = GetProperty(Var(kDebugInfo), &exception); 267 VarPrivate cb = GetProperty(Var(kDebugInfo), &exception);
267 268
(...skipping 10 matching lines...) Expand all
278 } 279 }
279 280
280 void ChromotingScriptableObject::SetDesktopSize(int width, int height) { 281 void ChromotingScriptableObject::SetDesktopSize(int width, int height) {
281 int width_index = property_names_[kDesktopWidth]; 282 int width_index = property_names_[kDesktopWidth];
282 int height_index = property_names_[kDesktopHeight]; 283 int height_index = property_names_[kDesktopHeight];
283 284
284 if (properties_[width_index].attribute.AsInt() != width || 285 if (properties_[width_index].attribute.AsInt() != width ||
285 properties_[height_index].attribute.AsInt() != height) { 286 properties_[height_index].attribute.AsInt() != height) {
286 properties_[width_index].attribute = Var(width); 287 properties_[width_index].attribute = Var(width);
287 properties_[height_index].attribute = Var(height); 288 properties_[height_index].attribute = Var(height);
288 plugin_message_loop_->PostTask( 289 plugin_task_runner_->PostTask(
289 FROM_HERE, base::Bind( 290 FROM_HERE, base::Bind(
290 &ChromotingScriptableObject::DoSignalDesktopSizeChange, 291 &ChromotingScriptableObject::DoSignalDesktopSizeChange,
291 AsWeakPtr())); 292 AsWeakPtr()));
292 } 293 }
293 294
294 VLOG(1) << "Update desktop size to: " << width << " x " << height; 295 VLOG(1) << "Update desktop size to: " << width << " x " << height;
295 } 296 }
296 297
297 void ChromotingScriptableObject::SendIq(const std::string& message_xml) { 298 void ChromotingScriptableObject::SendIq(const std::string& message_xml) {
298 plugin_message_loop_->PostTask( 299 plugin_task_runner_->PostTask(
299 FROM_HERE, base::Bind( 300 FROM_HERE, base::Bind(
300 &ChromotingScriptableObject::DoSendIq, AsWeakPtr(), message_xml)); 301 &ChromotingScriptableObject::DoSendIq, AsWeakPtr(), message_xml));
301 } 302 }
302 303
303 void ChromotingScriptableObject::AddAttribute(const std::string& name, 304 void ChromotingScriptableObject::AddAttribute(const std::string& name,
304 const Var& attribute) { 305 const Var& attribute) {
305 property_names_[name] = properties_.size(); 306 property_names_[name] = properties_.size();
306 properties_.push_back(PropertyDescriptor(name, attribute)); 307 properties_.push_back(PropertyDescriptor(name, attribute));
307 } 308 }
308 309
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 const std::vector<pp::Var>& args, pp::Var* exception) { 463 const std::vector<pp::Var>& args, pp::Var* exception) {
463 if (args.size() != 0) { 464 if (args.size() != 0) {
464 *exception = Var("Usage: DoReleaseAllKeys()"); 465 *exception = Var("Usage: DoReleaseAllKeys()");
465 return Var(); 466 return Var();
466 } 467 }
467 instance_->ReleaseAllKeys(); 468 instance_->ReleaseAllKeys();
468 return Var(); 469 return Var();
469 } 470 }
470 471
471 } // namespace remoting 472 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698