summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-09 02:08:33 +0000
committerbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-09 02:08:33 +0000
commit3b98ced7c4528bca2b7bccef06f1dbb09195e924 (patch)
tree68b5ff96929940152bfbf13fbc33a82d17bd76e0 /ppapi
parent2db72d5edd716d73a085d352219e91198f3a2ffd (diff)
downloadchromium_src-3b98ced7c4528bca2b7bccef06f1dbb09195e924.zip
chromium_src-3b98ced7c4528bca2b7bccef06f1dbb09195e924.tar.gz
chromium_src-3b98ced7c4528bca2b7bccef06f1dbb09195e924.tar.bz2
Add HandleInputEventAck message to allow out-of-process plugins to respond to user gestures.
Modifies PluginInstance to track pending user gestures by timestamp. Modifies ppapi/tests/test_fullscreen to not test that SetFullscreen and BindGraphics fail while fullscreen changes are pending. Because of how PluginInstance reports view changed events, these will likely fail due to race conditions. BUG=73070 TEST=ui_tests, --gtest_filter=*PPAPITest.Fullscreen Review URL: http://codereview.chromium.org/9558009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125768 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/proxy/ppapi_messages.h5
-rw-r--r--ppapi/proxy/ppb_instance_proxy.cc16
-rw-r--r--ppapi/proxy/ppb_instance_proxy.h7
-rw-r--r--ppapi/proxy/ppp_input_event_proxy.cc14
-rw-r--r--ppapi/proxy/ppp_input_event_proxy.h3
-rw-r--r--ppapi/tests/test_fullscreen.cc72
-rw-r--r--ppapi/tests/test_fullscreen.h3
-rw-r--r--ppapi/thunk/ppb_instance_api.h7
8 files changed, 62 insertions, 65 deletions
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 5860048..2872bd7 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -30,6 +30,7 @@
#include "ppapi/c/pp_rect.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_size.h"
+#include "ppapi/c/pp_time.h"
#include "ppapi/c/private/ppb_tcp_socket_private.h"
#include "ppapi/proxy/ppapi_param_traits.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
@@ -433,6 +434,10 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiMsg_PPPInputEvent_HandleFilteredInputEvent,
PP_Instance /* instance */,
ppapi::InputEventData /* data */,
PP_Bool /* result */)
+// (Message from the plugin to the browser that it handled an input event.)
+IPC_MESSAGE_ROUTED2(PpapiMsg_PPPInputEvent_HandleInputEvent_ACK,
+ PP_Instance /* instance */,
+ PP_TimeTicks /* timestamp */)
// PPP_Instance.
IPC_SYNC_MESSAGE_ROUTED3_1(PpapiMsg_PPPInstance_DidCreate,
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index 01977cc..7f29c66 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -5,6 +5,7 @@
#include "ppapi/proxy/ppb_instance_proxy.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_time.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_instance.h"
@@ -107,6 +108,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgRequestInputEvents)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents,
OnHostMsgClearInputEvents)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPPInputEvent_HandleInputEvent_ACK,
+ OnMsgHandleInputEventAck)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LockMouse,
OnHostMsgLockMouse)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UnlockMouse,
@@ -321,6 +324,12 @@ void PPB_Instance_Proxy::ClearInputEventRequest(PP_Instance instance,
API_ID_PPB_INSTANCE, instance, event_classes));
}
+void PPB_Instance_Proxy::ClosePendingUserGesture(PP_Instance instance,
+ PP_TimeTicks timestamp) {
+ // Not called on the plugin side.
+ NOTREACHED();
+}
+
void PPB_Instance_Proxy::ZoomChanged(PP_Instance instance,
double factor) {
// Not proxied yet.
@@ -547,6 +556,13 @@ void PPB_Instance_Proxy::OnHostMsgClearInputEvents(PP_Instance instance,
enter.functions()->ClearInputEventRequest(instance, event_classes);
}
+void PPB_Instance_Proxy::OnMsgHandleInputEventAck(PP_Instance instance,
+ PP_TimeTicks timestamp) {
+ EnterInstanceNoLock enter(instance, false);
+ if (enter.succeeded())
+ enter.functions()->ClosePendingUserGesture(instance, timestamp);
+}
+
void PPB_Instance_Proxy::OnHostMsgPostMessage(
PP_Instance instance,
SerializedVarReceiveInput message) {
diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h
index edb6a95..5b17af1 100644
--- a/ppapi/proxy/ppb_instance_proxy.h
+++ b/ppapi/proxy/ppb_instance_proxy.h
@@ -7,6 +7,7 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/pp_time.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
@@ -64,7 +65,7 @@ class PPB_Instance_Proxy : public InterfaceProxy,
int32_t index) OVERRIDE;
virtual PP_Var GetFontFamilies(PP_Instance instance) OVERRIDE;
virtual PP_Bool SetFullscreen(PP_Instance instance,
- PP_Bool fullscreen) OVERRIDE;
+ PP_Bool fullscreen) OVERRIDE;
virtual PP_Bool GetScreenSize(PP_Instance instance,
PP_Size* size) OVERRIDE;
virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE;
@@ -80,6 +81,8 @@ class PPB_Instance_Proxy : public InterfaceProxy,
uint32_t event_classes) OVERRIDE;
virtual void ClearInputEventRequest(PP_Instance instance,
uint32_t event_classes) OVERRIDE;
+ virtual void ClosePendingUserGesture(PP_Instance instance,
+ PP_TimeTicks timestamp) OVERRIDE;
virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE;
virtual void ZoomLimitsChanged(PP_Instance instance,
double minimum_factor,
@@ -140,6 +143,8 @@ class PPB_Instance_Proxy : public InterfaceProxy,
uint32_t event_classes);
void OnHostMsgClearInputEvents(PP_Instance instance,
uint32_t event_classes);
+ void OnMsgHandleInputEventAck(PP_Instance instance,
+ PP_TimeTicks timestamp);
void OnHostMsgPostMessage(PP_Instance instance,
SerializedVarReceiveInput message);
void OnHostMsgLockMouse(PP_Instance instance);
diff --git a/ppapi/proxy/ppp_input_event_proxy.cc b/ppapi/proxy/ppp_input_event_proxy.cc
index e49296f..ce4eef0 100644
--- a/ppapi/proxy/ppp_input_event_proxy.cc
+++ b/ppapi/proxy/ppp_input_event_proxy.cc
@@ -101,6 +101,7 @@ void PPP_InputEvent_Proxy::OnMsgHandleInputEvent(PP_Instance instance,
CallWhileUnlocked(ppp_input_event_impl_->HandleInputEvent,
instance,
resource->pp_resource());
+ HandleInputEventAck(instance, data.event_time_stamp);
}
void PPP_InputEvent_Proxy::OnMsgHandleFilteredInputEvent(
@@ -112,6 +113,19 @@ void PPP_InputEvent_Proxy::OnMsgHandleFilteredInputEvent(
*result = CallWhileUnlocked(ppp_input_event_impl_->HandleInputEvent,
instance,
resource->pp_resource());
+ HandleInputEventAck(instance, data.event_time_stamp);
+}
+
+void PPP_InputEvent_Proxy::HandleInputEventAck(
+ PP_Instance instance, PP_TimeTicks timestamp) {
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
+ if (dispatcher) {
+ // Note that we're sending the message to the host PPB_InstanceProxy.
+ dispatcher->Send(new PpapiMsg_PPPInputEvent_HandleInputEvent_ACK(
+ API_ID_PPB_INSTANCE, instance, timestamp));
+ } else {
+ NOTREACHED();
+ }
}
} // namespace proxy
diff --git a/ppapi/proxy/ppp_input_event_proxy.h b/ppapi/proxy/ppp_input_event_proxy.h
index a7cc054..e326aec 100644
--- a/ppapi/proxy/ppp_input_event_proxy.h
+++ b/ppapi/proxy/ppp_input_event_proxy.h
@@ -6,6 +6,7 @@
#define PPAPI_PROXY_PPP_INPUT_EVENT_PROXY_H_
#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_time.h"
#include "ppapi/c/ppp_input_event.h"
#include "ppapi/proxy/interface_proxy.h"
@@ -33,6 +34,8 @@ class PPP_InputEvent_Proxy : public InterfaceProxy {
const ppapi::InputEventData& data,
PP_Bool* result);
+ void HandleInputEventAck(PP_Instance instance, PP_TimeTicks timestamp);
+
// When this proxy is in the plugin side, this value caches the interface
// pointer so we don't have to retrieve it from the dispatcher each time.
// In the host, this value is always NULL.
diff --git a/ppapi/tests/test_fullscreen.cc b/ppapi/tests/test_fullscreen.cc
index 5b2aabe..d8511e6 100644
--- a/ppapi/tests/test_fullscreen.cc
+++ b/ppapi/tests/test_fullscreen.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -54,7 +54,6 @@ TestFullscreen::TestFullscreen(TestingInstance* instance)
screen_mode_(instance),
fullscreen_pending_(false),
normal_pending_(false),
- saw_first_fullscreen_didchangeview(false),
set_fullscreen_true_callback_(instance->pp_instance()),
fullscreen_callback_(instance->pp_instance()),
normal_callback_(instance->pp_instance()) {
@@ -134,16 +133,6 @@ std::string TestFullscreen::TestNormalToFullscreenToNormal() {
normal_pending_ = true;
if (!screen_mode_.SetFullscreen(false))
return ReportError("SetFullscreen(false) in fullscreen", false);
- // Normal is now pending, so additional requests should fail.
- if (screen_mode_.SetFullscreen(false))
- return ReportError("SetFullscreen(false) in normal pending", true);
- if (screen_mode_.SetFullscreen(true))
- return ReportError("SetFullscreen(true) in normal pending", true);
- if (!screen_mode_.IsFullscreen())
- return ReportError("IsFullscreen() in normal transition", false);
- // No graphics devices can be bound while in transition.
- if (instance_->BindGraphics(graphics2d_))
- return ReportError("BindGraphics() in normal transition", true);
// DidChangeView() will call the callback once out of fullscreen mode.
normal_callback_.WaitForResult();
if (normal_pending_)
@@ -180,25 +169,20 @@ void TestFullscreen::SimulateUserGesture() {
}
void TestFullscreen::FailFullscreenTest(const std::string& error) {
- screen_mode_.SetFullscreen(false);
- fullscreen_pending_ = false;
error_ = error;
pp::Module::Get()->core()->CallOnMainThread(0, fullscreen_callback_);
}
void TestFullscreen::FailNormalTest(const std::string& error) {
- normal_pending_ = false;
error_ = error;
pp::Module::Get()->core()->CallOnMainThread(0, normal_callback_);
}
void TestFullscreen::PassFullscreenTest() {
- fullscreen_pending_ = false;
pp::Module::Get()->core()->CallOnMainThread(0, fullscreen_callback_);
}
void TestFullscreen::PassNormalTest() {
- normal_pending_ = false;
pp::Module::Get()->core()->CallOnMainThread(0, normal_callback_);
}
@@ -220,27 +204,6 @@ bool TestFullscreen::HandleInputEvent(const pp::InputEvent& event) {
FailFullscreenTest(ReportError("SetFullscreen(true) in normal", false));
return false;
}
- // Fullscreen is now pending, so additional requests should fail.
- if (screen_mode_.SetFullscreen(true)) {
- FailFullscreenTest(
- ReportError("SetFullscreen(true) in fullscreen pending", true));
- return false;
- }
- if (screen_mode_.SetFullscreen(false)) {
- FailFullscreenTest(
- ReportError("SetFullscreen(false) in fullscreen pending", true));
- }
- if (screen_mode_.IsFullscreen()) {
- FailFullscreenTest(
- ReportError("IsFullscreen() in fullscreen transition", true));
- return false;
- }
- // No graphics devices can be bound while in transition.
- if (instance_->BindGraphics(graphics2d_)) {
- FailFullscreenTest(
- ReportError("BindGraphics() in fullscreen transition", true));
- return false;
- }
// DidChangeView() will complete the transition to fullscreen.
return false;
}
@@ -283,13 +246,10 @@ bool TestFullscreen::PaintPlugin(pp::Size size, ColorPremul color) {
return true;
}
-// Transitions to/from fullscreen is asynchornous ending at DidChangeView.
-// When going to fullscreen, two DidChangeView calls are generated:
-// one for moving the plugin to the middle of window and one for stretching
-// the window and placing the plugin in the middle of the screen.
-// This is not something we advertise to users and not something they should
-// rely on. But the test checks for these, so we know when the underlying
-// implementation changes.
+// Transitions to/from fullscreen is asynchronous ending at DidChangeView.
+// The number of calls to DidChangeView during fullscreen / normal transitions
+// isn't specified by the API. The test waits until it the screen has
+// transitioned to the desired state.
//
// WebKit does not change the plugin size, but Pepper does explicitly set
// it to screen width and height when SetFullscreen(true) is called and
@@ -307,21 +267,13 @@ void TestFullscreen::DidChangeView(const pp::View& view) {
error_ = "Failed to initialize plugin image";
}
- if (fullscreen_pending_ && !saw_first_fullscreen_didchangeview) {
- saw_first_fullscreen_didchangeview = true;
- if (screen_mode_.IsFullscreen())
- FailFullscreenTest("DidChangeView1 is in fullscreen");
- else if (position.size() != screen_size_)
- FailFullscreenTest("DidChangeView1 does not have screen size");
- // Wait for the 2nd DidChangeView.
- } else if (fullscreen_pending_) {
- saw_first_fullscreen_didchangeview = false;
- if (!screen_mode_.IsFullscreen())
- FailFullscreenTest("DidChangeView2 is not in fullscreen");
- else if (!HasMidScreen(position, screen_size_))
- FailFullscreenTest("DidChangeView2 is not in the middle of the screen");
+ bool is_fullscreen = screen_mode_.IsFullscreen();
+ if (fullscreen_pending_ && is_fullscreen) {
+ fullscreen_pending_ = false;
+ if (!HasMidScreen(position, screen_size_))
+ FailFullscreenTest("DidChangeView is not in the middle of the screen");
else if (position.size() != screen_size_)
- FailFullscreenTest("DidChangeView2 does not have screen size");
+ FailFullscreenTest("DidChangeView does not have screen size");
// NOTE: we cannot reliably test for clip size being equal to the screen
// because it might be affected by JS console, info bars, etc.
else if (!instance_->BindGraphics(graphics2d_))
@@ -330,7 +282,7 @@ void TestFullscreen::DidChangeView(const pp::View& view) {
FailFullscreenTest("Failed to paint plugin image in fullscreen");
else
PassFullscreenTest();
- } else if (normal_pending_) {
+ } else if (normal_pending_ && !is_fullscreen) {
normal_pending_ = false;
if (screen_mode_.IsFullscreen())
FailNormalTest("DidChangeview is in fullscreen");
diff --git a/ppapi/tests/test_fullscreen.h b/ppapi/tests/test_fullscreen.h
index f3efbcc..1941864 100644
--- a/ppapi/tests/test_fullscreen.h
+++ b/ppapi/tests/test_fullscreen.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -52,7 +52,6 @@ class TestFullscreen : public TestCase {
bool fullscreen_pending_;
bool normal_pending_;
- bool saw_first_fullscreen_didchangeview;
pp::Graphics2D graphics2d_;
TestCompletionCallback set_fullscreen_true_callback_;
TestCompletionCallback fullscreen_callback_;
diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h
index d7ea28a..3a357af 100644
--- a/ppapi/thunk/ppb_instance_api.h
+++ b/ppapi/thunk/ppb_instance_api.h
@@ -7,12 +7,13 @@
#include "ppapi/c/dev/ppb_console_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
+#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_size.h"
+#include "ppapi/c/pp_time.h"
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_gamepad.h"
#include "ppapi/c/ppb_instance.h"
-#include "ppapi/c/pp_bool.h"
-#include "ppapi/c/pp_size.h"
#include "ppapi/c/private/ppb_instance_private.h"
#include "ppapi/shared_impl/api_id.h"
@@ -92,6 +93,8 @@ class PPB_Instance_FunctionAPI {
uint32_t event_classes) = 0;
virtual void ClearInputEventRequest(PP_Instance instance,
uint32_t event_classes) = 0;
+ virtual void ClosePendingUserGesture(PP_Instance instance,
+ PP_TimeTicks timestamp) = 0;
// Messaging.
virtual void PostMessage(PP_Instance instance, PP_Var message) = 0;