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

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

Issue 2780373002: Use observer pattern instead of sniffing SwapCompositorFrame IPC (Closed)
Patch Set: Don't send metadata 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
Index: content/public/test/browser_test_utils.h
diff --git a/content/public/test/browser_test_utils.h b/content/public/test/browser_test_utils.h
index a5211bc7817c18147cff94a76911511bb8e710c5..e7df0aa2a45a96e459f9532d530be09fa676567f 100644
--- a/content/public/test/browser_test_utils.h
+++ b/content/public/test/browser_test_utils.h
@@ -531,33 +531,34 @@ class WebContentsAddedObserver {
bool RequestFrame(WebContents* web_contents);
// Watches compositor frame changes, blocking until a frame has been
-// composited. This class is intended to be run on the main thread; to
-// synchronize the main thread against the impl thread.
-class FrameWatcher : public IPC::MessageFilter {
+// composited. This class must run on the UI thread.
+class FrameWatcher : public WebContentsObserver {
public:
+ // Don't observe any WebContents at construction. Observe() must be called
+ // later on.
FrameWatcher();
- // Listen for new frames from the |web_contents| renderer process.
- void AttachTo(WebContents* web_contents);
+ // Listen for new frames from the |web_contents| renderer process. The
+ // WebContents that we observe can be changed by calling Observe().
+ FrameWatcher(WebContents* web_contents);
piman 2017/04/04 17:34:46 nit: explicit
Saman Sami 2017/04/04 17:49:54 Done.
+
+ ~FrameWatcher() override;
// Wait for |frames_to_wait| swap mesages from the compositor.
void WaitFrames(int frames_to_wait);
- // Return the meta data received in the last compositor
- // swap frame.
+ // Return the last received CompositorFrame's metadata.
const cc::CompositorFrameMetadata& LastMetadata();
- private:
- ~FrameWatcher() override;
-
- // Overridden BrowserMessageFilter methods.
- bool OnMessageReceived(const IPC::Message& message) override;
+ // Call this method to start observing a WebContents for CompositorFrames.
+ using WebContentsObserver::Observe;
- void ReceivedFrameSwap(cc::CompositorFrameMetadata meta_data);
+ private:
+ // WebContentsObserver implementation.
+ void DidReceiveCompositorFrame() override;
- int frames_to_wait_;
+ int frames_to_wait_ = 0;
base::Closure quit_;
- cc::CompositorFrameMetadata last_metadata_;
DISALLOW_COPY_AND_ASSIGN(FrameWatcher);
};

Powered by Google App Engine
This is Rietveld 408576698