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 | |
349 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( | 335 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( |
350 WebContents* web_contents) | 336 WebContents* web_contents) |
351 : WebContentsObserver(web_contents), | 337 : WebContentsObserver(web_contents), web_contents_destroyed_(false) { |
352 is_loading_(false), | 338 } |
353 web_contents_destroyed_(false) {} | |
354 | 339 |
355 WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() { | 340 WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() { |
356 CHECK(web_contents_destroyed_); | 341 CHECK(web_contents_destroyed_); |
357 } | 342 } |
358 | 343 |
359 void WebContentsObserverSanityChecker::AssertRenderFrameExists( | 344 void WebContentsObserverSanityChecker::AssertRenderFrameExists( |
360 RenderFrameHost* render_frame_host) { | 345 RenderFrameHost* render_frame_host) { |
361 CHECK(!web_contents_destroyed_); | 346 CHECK(!web_contents_destroyed_); |
362 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); | 347 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); |
363 | 348 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (live_routes_.count(entry.first)) | 400 if (live_routes_.count(entry.first)) |
416 return true; | 401 return true; |
417 if (current_hosts_.count(entry.first)) | 402 if (current_hosts_.count(entry.first)) |
418 return true; | 403 return true; |
419 } | 404 } |
420 } | 405 } |
421 return false; | 406 return false; |
422 } | 407 } |
423 | 408 |
424 } // namespace content | 409 } // namespace content |
OLD | NEW |