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

Side by Side Diff: content/test/content_browser_test_utils_internal.h

Issue 2132603002: [page_load_metrics] Add a NavigationThrottle for richer abort metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clamy@ review Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_ 5 #ifndef CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_
6 #define CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_ 6 #define CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_
7 7
8 // A collection of functions designed for use with content_shell based browser 8 // A collection of functions designed for use with content_shell based browser
9 // tests internal to the content/ module. 9 // tests internal to the content/ module.
10 // Note: If a function here also works with browser_tests, it should be in 10 // Note: If a function here also works with browser_tests, it should be in
11 // the content public API. 11 // the content public API.
12 12
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "cc/surfaces/surface_id.h" 19 #include "cc/surfaces/surface_id.h"
20 #include "content/public/browser/navigation_handle.h"
21 #include "content/public/browser/resource_dispatcher_host_delegate.h" 20 #include "content/public/browser/resource_dispatcher_host_delegate.h"
22 #include "content/public/browser/web_contents_delegate.h" 21 #include "content/public/browser/web_contents_delegate.h"
23 #include "content/public/browser/web_contents_observer.h"
24 #include "url/gurl.h" 22 #include "url/gurl.h"
25 23
26 namespace cc { 24 namespace cc {
27 class SurfaceManager; 25 class SurfaceManager;
28 } 26 }
29 27
30 namespace content { 28 namespace content {
31 29
32 class FrameTreeNode; 30 class FrameTreeNode;
33 class MessageLoopRunner; 31 class MessageLoopRunner;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void RequestBeginning( 108 void RequestBeginning(
111 net::URLRequest* request, 109 net::URLRequest* request,
112 content::ResourceContext* resource_context, 110 content::ResourceContext* resource_context,
113 content::AppCacheService* appcache_service, 111 content::AppCacheService* appcache_service,
114 ResourceType resource_type, 112 ResourceType resource_type,
115 ScopedVector<content::ResourceThrottle>* throttles) override; 113 ScopedVector<content::ResourceThrottle>* throttles) override;
116 114
117 GURL url_; 115 GURL url_;
118 }; 116 };
119 117
120 // This class can be used to pause and resume navigations, based on a URL
121 // match. Note that it only keeps track of one navigation at a time.
122 // Navigations are paused automatically before hitting the network, and are
123 // resumed automatically if a Wait method is called for a future event.
124 class TestNavigationManager : public WebContentsObserver {
125 public:
126 // Monitors notifications within the given frame tree node. Use the other
127 // constructor if the manager should monitor all frames, which is equivalent
128 // to passing kFrameTreeNodeInvalidId for |frame_tree_node_id|.
129 TestNavigationManager(int frame_tree_node_id,
130 WebContents* web_contents,
131 const GURL& url);
132
133 // Monitors any frame in WebContents.
134 TestNavigationManager(WebContents* web_contents, const GURL& url);
135
136 ~TestNavigationManager() override;
137
138 // Waits until the navigation request is ready to be sent to the network
139 // stack.
140 void WaitForWillStartRequest();
141
142 // Waits until the navigation has been finished. Will automatically resume
143 // navigations paused before this point.
144 void WaitForNavigationFinished();
145
146 private:
147 // WebContentsObserver:
148 void DidStartNavigation(NavigationHandle* handle) override;
149 void DidFinishNavigation(NavigationHandle* handle) override;
150
151 // Called when the NavigationThrottle pauses the navigation in
152 // WillStartRequest.
153 void OnWillStartRequest();
154
155 // Resumes the navigation.
156 void ResumeNavigation();
157
158 // If this member is not |kFrameTreeNodeInvalidId|, notifications are filtered
159 // so only this frame is monitored.
160 int filtering_frame_tree_node_id_;
161
162 const GURL url_;
163 bool navigation_paused_;
164 NavigationHandle* handle_;
165 scoped_refptr<MessageLoopRunner> will_start_loop_runner_;
166 scoped_refptr<MessageLoopRunner> did_finish_loop_runner_;
167
168 base::WeakPtrFactory<TestNavigationManager> weak_factory_;
169 };
170
171 // Helper class to assist with hit testing surfaces in multiple processes. 118 // Helper class to assist with hit testing surfaces in multiple processes.
172 // WaitForSurfaceReady() will only return after a Surface from |target_view| 119 // WaitForSurfaceReady() will only return after a Surface from |target_view|
173 // has been composited in the top-level frame's Surface. At that point, 120 // has been composited in the top-level frame's Surface. At that point,
174 // browser process hit testing to target_view's Surface can succeed. 121 // browser process hit testing to target_view's Surface can succeed.
175 class SurfaceHitTestReadyNotifier { 122 class SurfaceHitTestReadyNotifier {
176 public: 123 public:
177 SurfaceHitTestReadyNotifier(RenderWidgetHostViewChildFrame* target_view); 124 SurfaceHitTestReadyNotifier(RenderWidgetHostViewChildFrame* target_view);
178 ~SurfaceHitTestReadyNotifier() {} 125 ~SurfaceHitTestReadyNotifier() {}
179 126
180 void WaitForSurfaceReady(); 127 void WaitForSurfaceReady();
(...skipping 23 matching lines...) Expand all
204 bool file_chosen() { return file_chosen_; } 151 bool file_chosen() { return file_chosen_; }
205 152
206 private: 153 private:
207 base::FilePath file_; 154 base::FilePath file_;
208 bool file_chosen_; 155 bool file_chosen_;
209 }; 156 };
210 157
211 } // namespace content 158 } // namespace content
212 159
213 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_ 160 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698