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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 return false; | 325 return false; |
326 } | 326 } |
327 | 327 |
328 void WebContentsObserverSanityChecker::WebContentsDestroyed() { | 328 void WebContentsObserverSanityChecker::WebContentsDestroyed() { |
329 CHECK(!web_contents_destroyed_); | 329 CHECK(!web_contents_destroyed_); |
330 web_contents_destroyed_ = true; | 330 web_contents_destroyed_ = true; |
331 CHECK(ongoing_navigations_.empty()); | 331 CHECK(ongoing_navigations_.empty()); |
332 CHECK(active_media_players_.empty()); | 332 CHECK(active_media_players_.empty()); |
333 } | 333 } |
334 | 334 |
| 335 void WebContentsObserverSanityChecker::DidStartLoading() { |
| 336 // TODO(clamy): add checks for the loading state in the rest of observer |
| 337 // methods. |
| 338 CHECK(!is_loading_); |
| 339 CHECK(web_contents()->IsLoading()); |
| 340 is_loading_ = true; |
| 341 } |
| 342 |
| 343 void WebContentsObserverSanityChecker::DidStopLoading() { |
| 344 CHECK(is_loading_); |
| 345 CHECK(!web_contents()->IsLoading()); |
| 346 is_loading_ = false; |
| 347 } |
| 348 |
335 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( | 349 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( |
336 WebContents* web_contents) | 350 WebContents* web_contents) |
337 : WebContentsObserver(web_contents), web_contents_destroyed_(false) { | 351 : WebContentsObserver(web_contents), |
338 } | 352 is_loading_(false), |
| 353 web_contents_destroyed_(false) {} |
339 | 354 |
340 WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() { | 355 WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() { |
341 CHECK(web_contents_destroyed_); | 356 CHECK(web_contents_destroyed_); |
342 } | 357 } |
343 | 358 |
344 void WebContentsObserverSanityChecker::AssertRenderFrameExists( | 359 void WebContentsObserverSanityChecker::AssertRenderFrameExists( |
345 RenderFrameHost* render_frame_host) { | 360 RenderFrameHost* render_frame_host) { |
346 CHECK(!web_contents_destroyed_); | 361 CHECK(!web_contents_destroyed_); |
347 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); | 362 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); |
348 | 363 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 if (live_routes_.count(entry.first)) | 415 if (live_routes_.count(entry.first)) |
401 return true; | 416 return true; |
402 if (current_hosts_.count(entry.first)) | 417 if (current_hosts_.count(entry.first)) |
403 return true; | 418 return true; |
404 } | 419 } |
405 } | 420 } |
406 return false; | 421 return false; |
407 } | 422 } |
408 | 423 |
409 } // namespace content | 424 } // namespace content |
OLD | NEW |