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

Unified Diff: content/browser/frame_host/frame_tree_node.cc

Issue 1901023003: Introduce browser side FrameTreeNodeBlameContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revised the comments slightly Created 4 years, 8 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
Index: content/browser/frame_host/frame_tree_node.cc
diff --git a/content/browser/frame_host/frame_tree_node.cc b/content/browser/frame_host/frame_tree_node.cc
index 547e872f2210bb42d1f420d3506b42d0f9b50a31..4ece6a130310bc807b0df1fcad519b9c7332b2f9 100644
--- a/content/browser/frame_host/frame_tree_node.cc
+++ b/content/browser/frame_host/frame_tree_node.cc
@@ -15,7 +15,6 @@
#include "content/browser/frame_host/navigation_request.h"
#include "content/browser/frame_host/navigator.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
-#include "content/browser/frame_host/traced_frame_tree_node.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/common/frame_messages.h"
#include "content/common/site_isolation_policy.h"
@@ -101,17 +100,12 @@ FrameTreeNode::FrameTreeNode(
false /* is a potentially trustworthy unique origin */),
pending_sandbox_flags_(blink::WebSandboxFlags::None),
frame_owner_properties_(frame_owner_properties),
- loading_progress_(kLoadingProgressNotStarted) {
+ loading_progress_(kLoadingProgressNotStarted),
+ blame_context_(nullptr) {
std::pair<FrameTreeNodeIdMap::iterator, bool> result =
g_frame_tree_node_id_map.Get().insert(
std::make_pair(frame_tree_node_id_, this));
CHECK(result.second);
-
- TRACE_EVENT_OBJECT_CREATED_WITH_ID(
- "navigation", "FrameTreeNode",
- TRACE_ID_WITH_SCOPE("FrameTreeNode", frame_tree_node_id_));
- // Don't TraceSnapshot() until the RenderFrameHostManager is initialized and
- // calls SetCurrentURL().
}
FrameTreeNode::~FrameTreeNode() {
@@ -124,9 +118,9 @@ FrameTreeNode::~FrameTreeNode() {
g_frame_tree_node_id_map.Get().erase(frame_tree_node_id_);
- TRACE_EVENT_OBJECT_DELETED_WITH_ID(
- "navigation", "FrameTreeNode",
- TRACE_ID_WITH_SCOPE("FrameTreeNode", frame_tree_node_id_));
+ // TODO(xiaochengh): Is this check necessary?
+ if (blame_context_)
+ blame_context_->ClearArguments();
}
void FrameTreeNode::AddObserver(Observer* observer) {
@@ -148,6 +142,11 @@ FrameTreeNode* FrameTreeNode::AddChild(std::unique_ptr<FrameTreeNode> child,
CHECK_EQ(process_id, render_manager_.current_host()->GetProcess()->GetID());
child->set_parent(this);
+ // TODO(xiaochengh): Is it the right timing to initialize BlameContext?
+ // It has to be after setting parent, because BlameContext::parent_id_ cannot
+ // be changed once initialized.
+ child->InitializeBlameContext();
+
// Initialize the RenderFrameHost for the new node. We always create child
// frames in the same SiteInstance as the current frame, and they can swap to
// a different one if they navigate away.
@@ -183,7 +182,12 @@ void FrameTreeNode::RemoveChild(FrameTreeNode* child) {
void FrameTreeNode::ResetForNewProcess() {
current_frame_host()->set_last_committed_url(GURL());
- TraceSnapshot();
+
+ // TODO(xiaochengh): Is this check necessary?
+ if (blame_context_) {
+ blame_context_->UpdateArguments(this);
+ blame_context_->TakeSnapshot();
+ }
// Remove child nodes from the tree, then delete them. This destruction
// operation will notify observers.
@@ -209,7 +213,12 @@ void FrameTreeNode::SetCurrentURL(const GURL& url) {
if (!has_committed_real_load_ && url != GURL(url::kAboutBlankURL))
has_committed_real_load_ = true;
current_frame_host()->set_last_committed_url(url);
- TraceSnapshot();
+
+ // TODO(xiaochengh): Is this check necessary?
+ if (blame_context_) {
+ blame_context_->UpdateArguments(this);
+ blame_context_->TakeSnapshot();
+ }
}
void FrameTreeNode::SetCurrentOrigin(
@@ -478,13 +487,10 @@ void FrameTreeNode::BeforeUnloadCanceled() {
}
}
-void FrameTreeNode::TraceSnapshot() const {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
- "navigation", "FrameTreeNode",
- TRACE_ID_WITH_SCOPE("FrameTreeNode", frame_tree_node_id_),
- std::unique_ptr<base::trace_event::ConvertableToTraceFormat>(
- new TracedFrameTreeNode(*this)));
+void FrameTreeNode::InitializeBlameContext() {
+ DCHECK(!blame_context_);
+ blame_context_ = new FrameTreeNodeBlameContext(this);
+ blame_context_->Initialize();
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698