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

Unified Diff: content/public/test/web_contents_observer_sanity_checker.cc

Issue 950223006: Fix RenderFrameHostChanged WebContentsObserver methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes based on Charlie's review. Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/test/web_contents_observer_sanity_checker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/web_contents_observer_sanity_checker.cc
diff --git a/content/public/test/web_contents_observer_sanity_checker.cc b/content/public/test/web_contents_observer_sanity_checker.cc
index e59998baf7fe54f7a8f1c1361686a24cd93984f1..9b0fdccd344afcb497e998b8bdc517559d787996 100644
--- a/content/public/test/web_contents_observer_sanity_checker.cc
+++ b/content/public/test/web_contents_observer_sanity_checker.cc
@@ -4,7 +4,6 @@
#include "content/public/test/web_contents_observer_sanity_checker.h"
-#include "base/debug/stack_trace.h"
#include "base/strings/stringprintf.h"
#include "content/common/frame_messages.h"
#include "content/public/browser/render_frame_host.h"
@@ -80,8 +79,27 @@ void WebContentsObserverSanityChecker::RenderFrameHostChanged(
CHECK(new_host);
CHECK_NE(new_host, old_host);
- // TODO(nasko): Implement consistency checking for RenderFrameHostChanged
- // in follow up CL.
+ if (old_host) {
+ std::pair<int, int> routing_pair =
+ std::make_pair(old_host->GetProcess()->GetID(),
+ old_host->GetRoutingID());
+ bool old_did_exist = !!current_hosts_.erase(routing_pair);
+ if (!old_did_exist) {
+ CHECK(false)
+ << "RenderFrameHostChanged called with old host that did not exist:"
+ << Format(old_host);
+ }
+ }
+
+ std::pair<int, int> routing_pair =
+ std::make_pair(new_host->GetProcess()->GetID(),
+ new_host->GetRoutingID());
+ bool host_exists = !current_hosts_.insert(routing_pair).second;
+ if (host_exists) {
+ CHECK(false)
+ << "RenderFrameHostChanged called more than once for routing pair:"
+ << Format(new_host);
+ }
}
void WebContentsObserverSanityChecker::FrameDeleted(
« no previous file with comments | « content/public/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