Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
| 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 std::unique_ptr<RenderViewCreatedObserver> child_observer_; | 524 std::unique_ptr<RenderViewCreatedObserver> child_observer_; |
| 525 scoped_refptr<MessageLoopRunner> runner_; | 525 scoped_refptr<MessageLoopRunner> runner_; |
| 526 | 526 |
| 527 DISALLOW_COPY_AND_ASSIGN(WebContentsAddedObserver); | 527 DISALLOW_COPY_AND_ASSIGN(WebContentsAddedObserver); |
| 528 }; | 528 }; |
| 529 | 529 |
| 530 // Request a new frame be drawn, returns false if request fails. | 530 // Request a new frame be drawn, returns false if request fails. |
| 531 bool RequestFrame(WebContents* web_contents); | 531 bool RequestFrame(WebContents* web_contents); |
| 532 | 532 |
| 533 // Watches compositor frame changes, blocking until a frame has been | 533 // Watches compositor frame changes, blocking until a frame has been |
| 534 // composited. This class is intended to be run on the main thread; to | 534 // composited. This class must run on the UI thread. |
| 535 // synchronize the main thread against the impl thread. | 535 class FrameWatcher : public WebContentsObserver { |
| 536 class FrameWatcher : public IPC::MessageFilter { | |
| 537 public: | 536 public: |
| 537 // Don't observe any WebContents at construction. Observe() must be called | |
| 538 // later on. | |
| 538 FrameWatcher(); | 539 FrameWatcher(); |
| 539 | 540 |
| 540 // Listen for new frames from the |web_contents| renderer process. | 541 // Listen for new frames from the |web_contents| renderer process. The |
| 541 void AttachTo(WebContents* web_contents); | 542 // WebContents that we observe can be changed by calling Observe(). |
| 543 FrameWatcher(WebContents* web_contents); | |
|
piman
2017/04/04 17:34:46
nit: explicit
Saman Sami
2017/04/04 17:49:54
Done.
| |
| 544 | |
| 545 ~FrameWatcher() override; | |
| 542 | 546 |
| 543 // Wait for |frames_to_wait| swap mesages from the compositor. | 547 // Wait for |frames_to_wait| swap mesages from the compositor. |
| 544 void WaitFrames(int frames_to_wait); | 548 void WaitFrames(int frames_to_wait); |
| 545 | 549 |
| 546 // Return the meta data received in the last compositor | 550 // Return the last received CompositorFrame's metadata. |
| 547 // swap frame. | |
| 548 const cc::CompositorFrameMetadata& LastMetadata(); | 551 const cc::CompositorFrameMetadata& LastMetadata(); |
| 549 | 552 |
| 553 // Call this method to start observing a WebContents for CompositorFrames. | |
| 554 using WebContentsObserver::Observe; | |
| 555 | |
| 550 private: | 556 private: |
| 551 ~FrameWatcher() override; | 557 // WebContentsObserver implementation. |
| 558 void DidReceiveCompositorFrame() override; | |
| 552 | 559 |
| 553 // Overridden BrowserMessageFilter methods. | 560 int frames_to_wait_ = 0; |
| 554 bool OnMessageReceived(const IPC::Message& message) override; | |
| 555 | |
| 556 void ReceivedFrameSwap(cc::CompositorFrameMetadata meta_data); | |
| 557 | |
| 558 int frames_to_wait_; | |
| 559 base::Closure quit_; | 561 base::Closure quit_; |
| 560 cc::CompositorFrameMetadata last_metadata_; | |
| 561 | 562 |
| 562 DISALLOW_COPY_AND_ASSIGN(FrameWatcher); | 563 DISALLOW_COPY_AND_ASSIGN(FrameWatcher); |
| 563 }; | 564 }; |
| 564 | 565 |
| 565 // This class is intended to synchronize the renderer main thread, renderer impl | 566 // This class is intended to synchronize the renderer main thread, renderer impl |
| 566 // thread and the browser main thread. | 567 // thread and the browser main thread. |
| 567 class MainThreadFrameObserver : public IPC::Listener { | 568 class MainThreadFrameObserver : public IPC::Listener { |
| 568 public: | 569 public: |
| 569 explicit MainThreadFrameObserver(RenderWidgetHost* render_widget_host); | 570 explicit MainThreadFrameObserver(RenderWidgetHost* render_widget_host); |
| 570 ~MainThreadFrameObserver() override; | 571 ~MainThreadFrameObserver() override; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 800 | 801 |
| 801 private: | 802 private: |
| 802 PwnMessageHelper(); // Not instantiable. | 803 PwnMessageHelper(); // Not instantiable. |
| 803 | 804 |
| 804 DISALLOW_COPY_AND_ASSIGN(PwnMessageHelper); | 805 DISALLOW_COPY_AND_ASSIGN(PwnMessageHelper); |
| 805 }; | 806 }; |
| 806 | 807 |
| 807 } // namespace content | 808 } // namespace content |
| 808 | 809 |
| 809 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 810 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
| OLD | NEW |