Chromium Code Reviews| 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..1dc5b5fe436e57ce151e711a4b75f10e41249cc9 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_meta_data_ = 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, ¶m)) |
| + 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() { |
|
aelias_OOO_until_Jul13
2016/02/10 03:30:24
nit: capitalization inconsistent with existing cod
dtapuska
2016/02/10 16:46:26
Done.
|
| + return last_meta_data_; |
|
aelias_OOO_until_Jul13
2016/02/10 03:30:24
Likewise should be one word "last_metadata_" for c
dtapuska
2016/02/10 16:46:26
Done.
|
| +} |
| + |
| MainThreadFrameObserver::MainThreadFrameObserver( |
| RenderWidgetHost* render_widget_host) |
| : render_widget_host_(render_widget_host), |
| @@ -1140,4 +1153,44 @@ 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, |
| + uint32_t ack_state) { |
| + if (wait_for_type_ == ack_type) { |
| + ack_result_ = ack_state; |
| + 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, ¶ms); |
| + 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::Wait() { |
| + 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 |