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

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

Issue 1534933002: Don't process messages sent to dead routing ids. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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/browser/web_contents/web_contents_impl_unittest.cc ('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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 EnsureStableParentValue(render_frame_host); 151 EnsureStableParentValue(render_frame_host);
152 152
153 CHECK(!HasAnyChildren(render_frame_host)) 153 CHECK(!HasAnyChildren(render_frame_host))
154 << "All children should be deleted before a frame is detached."; 154 << "All children should be deleted before a frame is detached.";
155 155
156 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); 156 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host);
157 CHECK(current_hosts_.erase(routing_pair)) 157 CHECK(current_hosts_.erase(routing_pair))
158 << "FrameDeleted called with a non-current RenderFrameHost."; 158 << "FrameDeleted called with a non-current RenderFrameHost.";
159 159
160 if (render_frame_host->GetParent()) 160 if (render_frame_host->GetParent())
161 AssertRenderFrameExists(render_frame_host->GetParent()); 161 AssertRenderFrameExists(render_frame_host->GetParent());
nasko 2015/12/18 15:10:51 This is causing issues when process has died accor
162 } 162 }
163 163
164 void WebContentsObserverSanityChecker::DidStartNavigation( 164 void WebContentsObserverSanityChecker::DidStartNavigation(
165 NavigationHandle* navigation_handle) { 165 NavigationHandle* navigation_handle) {
166 CHECK(!NavigationIsOngoing(navigation_handle)); 166 CHECK(!NavigationIsOngoing(navigation_handle));
167 167
168 CHECK(navigation_handle->GetNetErrorCode() == net::OK); 168 CHECK(navigation_handle->GetNetErrorCode() == net::OK);
169 CHECK(!navigation_handle->HasCommitted()); 169 CHECK(!navigation_handle->HasCommitted());
170 CHECK(!navigation_handle->IsErrorPage()); 170 CHECK(!navigation_handle->IsErrorPage());
171 CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); 171 CHECK_EQ(navigation_handle->GetWebContents(), web_contents());
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 active_media_players_.end()); 310 active_media_players_.end());
311 } 311 }
312 312
313 bool WebContentsObserverSanityChecker::OnMessageReceived( 313 bool WebContentsObserverSanityChecker::OnMessageReceived(
314 const IPC::Message& message, 314 const IPC::Message& message,
315 RenderFrameHost* render_frame_host) { 315 RenderFrameHost* render_frame_host) {
316 // FrameHostMsg_RenderProcessGone is special internal IPC message that 316 // FrameHostMsg_RenderProcessGone is special internal IPC message that
317 // should not be leaking outside of RenderFrameHost. 317 // should not be leaking outside of RenderFrameHost.
318 CHECK(message.type() != FrameHostMsg_RenderProcessGone::ID); 318 CHECK(message.type() != FrameHostMsg_RenderProcessGone::ID);
319 319
320 #if !defined(OS_MACOSX)
321 // TODO(avi): Disabled because of http://crbug.com/445054
nasko 2015/12/18 15:10:51 Yay!
322 AssertRenderFrameExists(render_frame_host); 320 AssertRenderFrameExists(render_frame_host);
323 #endif
324 return false; 321 return false;
325 } 322 }
326 323
327 void WebContentsObserverSanityChecker::WebContentsDestroyed() { 324 void WebContentsObserverSanityChecker::WebContentsDestroyed() {
328 CHECK(!web_contents_destroyed_); 325 CHECK(!web_contents_destroyed_);
329 web_contents_destroyed_ = true; 326 web_contents_destroyed_ = true;
330 CHECK(ongoing_navigations_.empty()); 327 CHECK(ongoing_navigations_.empty());
331 CHECK(active_media_players_.empty()); 328 CHECK(active_media_players_.empty());
332 } 329 }
333 330
334 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( 331 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker(
335 WebContents* web_contents) 332 WebContents* web_contents)
336 : WebContentsObserver(web_contents), web_contents_destroyed_(false) { 333 : WebContentsObserver(web_contents), web_contents_destroyed_(false) {
337 } 334 }
338 335
339 WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() { 336 WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() {
340 CHECK(web_contents_destroyed_); 337 CHECK(web_contents_destroyed_);
341 } 338 }
342 339
343 void WebContentsObserverSanityChecker::AssertRenderFrameExists( 340 void WebContentsObserverSanityChecker::AssertRenderFrameExists(
344 RenderFrameHost* render_frame_host) { 341 RenderFrameHost* render_frame_host) {
345 CHECK(!web_contents_destroyed_); 342 CHECK(!web_contents_destroyed_);
343 CHECK(render_frame_host->IsRenderFrameLive());
344
346 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); 345 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host);
347 346
348 bool render_frame_created_happened = live_routes_.count(routing_pair) != 0; 347 bool render_frame_created_happened = live_routes_.count(routing_pair) != 0;
349 bool render_frame_deleted_happened = deleted_routes_.count(routing_pair) != 0; 348 bool render_frame_deleted_happened = deleted_routes_.count(routing_pair) != 0;
350 349
351 CHECK(render_frame_created_happened) 350 CHECK(render_frame_created_happened)
352 << "A RenderFrameHost pointer was passed to a WebContentsObserver " 351 << "A RenderFrameHost pointer was passed to a WebContentsObserver "
353 << "method, but WebContentsObserver::RenderFrameCreated was never called " 352 << "method, but WebContentsObserver::RenderFrameCreated was never called "
354 << "for that RenderFrameHost: " << Format(render_frame_host); 353 << "for that RenderFrameHost: " << Format(render_frame_host);
355 CHECK(!render_frame_deleted_happened) 354 CHECK(!render_frame_deleted_happened)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if (live_routes_.count(entry.first)) 398 if (live_routes_.count(entry.first))
400 return true; 399 return true;
401 if (current_hosts_.count(entry.first)) 400 if (current_hosts_.count(entry.first))
402 return true; 401 return true;
403 } 402 }
404 } 403 }
405 return false; 404 return false;
406 } 405 }
407 406
408 } // namespace content 407 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698