summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-21 17:24:20 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-21 17:24:20 +0000
commita8e72141bdee8251279cb47a7e55cb70ab878dd3 (patch)
treee21a602391c211e0b488a2401a45768824b4c2ca /ppapi
parent0199dbca65797698b41a7480612b52fcbeed3b78 (diff)
downloadchromium_src-a8e72141bdee8251279cb47a7e55cb70ab878dd3.zip
chromium_src-a8e72141bdee8251279cb47a7e55cb70ab878dd3.tar.gz
chromium_src-a8e72141bdee8251279cb47a7e55cb70ab878dd3.tar.bz2
PPAPI: Make the proxy not issue redundant or stale calls to RequestSurroundingText().
(The problem still exists in-process, and will be taken care of separately.) BUG=143386 Review URL: https://chromiumcodereview.appspot.com/10823418 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152584 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/proxy/plugin_dispatcher.cc4
-rw-r--r--ppapi/proxy/plugin_dispatcher.h7
-rw-r--r--ppapi/proxy/ppb_instance_proxy.cc33
-rw-r--r--ppapi/proxy/ppb_instance_proxy.h3
4 files changed, 43 insertions, 4 deletions
diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc
index fc51785..4c50653 100644
--- a/ppapi/proxy/plugin_dispatcher.cc
+++ b/ppapi/proxy/plugin_dispatcher.cc
@@ -47,7 +47,9 @@ DispatcherSet* g_live_dispatchers = NULL;
} // namespace
InstanceData::InstanceData()
- : flash_fullscreen(PP_FALSE) {
+ : flash_fullscreen(PP_FALSE),
+ is_request_surrounding_text_pending(false),
+ should_do_request_surrounding_text(false) {
}
InstanceData::~InstanceData() {
diff --git a/ppapi/proxy/plugin_dispatcher.h b/ppapi/proxy/plugin_dispatcher.h
index d7c118e..5cf1967 100644
--- a/ppapi/proxy/plugin_dispatcher.h
+++ b/ppapi/proxy/plugin_dispatcher.h
@@ -47,6 +47,13 @@ struct InstanceData {
// When non-NULL, indicates the callback to execute when mouse lock is lost.
scoped_refptr<TrackedCallback> mouse_lock_callback;
+
+ // Calls to |RequestSurroundingText()| are done by posted tasks. Track whether
+ // a) a task is pending, to avoid redundant calls, and b) whether we should
+ // actually call |RequestSurroundingText()|, to avoid stale calls (i.e.,
+ // calling when we shouldn't).
+ bool is_request_surrounding_text_pending;
+ bool should_do_request_surrounding_text;
};
class PPAPI_PROXY_EXPORT PluginDispatcher
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index 698c001..4960b1e 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -48,6 +48,12 @@ void RequestSurroundingText(PP_Instance instance) {
if (!dispatcher)
return; // Instance has gone away while message was pending.
+ InstanceData* data = dispatcher->GetInstanceData(instance);
+ DCHECK(data); // Should have it, since we still have a dispatcher.
+ data->is_request_surrounding_text_pending = false;
+ if (!data->should_do_request_surrounding_text)
+ return;
+
// Just fake out a RequestSurroundingText message to the proxy for the PPP
// interface.
InterfaceProxy* proxy = dispatcher->GetInterfaceProxy(API_ID_PPP_TEXT_INPUT);
@@ -589,6 +595,7 @@ PP_Bool PPB_Instance_Proxy::GetDefaultPrintSettings(
void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance,
PP_TextInput_Type type) {
+ CancelAnyPendingRequestSurroundingText(instance);
dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTextInputType(
API_ID_PPB_INSTANCE, instance, type));
}
@@ -601,6 +608,7 @@ void PPB_Instance_Proxy::UpdateCaretPosition(PP_Instance instance,
}
void PPB_Instance_Proxy::CancelCompositionText(PP_Instance instance) {
+ CancelAnyPendingRequestSurroundingText(instance);
dispatcher()->Send(new PpapiHostMsg_PPBInstance_CancelCompositionText(
API_ID_PPB_INSTANCE, instance));
}
@@ -616,9 +624,19 @@ void PPB_Instance_Proxy::SelectionChanged(PP_Instance instance) {
// we'll need to reevanuate whether we want to do the round trip instead.
//
// Be careful to post a task to avoid reentering the plugin.
- MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&RequestSurroundingText, instance));
+
+ InstanceData* data =
+ static_cast<PluginDispatcher*>(dispatcher())->GetInstanceData(instance);
+ if (!data)
+ return;
+ data->should_do_request_surrounding_text = true;
+
+ if (!data->is_request_surrounding_text_pending) {
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&RequestSurroundingText, instance));
+ data->is_request_surrounding_text_pending = true;
+ }
}
void PPB_Instance_Proxy::UpdateSurroundingText(PP_Instance instance,
@@ -998,5 +1016,14 @@ void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result,
API_ID_PPB_INSTANCE, instance, result));
}
+void PPB_Instance_Proxy::CancelAnyPendingRequestSurroundingText(
+ PP_Instance instance) {
+ InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
+ GetInstanceData(instance);
+ if (!data)
+ return; // Instance was probably deleted.
+ data->should_do_request_surrounding_text = false;
+}
+
} // namespace proxy
} // namespace ppapi
diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h
index f7d2905..1585f75 100644
--- a/ppapi/proxy/ppb_instance_proxy.h
+++ b/ppapi/proxy/ppb_instance_proxy.h
@@ -247,6 +247,9 @@ class PPB_Instance_Proxy : public InterfaceProxy,
void MouseLockCompleteInHost(int32_t result, PP_Instance instance);
+ // Other helpers.
+ void CancelAnyPendingRequestSurroundingText(PP_Instance instance);
+
ProxyCompletionCallbackFactory<PPB_Instance_Proxy> callback_factory_;
};