| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ | 5 #ifndef CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ |
| 6 #define CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ | 6 #define CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 15 #include "content/public/test/browser_test_utils.h" |
| 15 #include "content/public/test/test_utils.h" | 16 #include "content/public/test/test_utils.h" |
| 16 | 17 |
| 17 class GURL; | 18 class GURL; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class FrameTreeNode; | 21 class RenderFrameHost; |
| 21 class WebContents; | |
| 22 | 22 |
| 23 // For content_browsertests, which run on the UI thread, run a second | 23 // Helper for waiting until the navigation in a specific frame tree node (and |
| 24 // MessageLoop and quit when the navigation in a specific frame (and all of its | 24 // all of its subframes) has completed loading. |
| 25 // subframes) has completed loading. | |
| 26 class TestFrameNavigationObserver : public WebContentsObserver { | 25 class TestFrameNavigationObserver : public WebContentsObserver { |
| 27 public: | 26 public: |
| 28 // Create and register a new TestFrameNavigationObserver which will track | 27 // Create and register a new TestFrameNavigationObserver which will track |
| 29 // navigations performed in the specified |node| of the frame tree. | 28 // navigations performed in the frame tree node associated with |adapter|. |
| 30 explicit TestFrameNavigationObserver(FrameTreeNode* node); | 29 // Note that RenderFrameHost associated with |frame| might be destroyed during |
| 30 // the navigation (e.g. if the content commits in a new renderer process). |
| 31 explicit TestFrameNavigationObserver(const ToRenderFrameHost& adapter); |
| 31 | 32 |
| 32 ~TestFrameNavigationObserver() override; | 33 ~TestFrameNavigationObserver() override; |
| 33 | 34 |
| 34 // Runs a nested message loop and blocks until the full load has | 35 // Runs a nested message loop and blocks until the full load has |
| 35 // completed. | 36 // completed. |
| 36 void Wait(); | 37 void Wait(); |
| 37 | 38 |
| 38 // Runs a nested message loop and blocks until the navigation in the | 39 // Runs a nested message loop and blocks until the navigation in the |
| 39 // associated FrameTreeNode has committed. | 40 // associated FrameTreeNode has committed. |
| 40 void WaitForCommit(); | 41 void WaitForCommit(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 66 | 67 |
| 67 // The MessageLoopRunner used to spin the message loop. | 68 // The MessageLoopRunner used to spin the message loop. |
| 68 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 69 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 69 | 70 |
| 70 DISALLOW_COPY_AND_ASSIGN(TestFrameNavigationObserver); | 71 DISALLOW_COPY_AND_ASSIGN(TestFrameNavigationObserver); |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 } // namespace content | 74 } // namespace content |
| 74 | 75 |
| 75 #endif // CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ | 76 #endif // CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ |
| OLD | NEW |