| 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 #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> |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 SurfaceHitTestReadyNotifier::SurfaceHitTestReadyNotifier( | 274 SurfaceHitTestReadyNotifier::SurfaceHitTestReadyNotifier( |
| 275 RenderWidgetHostViewChildFrame* target_view) | 275 RenderWidgetHostViewChildFrame* target_view) |
| 276 : target_view_(target_view) { | 276 : target_view_(target_view) { |
| 277 surface_manager_ = GetSurfaceManager(); | 277 surface_manager_ = GetSurfaceManager(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void SurfaceHitTestReadyNotifier::WaitForSurfaceReady() { | 280 void SurfaceHitTestReadyNotifier::WaitForSurfaceReady() { |
| 281 root_surface_id_ = target_view_->FrameConnectorForTesting() | 281 root_surface_id_ = target_view_->FrameConnectorForTesting() |
| 282 ->GetRootRenderWidgetHostViewForTesting() | 282 ->GetRootRenderWidgetHostViewForTesting() |
| 283 ->SurfaceIdForTesting(); | 283 ->SurfaceIdForTesting(); |
| 284 if (ContainsSurfaceId()) | 284 if (ContainsSurfaceId(root_surface_id_)) |
| 285 return; | 285 return; |
| 286 | 286 |
| 287 while (true) { | 287 while (true) { |
| 288 // TODO(kenrb): Need a better way to do this. If | 288 // TODO(kenrb): Need a better way to do this. If |
| 289 // RenderWidgetHostViewBase lifetime observer lands (see | 289 // RenderWidgetHostViewBase lifetime observer lands (see |
| 290 // https://codereview.chromium.org/1711103002/), we can add a callback | 290 // https://codereview.chromium.org/1711103002/), we can add a callback |
| 291 // from OnSwapCompositorFrame and avoid this busy waiting, which is very | 291 // from OnSwapCompositorFrame and avoid this busy waiting, which is very |
| 292 // frequent in tests in this file. | 292 // frequent in tests in this file. |
| 293 base::RunLoop run_loop; | 293 base::RunLoop run_loop; |
| 294 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 294 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 295 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); | 295 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); |
| 296 run_loop.Run(); | 296 run_loop.Run(); |
| 297 if (ContainsSurfaceId()) | 297 if (ContainsSurfaceId(root_surface_id_)) |
| 298 break; | 298 break; |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 | 301 |
| 302 bool SurfaceHitTestReadyNotifier::ContainsSurfaceId() { | 302 bool SurfaceHitTestReadyNotifier::ContainsSurfaceId( |
| 303 if (root_surface_id_.is_null()) | 303 cc::SurfaceId container_surface_id) { |
| 304 if (container_surface_id.is_null()) |
| 304 return false; | 305 return false; |
| 305 for (cc::SurfaceId id : surface_manager_->GetSurfaceForId(root_surface_id_) | 306 for (cc::SurfaceId id : |
| 306 ->referenced_surfaces()) { | 307 surface_manager_->GetSurfaceForId(container_surface_id) |
| 307 if (id == target_view_->SurfaceIdForTesting()) | 308 ->referenced_surfaces()) { |
| 309 if (id == target_view_->SurfaceIdForTesting() || ContainsSurfaceId(id)) |
| 308 return true; | 310 return true; |
| 309 } | 311 } |
| 310 return false; | 312 return false; |
| 311 } | 313 } |
| 312 | 314 |
| 313 NavigationStallDelegate::NavigationStallDelegate(const GURL& url) : url_(url) {} | 315 NavigationStallDelegate::NavigationStallDelegate(const GURL& url) : url_(url) {} |
| 314 | 316 |
| 315 void NavigationStallDelegate::RequestBeginning( | 317 void NavigationStallDelegate::RequestBeginning( |
| 316 net::URLRequest* request, | 318 net::URLRequest* request, |
| 317 content::ResourceContext* resource_context, | 319 content::ResourceContext* resource_context, |
| 318 content::AppCacheService* appcache_service, | 320 content::AppCacheService* appcache_service, |
| 319 ResourceType resource_type, | 321 ResourceType resource_type, |
| 320 ScopedVector<content::ResourceThrottle>* throttles) { | 322 ScopedVector<content::ResourceThrottle>* throttles) { |
| 321 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 323 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 322 if (request->url() == url_) | 324 if (request->url() == url_) |
| 323 throttles->push_back(new HttpRequestStallThrottle); | 325 throttles->push_back(new HttpRequestStallThrottle); |
| 324 } | 326 } |
| 325 | 327 |
| 326 } // namespace content | 328 } // namespace content |
| OLD | NEW |