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

Unified Diff: content/test/web_contents_observer_sanity_checker.cc

Issue 2383573002: [DO NOT COMMIT] Remove chrome::NOTIFICATION_RETARGETING
Patch Set: Rebase on ToT Created 4 years, 2 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/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/test/web_contents_observer_sanity_checker.cc
diff --git a/content/test/web_contents_observer_sanity_checker.cc b/content/test/web_contents_observer_sanity_checker.cc
index 1d85380fc7827c17a154e04b50c26f26e3e561ce..f3a72cb2dede13ee00f41235fa4198622488188b 100644
--- a/content/test/web_contents_observer_sanity_checker.cc
+++ b/content/test/web_contents_observer_sanity_checker.cc
@@ -4,6 +4,7 @@
#include "content/test/web_contents_observer_sanity_checker.h"
+#include "base/debug/stack_trace.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
@@ -23,6 +24,10 @@ namespace {
const char kWebContentsObserverSanityCheckerKey[] =
"WebContentsObserverSanityChecker";
+// Set this variable to true to collect stack traces on observer method calls
+// so duplicate ones can be easily debugged.
+static bool g_collect_stack_traces = true;
+
GlobalRoutingID GetRoutingPair(RenderFrameHost* host) {
if (!host)
return GlobalRoutingID(0, 0);
@@ -282,6 +287,16 @@ void WebContentsObserverSanityChecker::DidOpenRequestedURL(
WindowOpenDisposition disposition,
ui::PageTransition transition) {
AssertRenderFrameExists(source_render_frame_host);
+
+ std::string trace;
+ if (g_collect_stack_traces) {
+ base::debug::StackTrace stack_trace;
+ trace = stack_trace.ToString();
+ }
+
+ bool did_not_exist = created_web_contents_.insert(std::make_pair(new_contents, trace)).second;
+ CHECK(did_not_exist) << "A WebContents was created for the same address as previously "
+ "created one. The original one was allocated by:\n" << trace;
}
void WebContentsObserverSanityChecker::MediaStartedPlaying(
« 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