Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(603)

Side by Side Diff: content/test/web_contents_observer_sanity_checker.cc

Issue 1478643002: Refactor media out of WebContentsImpl to MediaWebContentsObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix namespace for cast. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/test/web_contents_observer_sanity_checker.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } else if (!was_live) { 77 } else if (!was_live) {
78 // TODO(nick): Clients can easily ignore an unrecognized object, but it 78 // TODO(nick): Clients can easily ignore an unrecognized object, but it
79 // would be useful from a finding-bugs perspective if we could enable this 79 // would be useful from a finding-bugs perspective if we could enable this
80 // check. 80 // check.
81 #if 0 81 #if 0
82 CHECK(false) << "RenderFrameDeleted called for routing pair " 82 CHECK(false) << "RenderFrameDeleted called for routing pair "
83 << Format(render_frame_host) 83 << Format(render_frame_host)
84 << " for which RenderFrameCreated was never called"; 84 << " for which RenderFrameCreated was never called";
85 #endif 85 #endif
86 } 86 }
87
88 // All players should have been paused by this point.
89 for (const auto& id : active_media_players_)
90 CHECK_NE(id.first, render_frame_host);
87 } 91 }
88 92
89 void WebContentsObserverSanityChecker::RenderFrameForInterstitialPageCreated( 93 void WebContentsObserverSanityChecker::RenderFrameForInterstitialPageCreated(
90 RenderFrameHost* render_frame_host) { 94 RenderFrameHost* render_frame_host) {
91 // TODO(nick): Record this. 95 // TODO(nick): Record this.
92 } 96 }
93 97
94 void WebContentsObserverSanityChecker::RenderFrameHostChanged( 98 void WebContentsObserverSanityChecker::RenderFrameHostChanged(
95 RenderFrameHost* old_host, 99 RenderFrameHost* old_host,
96 RenderFrameHost* new_host) { 100 RenderFrameHost* new_host) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 void WebContentsObserverSanityChecker::DidOpenRequestedURL( 255 void WebContentsObserverSanityChecker::DidOpenRequestedURL(
252 WebContents* new_contents, 256 WebContents* new_contents,
253 RenderFrameHost* source_render_frame_host, 257 RenderFrameHost* source_render_frame_host,
254 const GURL& url, 258 const GURL& url,
255 const Referrer& referrer, 259 const Referrer& referrer,
256 WindowOpenDisposition disposition, 260 WindowOpenDisposition disposition,
257 ui::PageTransition transition) { 261 ui::PageTransition transition) {
258 AssertRenderFrameExists(source_render_frame_host); 262 AssertRenderFrameExists(source_render_frame_host);
259 } 263 }
260 264
265 void WebContentsObserverSanityChecker::MediaStartedPlaying(
266 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_.push_back(id);
271 }
272
273 void WebContentsObserverSanityChecker::MediaStoppedPlaying(
274 const MediaPlayerId& id) {
275 CHECK(!web_contents_destroyed_);
276 CHECK(std::find(active_media_players_.begin(), active_media_players_.end(),
277 id) != active_media_players_.end());
278 active_media_players_.erase(std::remove(active_media_players_.begin(),
279 active_media_players_.end(), id),
280 active_media_players_.end());
281 }
282
261 bool WebContentsObserverSanityChecker::OnMessageReceived( 283 bool WebContentsObserverSanityChecker::OnMessageReceived(
262 const IPC::Message& message, 284 const IPC::Message& message,
263 RenderFrameHost* render_frame_host) { 285 RenderFrameHost* render_frame_host) {
264 // FrameHostMsg_RenderProcessGone is special internal IPC message that 286 // FrameHostMsg_RenderProcessGone is special internal IPC message that
265 // should not be leaking outside of RenderFrameHost. 287 // should not be leaking outside of RenderFrameHost.
266 CHECK(message.type() != FrameHostMsg_RenderProcessGone::ID); 288 CHECK(message.type() != FrameHostMsg_RenderProcessGone::ID);
267 289
268 #if !defined(OS_MACOSX) 290 #if !defined(OS_MACOSX)
269 // TODO(avi): Disabled because of http://crbug.com/445054 291 // TODO(avi): Disabled because of http://crbug.com/445054
270 AssertRenderFrameExists(render_frame_host); 292 AssertRenderFrameExists(render_frame_host);
271 #endif 293 #endif
272 return false; 294 return false;
273 } 295 }
274 296
275 void WebContentsObserverSanityChecker::WebContentsDestroyed() { 297 void WebContentsObserverSanityChecker::WebContentsDestroyed() {
276 CHECK(!web_contents_destroyed_); 298 CHECK(!web_contents_destroyed_);
277 web_contents_destroyed_ = true; 299 web_contents_destroyed_ = true;
278 CHECK(ongoing_navigations_.empty()); 300 CHECK(ongoing_navigations_.empty());
301 CHECK(active_media_players_.empty());
279 } 302 }
280 303
281 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( 304 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker(
282 WebContents* web_contents) 305 WebContents* web_contents)
283 : WebContentsObserver(web_contents), web_contents_destroyed_(false) { 306 : WebContentsObserver(web_contents), web_contents_destroyed_(false) {
284 // Prime the pump with the initial objects. 307 // Prime the pump with the initial objects.
285 // TODO(nasko): Investigate why this is needed. 308 // TODO(nasko): Investigate why this is needed.
286 RenderViewCreated(web_contents->GetRenderViewHost()); 309 RenderViewCreated(web_contents->GetRenderViewHost());
287 } 310 }
288 311
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str()); 345 render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str());
323 } 346 }
324 347
325 bool WebContentsObserverSanityChecker::NavigationIsOngoing( 348 bool WebContentsObserverSanityChecker::NavigationIsOngoing(
326 NavigationHandle* navigation_handle) { 349 NavigationHandle* navigation_handle) {
327 auto it = ongoing_navigations_.find(navigation_handle); 350 auto it = ongoing_navigations_.find(navigation_handle);
328 return it != ongoing_navigations_.end(); 351 return it != ongoing_navigations_.end();
329 } 352 }
330 353
331 } // namespace content 354 } // namespace content
OLDNEW
« no previous file with comments | « content/test/web_contents_observer_sanity_checker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698