Commit d39343e6 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Add mojo message filters on LocalFrame for tracking ActiveURL.

The ActiveURL is now set via messages sent on the LocalFrame.
Hopefully this will help improve crash reports. This use to occur
in RenderFrameImpl::OnMessageReceived.

BUG=993189

Change-Id: I184ef2892b550fb79ced43c2c48315f68dd6c358
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521078Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826367}
parent 46ba0a69
...@@ -967,6 +967,13 @@ void RendererBlinkPlatformImpl::SetRenderingColorSpace( ...@@ -967,6 +967,13 @@ void RendererBlinkPlatformImpl::SetRenderingColorSpace(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RendererBlinkPlatformImpl::SetActiveURL(const blink::WebURL& url,
const blink::WebString& top_url) {
GetContentClient()->SetActiveURL(url, top_url.Utf8());
}
//------------------------------------------------------------------------------
blink::mojom::CodeCacheHost& RendererBlinkPlatformImpl::GetCodeCacheHost() { blink::mojom::CodeCacheHost& RendererBlinkPlatformImpl::GetCodeCacheHost() {
if (!code_cache_host_) { if (!code_cache_host_) {
code_cache_host_ = mojo::SharedRemote<blink::mojom::CodeCacheHost>( code_cache_host_ = mojo::SharedRemote<blink::mojom::CodeCacheHost>(
......
...@@ -210,6 +210,8 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { ...@@ -210,6 +210,8 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
scoped_refptr<base::SingleThreadTaskRunner> owner_task_runner) override; scoped_refptr<base::SingleThreadTaskRunner> owner_task_runner) override;
media::GpuVideoAcceleratorFactories* GetGpuFactories() override; media::GpuVideoAcceleratorFactories* GetGpuFactories() override;
void SetRenderingColorSpace(const gfx::ColorSpace& color_space) override; void SetRenderingColorSpace(const gfx::ColorSpace& color_space) override;
void SetActiveURL(const blink::WebURL& url,
const blink::WebString& top_url) override;
// Tells this platform that the renderer is locked to a site (i.e., a scheme // Tells this platform that the renderer is locked to a site (i.e., a scheme
// plus eTLD+1, such as https://google.com), or to a more specific origin. // plus eTLD+1, such as https://google.com), or to a more specific origin.
......
...@@ -747,6 +747,13 @@ class BLINK_PLATFORM_EXPORT Platform { ...@@ -747,6 +747,13 @@ class BLINK_PLATFORM_EXPORT Platform {
// runs during Chromium's build step). // runs during Chromium's build step).
virtual bool IsTakingV8ContextSnapshot() { return false; } virtual bool IsTakingV8ContextSnapshot() { return false; }
// Crash Reporting -----------------------------------------------------
// Set the active URL for crash reporting. The active URL is stored as crash
// keys and is usually set for the duration of processing an IPC message. To
// unset pass an empty WebURL and WebString.
virtual void SetActiveURL(const WebURL& url, const WebString& top_url) {}
private: private:
static void InitializeMainThreadCommon(Platform* platform, static void InitializeMainThreadCommon(Platform* platform,
std::unique_ptr<Thread> main_thread); std::unique_ptr<Thread> main_thread);
......
...@@ -331,6 +331,43 @@ class ResourceSnapshotForWebBundleImpl ...@@ -331,6 +331,43 @@ class ResourceSnapshotForWebBundleImpl
const Deque<SerializedResource> resources_; const Deque<SerializedResource> resources_;
}; };
class ActiveURLMessageFilter : public mojo::MessageFilter {
public:
explicit ActiveURLMessageFilter(LocalFrame* local_frame)
: local_frame_(local_frame) {}
~ActiveURLMessageFilter() override {
if (debug_url_set_) {
Platform::Current()->SetActiveURL(WebURL(), WebString());
}
}
// mojo::MessageFilter overrides.
bool WillDispatch(mojo::Message* message) override {
// We expect local_frame_ always to be set because this MessageFilter
// is owned by the LocalFrame. We do not want to introduce a Persistent
// reference so we don't cause a cycle. If you hit this CHECK then you
// likely didn't reset your mojo receiver in Detach.
CHECK(local_frame_);
debug_url_set_ = true;
Platform::Current()->SetActiveURL(local_frame_->GetDocument()->Url(),
local_frame_->Top()
->GetSecurityContext()
->GetSecurityOrigin()
->ToString());
return true;
}
void DidDispatchOrReject(mojo::Message* message, bool accepted) override {
Platform::Current()->SetActiveURL(WebURL(), WebString());
debug_url_set_ = false;
}
private:
WeakPersistent<LocalFrame> local_frame_;
bool debug_url_set_ = false;
};
} // namespace } // namespace
template class CORE_TEMPLATE_EXPORT Supplement<LocalFrame>; template class CORE_TEMPLATE_EXPORT Supplement<LocalFrame>;
...@@ -3226,6 +3263,7 @@ void LocalFrame::BindToReceiver( ...@@ -3226,6 +3263,7 @@ void LocalFrame::BindToReceiver(
frame->receiver_.Bind( frame->receiver_.Bind(
std::move(receiver), std::move(receiver),
frame->GetTaskRunner(blink::TaskType::kInternalDefault)); frame->GetTaskRunner(blink::TaskType::kInternalDefault));
frame->receiver_.SetFilter(std::make_unique<ActiveURLMessageFilter>(frame));
} }
void LocalFrame::BindToMainFrameReceiver( void LocalFrame::BindToMainFrameReceiver(
...@@ -3238,6 +3276,8 @@ void LocalFrame::BindToMainFrameReceiver( ...@@ -3238,6 +3276,8 @@ void LocalFrame::BindToMainFrameReceiver(
frame->main_frame_receiver_.Bind( frame->main_frame_receiver_.Bind(
std::move(receiver), std::move(receiver),
frame->GetTaskRunner(blink::TaskType::kInternalDefault)); frame->GetTaskRunner(blink::TaskType::kInternalDefault));
frame->main_frame_receiver_.SetFilter(
std::make_unique<ActiveURLMessageFilter>(frame));
} }
void LocalFrame::BindToHighPriorityReceiver( void LocalFrame::BindToHighPriorityReceiver(
...@@ -3248,6 +3288,8 @@ void LocalFrame::BindToHighPriorityReceiver( ...@@ -3248,6 +3288,8 @@ void LocalFrame::BindToHighPriorityReceiver(
high_priority_frame_receiver_.Bind( high_priority_frame_receiver_.Bind(
std::move(receiver), std::move(receiver),
GetTaskRunner(blink::TaskType::kInternalHighPriorityLocalFrame)); GetTaskRunner(blink::TaskType::kInternalHighPriorityLocalFrame));
high_priority_frame_receiver_.SetFilter(
std::make_unique<ActiveURLMessageFilter>(this));
} }
void LocalFrame::BindTextFragmentSelectorProducer( void LocalFrame::BindTextFragmentSelectorProducer(
......
...@@ -66,6 +66,10 @@ class HeapMojoAssociatedReceiver { ...@@ -66,6 +66,10 @@ class HeapMojoAssociatedReceiver {
return wrapper_->associated_receiver().WaitForIncomingCall(); return wrapper_->associated_receiver().WaitForIncomingCall();
} }
void SetFilter(std::unique_ptr<mojo::MessageFilter> filter) {
wrapper_->associated_receiver().SetFilter(std::move(filter));
}
void Trace(Visitor* visitor) const { visitor->Trace(wrapper_); } void Trace(Visitor* visitor) const { visitor->Trace(wrapper_); }
private: private:
......
...@@ -69,6 +69,9 @@ class HeapMojoReceiver { ...@@ -69,6 +69,9 @@ class HeapMojoReceiver {
bool WaitForIncomingCall() { bool WaitForIncomingCall() {
return wrapper_->receiver().WaitForIncomingCall(); return wrapper_->receiver().WaitForIncomingCall();
} }
void SetFilter(std::unique_ptr<mojo::MessageFilter> filter) {
wrapper_->receiver().SetFilter(std::move(filter));
}
void Trace(Visitor* visitor) const { visitor->Trace(wrapper_); } void Trace(Visitor* visitor) const { visitor->Trace(wrapper_); }
......
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