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

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

Issue 2686683004: ABANDONED CL: WaitForChildFrameSurfaceReady to avoid flaky test hangs. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « content/test/content_browser_test_utils_internal.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/test/content_browser_test_utils_internal.h" 5 #include "content/test/content_browser_test_utils_internal.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/test/test_timeouts.h" 16 #include "base/test/test_timeouts.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "cc/surfaces/surface.h"
19 #include "cc/surfaces/surface_manager.h"
20 #include "content/browser/compositor/surface_utils.h" 18 #include "content/browser/compositor/surface_utils.h"
21 #include "content/browser/frame_host/cross_process_frame_connector.h"
22 #include "content/browser/frame_host/frame_tree_node.h" 19 #include "content/browser/frame_host/frame_tree_node.h"
23 #include "content/browser/frame_host/navigator.h" 20 #include "content/browser/frame_host/navigator.h"
24 #include "content/browser/frame_host/render_frame_host_delegate.h" 21 #include "content/browser/frame_host/render_frame_host_delegate.h"
25 #include "content/browser/frame_host/render_frame_proxy_host.h" 22 #include "content/browser/frame_host/render_frame_proxy_host.h"
26 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
27 #include "content/browser/renderer_host/delegated_frame_host.h" 23 #include "content/browser/renderer_host/delegated_frame_host.h"
28 #include "content/browser/renderer_host/render_widget_host_view_base.h"
29 #include "content/public/browser/navigation_handle.h" 24 #include "content/public/browser/navigation_handle.h"
30 #include "content/public/browser/render_frame_host.h" 25 #include "content/public/browser/render_frame_host.h"
31 #include "content/public/browser/resource_dispatcher_host.h" 26 #include "content/public/browser/resource_dispatcher_host.h"
32 #include "content/public/browser/resource_throttle.h" 27 #include "content/public/browser/resource_throttle.h"
33 #include "content/public/common/file_chooser_file_info.h" 28 #include "content/public/common/file_chooser_file_info.h"
34 #include "content/public/test/browser_test_utils.h" 29 #include "content/public/test/browser_test_utils.h"
35 #include "content/public/test/content_browser_test_utils.h" 30 #include "content/public/test/content_browser_test_utils.h"
36 #include "content/public/test/test_frame_navigation_observer.h" 31 #include "content/public/test/test_frame_navigation_observer.h"
37 #include "content/shell/browser/shell.h" 32 #include "content/shell/browser/shell.h"
38 #include "content/shell/browser/shell_javascript_dialog_manager.h" 33 #include "content/shell/browser/shell_javascript_dialog_manager.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // ResourceThrottle 278 // ResourceThrottle
284 void WillStartRequest(bool* defer) override { *defer = true; } 279 void WillStartRequest(bool* defer) override { *defer = true; }
285 280
286 const char* GetNameForLogging() const override { 281 const char* GetNameForLogging() const override {
287 return "HttpRequestStallThrottle"; 282 return "HttpRequestStallThrottle";
288 } 283 }
289 }; 284 };
290 285
291 } // namespace 286 } // namespace
292 287
293 SurfaceHitTestReadyNotifier::SurfaceHitTestReadyNotifier(
294 RenderWidgetHostViewChildFrame* target_view)
295 : target_view_(target_view) {
296 surface_manager_ = GetSurfaceManager();
297 }
298
299 void SurfaceHitTestReadyNotifier::WaitForSurfaceReady() {
300 root_surface_id_ = target_view_->FrameConnectorForTesting()
301 ->GetRootRenderWidgetHostViewForTesting()
302 ->SurfaceIdForTesting();
303 if (ContainsSurfaceId(root_surface_id_))
304 return;
305
306 while (true) {
307 // TODO(kenrb): Need a better way to do this. If
308 // RenderWidgetHostViewBase lifetime observer lands (see
309 // https://codereview.chromium.org/1711103002/), we can add a callback
310 // from OnSwapCompositorFrame and avoid this busy waiting, which is very
311 // frequent in tests in this file.
312 base::RunLoop run_loop;
313 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
314 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
315 run_loop.Run();
316 if (ContainsSurfaceId(root_surface_id_))
317 break;
318 }
319 }
320
321 bool SurfaceHitTestReadyNotifier::ContainsSurfaceId(
322 cc::SurfaceId container_surface_id) {
323 if (!container_surface_id.is_valid())
324 return false;
325 for (cc::SurfaceId id :
326 surface_manager_->GetSurfaceForId(container_surface_id)
327 ->referenced_surfaces()) {
328 if (id == target_view_->SurfaceIdForTesting() || ContainsSurfaceId(id))
329 return true;
330 }
331 return false;
332 }
333
334 NavigationStallDelegate::NavigationStallDelegate(const GURL& url) : url_(url) {} 288 NavigationStallDelegate::NavigationStallDelegate(const GURL& url) : url_(url) {}
335 289
336 void NavigationStallDelegate::RequestBeginning( 290 void NavigationStallDelegate::RequestBeginning(
337 net::URLRequest* request, 291 net::URLRequest* request,
338 content::ResourceContext* resource_context, 292 content::ResourceContext* resource_context,
339 content::AppCacheService* appcache_service, 293 content::AppCacheService* appcache_service,
340 ResourceType resource_type, 294 ResourceType resource_type,
341 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) { 295 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) {
342 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 296 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
343 if (request->url() == url_) 297 if (request->url() == url_)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 NavigationHandle* navigation_handle) { 346 NavigationHandle* navigation_handle) {
393 if (navigation_handle->HasCommitted() && 347 if (navigation_handle->HasCommitted() &&
394 !navigation_handle->IsErrorPage() && 348 !navigation_handle->IsErrorPage() &&
395 navigation_handle->GetURL() == url_ && 349 navigation_handle->GetURL() == url_ &&
396 navigation_handle->GetFrameTreeNodeId() == frame_tree_node_id_) { 350 navigation_handle->GetFrameTreeNodeId() == frame_tree_node_id_) {
397 run_loop_.Quit(); 351 run_loop_.Quit();
398 } 352 }
399 } 353 }
400 354
401 } // namespace content 355 } // namespace content
OLDNEW
« no previous file with comments | « content/test/content_browser_test_utils_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698