Chromium Code Reviews| 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 "content/browser/frame_host/render_frame_host_impl.h" | 8 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 9 #include "content/common/frame_messages.h" | 9 #include "content/common/frame_messages.h" |
| 10 #include "content/public/browser/navigation_handle.h" | 10 #include "content/public/browser/navigation_handle.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 } else if (!was_live) { | 71 } else if (!was_live) { |
| 72 // TODO(nick): Clients can easily ignore an unrecognized object, but it | 72 // TODO(nick): Clients can easily ignore an unrecognized object, but it |
| 73 // would be useful from a finding-bugs perspective if we could enable this | 73 // would be useful from a finding-bugs perspective if we could enable this |
| 74 // check. | 74 // check. |
| 75 #if 0 | 75 #if 0 |
| 76 CHECK(false) << "RenderFrameDeleted called for routing pair " | 76 CHECK(false) << "RenderFrameDeleted called for routing pair " |
| 77 << Format(render_frame_host) | 77 << Format(render_frame_host) |
| 78 << " for which RenderFrameCreated was never called"; | 78 << " for which RenderFrameCreated was never called"; |
| 79 #endif | 79 #endif |
| 80 } | 80 } |
| 81 | |
| 82 // All players should have been paused by this point. | |
| 83 CHECK(active_media_players_.empty()); | |
|
ncarter (slow)
2015/12/05 00:43:33
This CHECK needs to depend on |render_frame_host|,
DaleCurtis
2015/12/05 01:18:02
Whoops, yeah, done.
| |
| 81 } | 84 } |
| 82 | 85 |
| 83 void WebContentsObserverSanityChecker::RenderFrameForInterstitialPageCreated( | 86 void WebContentsObserverSanityChecker::RenderFrameForInterstitialPageCreated( |
| 84 RenderFrameHost* render_frame_host) { | 87 RenderFrameHost* render_frame_host) { |
| 85 // TODO(nick): Record this. | 88 // TODO(nick): Record this. |
| 86 } | 89 } |
| 87 | 90 |
| 88 void WebContentsObserverSanityChecker::RenderFrameHostChanged( | 91 void WebContentsObserverSanityChecker::RenderFrameHostChanged( |
| 89 RenderFrameHost* old_host, | 92 RenderFrameHost* old_host, |
| 90 RenderFrameHost* new_host) { | 93 RenderFrameHost* new_host) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 void WebContentsObserverSanityChecker::DidOpenRequestedURL( | 248 void WebContentsObserverSanityChecker::DidOpenRequestedURL( |
| 246 WebContents* new_contents, | 249 WebContents* new_contents, |
| 247 RenderFrameHost* source_render_frame_host, | 250 RenderFrameHost* source_render_frame_host, |
| 248 const GURL& url, | 251 const GURL& url, |
| 249 const Referrer& referrer, | 252 const Referrer& referrer, |
| 250 WindowOpenDisposition disposition, | 253 WindowOpenDisposition disposition, |
| 251 ui::PageTransition transition) { | 254 ui::PageTransition transition) { |
| 252 AssertRenderFrameExists(source_render_frame_host); | 255 AssertRenderFrameExists(source_render_frame_host); |
| 253 } | 256 } |
| 254 | 257 |
| 258 void WebContentsObserverSanityChecker::MediaStartedPlaying( | |
| 259 const MediaPlayerId& id) { | |
| 260 CHECK(!web_contents_destroyed_); | |
| 261 CHECK(std::find(active_media_players_.begin(), active_media_players_.end(), | |
| 262 id) == active_media_players_.end()); | |
| 263 active_media_players_.push_back(id); | |
| 264 } | |
| 265 | |
| 266 void WebContentsObserverSanityChecker::MediaPaused(const MediaPlayerId& id) { | |
| 267 CHECK(!web_contents_destroyed_); | |
| 268 CHECK(std::find(active_media_players_.begin(), active_media_players_.end(), | |
| 269 id) != active_media_players_.end()); | |
| 270 active_media_players_.erase(std::remove(active_media_players_.begin(), | |
| 271 active_media_players_.end(), id), | |
| 272 active_media_players_.end()); | |
| 273 } | |
| 274 | |
| 255 bool WebContentsObserverSanityChecker::OnMessageReceived( | 275 bool WebContentsObserverSanityChecker::OnMessageReceived( |
| 256 const IPC::Message& message, | 276 const IPC::Message& message, |
| 257 RenderFrameHost* render_frame_host) { | 277 RenderFrameHost* render_frame_host) { |
| 258 // FrameHostMsg_RenderProcessGone is special internal IPC message that | 278 // FrameHostMsg_RenderProcessGone is special internal IPC message that |
| 259 // should not be leaking outside of RenderFrameHost. | 279 // should not be leaking outside of RenderFrameHost. |
| 260 CHECK(message.type() != FrameHostMsg_RenderProcessGone::ID); | 280 CHECK(message.type() != FrameHostMsg_RenderProcessGone::ID); |
| 261 | 281 |
| 262 #if !defined(OS_MACOSX) | 282 #if !defined(OS_MACOSX) |
| 263 // TODO(avi): Disabled because of http://crbug.com/445054 | 283 // TODO(avi): Disabled because of http://crbug.com/445054 |
| 264 AssertRenderFrameExists(render_frame_host); | 284 AssertRenderFrameExists(render_frame_host); |
| 265 #endif | 285 #endif |
| 266 return false; | 286 return false; |
| 267 } | 287 } |
| 268 | 288 |
| 269 void WebContentsObserverSanityChecker::WebContentsDestroyed() { | 289 void WebContentsObserverSanityChecker::WebContentsDestroyed() { |
| 270 CHECK(!web_contents_destroyed_); | 290 CHECK(!web_contents_destroyed_); |
| 271 web_contents_destroyed_ = true; | 291 web_contents_destroyed_ = true; |
| 272 CHECK(ongoing_navigations_.empty()); | 292 CHECK(ongoing_navigations_.empty()); |
| 293 CHECK(active_media_players_.empty()); | |
| 273 } | 294 } |
| 274 | 295 |
| 275 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( | 296 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( |
| 276 WebContents* web_contents) | 297 WebContents* web_contents) |
| 277 : WebContentsObserver(web_contents), web_contents_destroyed_(false) { | 298 : WebContentsObserver(web_contents), web_contents_destroyed_(false) { |
| 278 // Prime the pump with the initial objects. | 299 // Prime the pump with the initial objects. |
| 279 // TODO(nasko): Investigate why this is needed. | 300 // TODO(nasko): Investigate why this is needed. |
| 280 RenderViewCreated(web_contents->GetRenderViewHost()); | 301 RenderViewCreated(web_contents->GetRenderViewHost()); |
| 281 } | 302 } |
| 282 | 303 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str()); | 337 render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str()); |
| 317 } | 338 } |
| 318 | 339 |
| 319 bool WebContentsObserverSanityChecker::NavigationIsOngoing( | 340 bool WebContentsObserverSanityChecker::NavigationIsOngoing( |
| 320 NavigationHandle* navigation_handle) { | 341 NavigationHandle* navigation_handle) { |
| 321 auto it = ongoing_navigations_.find(navigation_handle); | 342 auto it = ongoing_navigations_.find(navigation_handle); |
| 322 return it != ongoing_navigations_.end(); | 343 return it != ongoing_navigations_.end(); |
| 323 } | 344 } |
| 324 | 345 |
| 325 } // namespace content | 346 } // namespace content |
| OLD | NEW |