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

Unified Diff: content/public/test/browser_test_utils.cc

Issue 1631963002: Plumb firing passive event listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_passive_listeners_2a
Patch Set: Renamed enum value as per wez@ request Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/public/test/browser_test_utils.cc
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index be9b2e0f26add65bc9e889a9295c540519a86f5e..ab3e6df0f2f05c70db9ccb121b4e83fdc4a695ed 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -25,6 +25,7 @@
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/web_contents/web_contents_view.h"
#include "content/common/input/synthetic_web_input_event_builders.h"
+#include "content/common/input_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/histogram_fetcher.h"
@@ -1073,16 +1074,24 @@ FrameWatcher::FrameWatcher()
FrameWatcher::~FrameWatcher() {
}
-void FrameWatcher::ReceivedFrameSwap() {
+void FrameWatcher::ReceivedFrameSwap(cc::CompositorFrameMetadata metadata) {
--frames_to_wait_;
+ last_metadata_ = metadata;
if (frames_to_wait_ == 0)
quit_.Run();
}
bool FrameWatcher::OnMessageReceived(const IPC::Message& message) {
if (message.type() == ViewHostMsg_SwapCompositorFrame::ID) {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&FrameWatcher::ReceivedFrameSwap, this));
+ ViewHostMsg_SwapCompositorFrame::Param param;
+ if (!ViewHostMsg_SwapCompositorFrame::Read(&message, &param))
+ return false;
+ scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
+ base::get<1>(param).AssignTo(frame.get());
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&FrameWatcher::ReceivedFrameSwap, this, frame->metadata));
}
return false;
}
@@ -1103,6 +1112,10 @@ void FrameWatcher::WaitFrames(int frames_to_wait) {
run_loop.Run();
}
+const cc::CompositorFrameMetadata& FrameWatcher::LastMetadata() {
+ return last_metadata_;
+}
+
MainThreadFrameObserver::MainThreadFrameObserver(
RenderWidgetHost* render_widget_host)
: render_widget_host_(render_widget_host),
@@ -1140,4 +1153,45 @@ bool MainThreadFrameObserver::OnMessageReceived(const IPC::Message& msg) {
return true;
}
+InputMsgWatcher::InputMsgWatcher(RenderWidgetHost* render_widget_host,
+ blink::WebInputEvent::Type type)
+ : BrowserMessageFilter(InputMsgStart),
+ wait_for_type_(type),
+ ack_result_(INPUT_EVENT_ACK_STATE_UNKNOWN) {
+ render_widget_host->GetProcess()->AddFilter(this);
+}
+
+InputMsgWatcher::~InputMsgWatcher() {}
+
+void InputMsgWatcher::ReceivedAck(blink::WebInputEvent::Type ack_type,
Charlie Reis 2016/02/16 22:25:22 Can you add some DCHECKs for which threads you exp
dtapuska 2016/02/17 03:34:57 Done.
+ uint32_t ack_state) {
+ if (wait_for_type_ == ack_type) {
+ ack_result_ = ack_state;
+ if (!quit_.is_null())
+ quit_.Run();
+ }
+}
+
+bool InputMsgWatcher::OnMessageReceived(const IPC::Message& message) {
+ if (message.type() == InputHostMsg_HandleInputEvent_ACK::ID) {
+ InputHostMsg_HandleInputEvent_ACK::Param params;
+ InputHostMsg_HandleInputEvent_ACK::Read(&message, &params);
+ blink::WebInputEvent::Type ack_type = base::get<0>(params).type;
+ InputEventAckState ack_state = base::get<0>(params).state;
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&InputMsgWatcher::ReceivedAck, this, ack_type, ack_state));
+ }
+ return false;
+}
+
+uint32_t InputMsgWatcher::WaitForAck() {
+ if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN)
+ return ack_result_;
+ base::RunLoop run_loop;
+ base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure());
+ run_loop.Run();
+ return ack_result_;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698