summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 23:21:31 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 23:21:31 +0000
commit300af2dad1d8115cf91727f1e52c00889630da38 (patch)
treee946902445c0c597c8f8f4e0a2ecf3b74fa553de
parent25cd2b0274d866b56c0a8eac07dc449efc074be1 (diff)
downloadchromium_src-300af2dad1d8115cf91727f1e52c00889630da38.zip
chromium_src-300af2dad1d8115cf91727f1e52c00889630da38.tar.gz
chromium_src-300af2dad1d8115cf91727f1e52c00889630da38.tar.bz2
Call SendIq() from plugin asynchronously.
BUG=93951 TEST=Client doesn't crash when disconnecting Review URL: http://codereview.chromium.org/7730002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98139 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/client/plugin/chromoting_scriptable_object.cc41
-rw-r--r--remoting/client/plugin/chromoting_scriptable_object.h8
2 files changed, 25 insertions, 24 deletions
diff --git a/remoting/client/plugin/chromoting_scriptable_object.cc b/remoting/client/plugin/chromoting_scriptable_object.cc
index 7970785..28c6303 100644
--- a/remoting/client/plugin/chromoting_scriptable_object.cc
+++ b/remoting/client/plugin/chromoting_scriptable_object.cc
@@ -272,6 +272,22 @@ void ChromotingScriptableObject::SetDesktopSize(int width, int height) {
LOG(INFO) << "Update desktop size to: " << width << " x " << height;
}
+void ChromotingScriptableObject::SignalLoginChallenge() {
+ plugin_message_loop_->PostTask(
+ FROM_HERE, task_factory_.NewRunnableMethod(
+ &ChromotingScriptableObject::DoSignalLoginChallenge));
+}
+
+void ChromotingScriptableObject::AttachXmppProxy(PepperXmppProxy* xmpp_proxy) {
+ xmpp_proxy_ = xmpp_proxy;
+}
+
+void ChromotingScriptableObject::SendIq(const std::string& message_xml) {
+ plugin_message_loop_->PostTask(
+ FROM_HERE, task_factory_.NewRunnableMethod(
+ &ChromotingScriptableObject::DoSendIq, message_xml));
+}
+
void ChromotingScriptableObject::AddAttribute(const std::string& name,
Var attribute) {
property_names_[name] = properties_.size();
@@ -296,31 +312,22 @@ void ChromotingScriptableObject::SignalDesktopSizeChange() {
&ChromotingScriptableObject::DoSignalDesktopSizeChange));
}
-void ChromotingScriptableObject::SignalLoginChallenge() {
- plugin_message_loop_->PostTask(
- FROM_HERE, task_factory_.NewRunnableMethod(
- &ChromotingScriptableObject::DoSignalLoginChallenge));
-}
-
void ChromotingScriptableObject::DoSignalConnectionInfoChange() {
Var exception;
VarPrivate cb = GetProperty(Var(kConnectionInfoUpdate), &exception);
- // Var() means call the object directly as a function rather than calling
- // a method in the object.
+ // |this| must not be touched after Call() returns.
cb.Call(Var(), &exception);
if (!exception.is_undefined())
LOG(ERROR) << "Exception when invoking connectionInfoUpdate JS callback.";
}
-
void ChromotingScriptableObject::DoSignalDesktopSizeChange() {
Var exception;
VarPrivate cb = GetProperty(Var(kDesktopSizeUpdate), &exception);
- // Var() means call the object directly as a function rather than calling
- // a method in the object.
+ // |this| must not be touched after Call() returns.
cb.Call(Var(), &exception);
if (!exception.is_undefined()) {
@@ -333,24 +340,18 @@ void ChromotingScriptableObject::DoSignalLoginChallenge() {
Var exception;
VarPrivate cb = GetProperty(Var(kLoginChallenge), &exception);
- // Var() means call the object directly as a function rather than calling
- // a method in the object.
+ // |this| must not be touched after Call() returns.
cb.Call(Var(), &exception);
if (!exception.is_undefined())
LOG(ERROR) << "Exception when invoking loginChallenge JS callback.";
}
-void ChromotingScriptableObject::AttachXmppProxy(PepperXmppProxy* xmpp_proxy) {
- xmpp_proxy_ = xmpp_proxy;
-}
-
-void ChromotingScriptableObject::SendIq(const std::string& message_xml) {
+void ChromotingScriptableObject::DoSendIq(const std::string& message_xml) {
Var exception;
VarPrivate cb = GetProperty(Var(kSendIq), &exception);
- // Var() means call the object directly as a function rather than calling
- // a method in the object.
+ // |this| must not be touched after Call() returns.
cb.Call(Var(), Var(message_xml), &exception);
if (!exception.is_undefined())
diff --git a/remoting/client/plugin/chromoting_scriptable_object.h b/remoting/client/plugin/chromoting_scriptable_object.h
index e34f2e1..04ef206 100644
--- a/remoting/client/plugin/chromoting_scriptable_object.h
+++ b/remoting/client/plugin/chromoting_scriptable_object.h
@@ -214,13 +214,13 @@ class ChromotingScriptableObject
void SignalConnectionInfoChange();
void SignalDesktopSizeChange();
- // Calls to these methods are posted to the plugin thread from
- // corresponding Signal*() methods. They actually call JavaScript
- // code. This is necessary becase JavaScript needs to be called with
- // clean stack - JavaScript event handlers may destroy the plugin.
+ // Calls to these methods are posted to the plugin thread so that we
+ // call JavaScript with clean stack. This is necessary because
+ // JavaScript event handlers may destroy the plugin.
void DoSignalConnectionInfoChange();
void DoSignalDesktopSizeChange();
void DoSignalLoginChallenge();
+ void DoSendIq(const std::string& message_xml);
pp::Var DoConnect(const std::vector<pp::Var>& args, pp::Var* exception);
pp::Var DoDisconnect(const std::vector<pp::Var>& args, pp::Var* exception);