Commit b5f8e24f authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Add a crash key for the top-level origin.

This is intended to help diagnose crashes and find repro
steps. While in some cases a full URL is available (and is
added), in the case of a render process that may be
out-of-process, full URLs may not be available. This adds
as much info as is available (full URL if possible, just
an origin if not).

BUG=793067
TEST=none

Change-Id: I11134cc5a5238839236b05717db1afe30d19328d
Reviewed-on: https://chromium-review.googlesource.com/818389Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523346}
parent 12d9e764
......@@ -37,6 +37,7 @@
#include "chrome/common/secure_origin_whitelist.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/common_resources.h"
#include "components/crash/core/common/crash_key.h"
#include "components/dom_distiller/core/url_constants.h"
#include "components/version_info/version_info.h"
#include "content/public/common/cdm_info.h"
......@@ -475,9 +476,12 @@ void ChromeContentClient::SetPDFEntryFunctions(
}
#endif
void ChromeContentClient::SetActiveURL(const GURL& url) {
void ChromeContentClient::SetActiveURL(const GURL& url,
std::string top_origin) {
base::debug::SetCrashKeyValue(crash_keys::kActiveURL,
url.possibly_invalid_spec());
static crash_reporter::CrashKeyString<64> top_origin_key("top-origin");
top_origin_key.Set(top_origin);
}
void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo& gpu_info) {
......
......@@ -69,7 +69,7 @@ class ChromeContentClient : public content::ContentClient {
const std::vector<std::unique_ptr<content::PepperPluginInfo>>& plugins);
#endif
void SetActiveURL(const GURL& url) override;
void SetActiveURL(const GURL& url, std::string top_origin) override;
void SetGpuInfo(const gpu::GPUInfo& gpu_info) override;
void AddPepperPlugins(
std::vector<content::PepperPluginInfo>* plugins) override;
......
......@@ -51,7 +51,7 @@ class ScopedPrinterInfo {
// Crash Key Name Constants ////////////////////////////////////////////////////
// The URL of the active tab.
// The URL actively being processed in some way.
extern const char kActiveURL[];
// Installed extensions. |kExtensionID| should be formatted with an integer,
......
......@@ -151,7 +151,10 @@ void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(
if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) &&
!is_allowed_in_web_ui_renderer) {
// Log the URL to help us diagnose any future failures of this CHECK.
GetContentClient()->SetActiveURL(url);
FrameTreeNode* root_node =
render_frame_host->frame_tree_node()->frame_tree()->root();
GetContentClient()->SetActiveURL(
url, root_node->current_url().possibly_invalid_spec());
CHECK(0);
}
}
......
......@@ -235,7 +235,7 @@ void PpapiThread::PreCacheFontForFlash(const void* logfontw) {
}
void PpapiThread::SetActiveURL(const std::string& url) {
GetContentClient()->SetActiveURL(GURL(url));
GetContentClient()->SetActiveURL(GURL(url), std::string());
}
PP_Resource PpapiThread::CreateBrowserFont(
......
......@@ -80,8 +80,14 @@ class CONTENT_EXPORT ContentClient {
ContentRendererClient* renderer() { return renderer_; }
ContentUtilityClient* utility() { return utility_; }
// Sets the currently active URL. Use GURL() to clear the URL.
virtual void SetActiveURL(const GURL& url) {}
// Sets the active URL (the URL of a frame that is navigating or processing an
// IPC message), and the origin of the main frame (for diagnosing crashes).
// Use GURL() or std::string() to clear the URL/origin.
//
// A string is used for the origin because the source of that value may be a
// WebSecurityOrigin or a full URL (if called from the browser process) and a
// string is the lowest-common-denominator.
virtual void SetActiveURL(const GURL& url, std::string top_origin) {}
// Sets the data on the current gpu.
virtual void SetGpuInfo(const gpu::GPUInfo& gpu_info) {}
......
......@@ -1700,7 +1700,9 @@ bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
DCHECK(!frame_->GetDocument().IsNull());
GetContentClient()->SetActiveURL(frame_->GetDocument().Url());
GetContentClient()->SetActiveURL(
frame_->GetDocument().Url(),
frame_->Top()->GetSecurityOrigin().ToString().Utf8());
{
SCOPED_UMA_HISTOGRAM_TIMER("RenderFrameObservers.OnMessageReceived");
......@@ -5508,7 +5510,8 @@ void RenderFrameImpl::OnFailedNavigation(
RenderFrameImpl::PrepareRenderViewForNavigation(
common_params.url, request_params);
GetContentClient()->SetActiveURL(common_params.url);
GetContentClient()->SetActiveURL(
common_params.url, frame_->Top()->GetSecurityOrigin().ToString().Utf8());
// If this frame is navigating cross-process, it may naively assume that this
// is the first navigation in the frame, but this may not actually be the
......@@ -6308,7 +6311,8 @@ void RenderFrameImpl::NavigateInternal(
RenderFrameImpl::PrepareRenderViewForNavigation(
common_params.url, request_params);
GetContentClient()->SetActiveURL(common_params.url);
GetContentClient()->SetActiveURL(
common_params.url, frame_->Top()->GetSecurityOrigin().ToString().Utf8());
// If this frame is navigating cross-process, it may naively assume that this
// is the first navigation in the frame, but this may not actually be the
......
......@@ -1088,9 +1088,13 @@ bool RenderViewImpl::RenderWidgetWillHandleMouseEvent(
bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
WebFrame* main_frame = webview() ? webview()->MainFrame() : nullptr;
if (main_frame && main_frame->IsWebLocalFrame())
if (main_frame) {
GURL active_url;
if (main_frame->IsWebLocalFrame())
active_url = main_frame->ToWebLocalFrame()->GetDocument().Url();
GetContentClient()->SetActiveURL(
main_frame->ToWebLocalFrame()->GetDocument().Url());
active_url, main_frame->Top()->GetSecurityOrigin().ToString().Utf8());
}
// Input IPC messages must not be processed if the RenderView is in
// swapped out state.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment