| 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/web_contents_observer_sanity_checker.h" | 5 #include "content/test/web_contents_observer_sanity_checker.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/browser/frame_host/render_frame_host_impl.h" | 9 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 10 #include "content/common/frame_messages.h" | 10 #include "content/common/frame_messages.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 return false; | 323 return false; |
| 324 } | 324 } |
| 325 | 325 |
| 326 void WebContentsObserverSanityChecker::WebContentsDestroyed() { | 326 void WebContentsObserverSanityChecker::WebContentsDestroyed() { |
| 327 CHECK(!web_contents_destroyed_); | 327 CHECK(!web_contents_destroyed_); |
| 328 web_contents_destroyed_ = true; | 328 web_contents_destroyed_ = true; |
| 329 CHECK(ongoing_navigations_.empty()); | 329 CHECK(ongoing_navigations_.empty()); |
| 330 CHECK(active_media_players_.empty()); | 330 CHECK(active_media_players_.empty()); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void WebContentsObserverSanityChecker::DidStartLoading() { |
| 334 // TODO(clamy): add checks for the loading state in the rest of observer |
| 335 // methods. |
| 336 CHECK(!is_loading_); |
| 337 CHECK(web_contents()->IsLoading()); |
| 338 is_loading_ = true; |
| 339 } |
| 340 |
| 341 void WebContentsObserverSanityChecker::DidStopLoading() { |
| 342 CHECK(is_loading_); |
| 343 CHECK(!web_contents()->IsLoading()); |
| 344 is_loading_ = false; |
| 345 } |
| 346 |
| 333 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( | 347 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( |
| 334 WebContents* web_contents) | 348 WebContents* web_contents) |
| 335 : WebContentsObserver(web_contents), web_contents_destroyed_(false) { | 349 : WebContentsObserver(web_contents), |
| 336 } | 350 is_loading_(false), |
| 351 web_contents_destroyed_(false) {} |
| 337 | 352 |
| 338 WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() { | 353 WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() { |
| 339 CHECK(web_contents_destroyed_); | 354 CHECK(web_contents_destroyed_); |
| 340 } | 355 } |
| 341 | 356 |
| 342 void WebContentsObserverSanityChecker::AssertRenderFrameExists( | 357 void WebContentsObserverSanityChecker::AssertRenderFrameExists( |
| 343 RenderFrameHost* render_frame_host) { | 358 RenderFrameHost* render_frame_host) { |
| 344 CHECK(!web_contents_destroyed_); | 359 CHECK(!web_contents_destroyed_); |
| 345 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); | 360 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); |
| 346 | 361 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 if (live_routes_.count(entry.first)) | 413 if (live_routes_.count(entry.first)) |
| 399 return true; | 414 return true; |
| 400 if (current_hosts_.count(entry.first)) | 415 if (current_hosts_.count(entry.first)) |
| 401 return true; | 416 return true; |
| 402 } | 417 } |
| 403 } | 418 } |
| 404 return false; | 419 return false; |
| 405 } | 420 } |
| 406 | 421 |
| 407 } // namespace content | 422 } // namespace content |
| OLD | NEW |