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

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

Issue 8573024: Clean up client state callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unused error code. Created 9 years, 1 month 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) 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/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 // TODO(wez): Remove this when crbug.com/86353 is complete. 9 // TODO(wez): Remove this when crbug.com/86353 is complete.
10 #include "ppapi/cpp/private/var_private.h" 10 #include "ppapi/cpp/private/var_private.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 signal = true; 239 signal = true;
240 } 240 }
241 241
242 int error_index = property_names_[kErrorAttribute]; 242 int error_index = property_names_[kErrorAttribute];
243 if (properties_[error_index].attribute.AsInt() != error) { 243 if (properties_[error_index].attribute.AsInt() != error) {
244 properties_[error_index].attribute = Var(error); 244 properties_[error_index].attribute = Var(error);
245 signal = true; 245 signal = true;
246 } 246 }
247 247
248 if (signal) 248 if (signal)
249 SignalConnectionInfoChange(); 249 SignalConnectionInfoChange(status, error);
250 } 250 }
251 251
252 void ChromotingScriptableObject::LogDebugInfo(const std::string& info) { 252 void ChromotingScriptableObject::LogDebugInfo(const std::string& info) {
253 Var exception; 253 Var exception;
254 VarPrivate cb = GetProperty(Var(kDebugInfo), &exception); 254 VarPrivate cb = GetProperty(Var(kDebugInfo), &exception);
255 255
256 // Var() means call the object directly as a function rather than calling 256 // Var() means call the object directly as a function rather than calling
257 // a method in the object. 257 // a method in the object.
258 cb.Call(Var(), Var(info), &exception); 258 cb.Call(Var(), Var(info), &exception);
259 259
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 property_names_[name] = properties_.size(); 292 property_names_[name] = properties_.size();
293 properties_.push_back(PropertyDescriptor(name, attribute)); 293 properties_.push_back(PropertyDescriptor(name, attribute));
294 } 294 }
295 295
296 void ChromotingScriptableObject::AddMethod(const std::string& name, 296 void ChromotingScriptableObject::AddMethod(const std::string& name,
297 MethodHandler handler) { 297 MethodHandler handler) {
298 property_names_[name] = properties_.size(); 298 property_names_[name] = properties_.size();
299 properties_.push_back(PropertyDescriptor(name, handler)); 299 properties_.push_back(PropertyDescriptor(name, handler));
300 } 300 }
301 301
302 void ChromotingScriptableObject::SignalConnectionInfoChange() { 302 void ChromotingScriptableObject::SignalConnectionInfoChange(int status,
303 int error) {
303 plugin_message_loop_->PostTask( 304 plugin_message_loop_->PostTask(
304 FROM_HERE, task_factory_.NewRunnableMethod( 305 FROM_HERE, task_factory_.NewRunnableMethod(
305 &ChromotingScriptableObject::DoSignalConnectionInfoChange)); 306 &ChromotingScriptableObject::DoSignalConnectionInfoChange,
307 status, error));
306 } 308 }
307 309
308 void ChromotingScriptableObject::SignalDesktopSizeChange() { 310 void ChromotingScriptableObject::SignalDesktopSizeChange() {
309 plugin_message_loop_->PostTask( 311 plugin_message_loop_->PostTask(
310 FROM_HERE, task_factory_.NewRunnableMethod( 312 FROM_HERE, task_factory_.NewRunnableMethod(
311 &ChromotingScriptableObject::DoSignalDesktopSizeChange)); 313 &ChromotingScriptableObject::DoSignalDesktopSizeChange));
312 } 314 }
313 315
314 void ChromotingScriptableObject::DoSignalConnectionInfoChange() { 316 void ChromotingScriptableObject::DoSignalConnectionInfoChange(int status,
317 int error) {
315 Var exception; 318 Var exception;
316 VarPrivate cb = GetProperty(Var(kConnectionInfoUpdate), &exception); 319 VarPrivate cb = GetProperty(Var(kConnectionInfoUpdate), &exception);
317 320
318 // |this| must not be touched after Call() returns. 321 // |this| must not be touched after Call() returns.
319 cb.Call(Var(), &exception); 322 cb.Call(Var(), Var(status), Var(error), &exception);
Sergey Ulanov 2011/11/16 23:08:12 Will this work with an older version of the webapp
Jamie 2011/11/17 22:06:18 Yes, I think so. Certainly the converse is true--i
320 323
321 if (!exception.is_undefined()) 324 if (!exception.is_undefined())
322 LOG(ERROR) << "Exception when invoking connectionInfoUpdate JS callback."; 325 LOG(ERROR) << "Exception when invoking connectionInfoUpdate JS callback.";
323 } 326 }
324 327
325 void ChromotingScriptableObject::DoSignalDesktopSizeChange() { 328 void ChromotingScriptableObject::DoSignalDesktopSizeChange() {
326 Var exception; 329 Var exception;
327 VarPrivate cb = GetProperty(Var(kDesktopSizeUpdate), &exception); 330 VarPrivate cb = GetProperty(Var(kDesktopSizeUpdate), &exception);
328 331
329 // |this| must not be touched after Call() returns. 332 // |this| must not be touched after Call() returns.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 const std::vector<pp::Var>& args, pp::Var* exception) { 447 const std::vector<pp::Var>& args, pp::Var* exception) {
445 if (args.size() != 0) { 448 if (args.size() != 0) {
446 *exception = Var("Usage: DoReleaseAllKeys()"); 449 *exception = Var("Usage: DoReleaseAllKeys()");
447 return Var(); 450 return Var();
448 } 451 }
449 instance_->ReleaseAllKeys(); 452 instance_->ReleaseAllKeys();
450 return Var(); 453 return Var();
451 } 454 }
452 455
453 } // namespace remoting 456 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698