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

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

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/browser/web_contents_observer.h ('k') | content/public/test/browser_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..00be458e9677252686f0b5de05669d6f2d919758 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().
+ explicit FrameWatcher(WebContents* web_contents);
+
+ ~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);
};
« no previous file with comments | « content/public/browser/web_contents_observer.h ('k') | content/public/test/browser_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698