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

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

Issue 2780373002: Use observer pattern instead of sniffing SwapCompositorFrame IPC (Closed)
Patch Set: Addressed comments Created 3 years, 8 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
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5806774e8203c16586540b0088e305cf78e84ca3..e2f634b0285257bd1428b1adbdb2cb0c71c68797 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -1533,41 +1533,15 @@ bool RequestFrame(WebContents* web_contents) {
->ScheduleComposite();
}
-FrameWatcher::FrameWatcher() : MessageFilter(), frames_to_wait_(0) {}
+FrameWatcher::FrameWatcher() = default;
-FrameWatcher::~FrameWatcher() {
-}
+FrameWatcher::FrameWatcher(WebContents* web_contents)
+ : WebContentsObserver(web_contents) {}
-void FrameWatcher::ReceivedFrameSwap(cc::CompositorFrameMetadata metadata) {
- --frames_to_wait_;
- last_metadata_ = std::move(metadata);
- if (frames_to_wait_ == 0)
- quit_.Run();
-}
-
-bool FrameWatcher::OnMessageReceived(const IPC::Message& message) {
- if (message.type() == ViewHostMsg_SwapCompositorFrame::ID) {
- ViewHostMsg_SwapCompositorFrame::Param param;
- if (!ViewHostMsg_SwapCompositorFrame::Read(&message, &param))
- return false;
- cc::CompositorFrame frame(std::move(std::get<2>(param)));
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&FrameWatcher::ReceivedFrameSwap, this,
- base::Passed(std::move(frame.metadata))));
- }
- return false;
-}
-
-void FrameWatcher::AttachTo(WebContents* web_contents) {
- DCHECK(web_contents);
- RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From(
- web_contents->GetRenderViewHost()->GetWidget());
- widget_host->GetProcess()->GetChannel()->AddFilter(this);
-}
+FrameWatcher::~FrameWatcher() = default;
void FrameWatcher::WaitFrames(int frames_to_wait) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (frames_to_wait <= 0)
return;
base::RunLoop run_loop;
@@ -1577,7 +1551,15 @@ void FrameWatcher::WaitFrames(int frames_to_wait) {
}
const cc::CompositorFrameMetadata& FrameWatcher::LastMetadata() {
- return last_metadata_;
+ return RenderWidgetHostImpl::From(
+ web_contents()->GetRenderViewHost()->GetWidget())
+ ->last_frame_metadata();
+}
+
+void FrameWatcher::DidReceiveCompositorFrame() {
+ --frames_to_wait_;
+ if (frames_to_wait_ == 0)
+ quit_.Run();
}
MainThreadFrameObserver::MainThreadFrameObserver(
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698