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

Unified Diff: content/browser/frame_host/frame_tree_node_blame_context.h

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_blame_context.h
diff --git a/content/browser/frame_host/frame_tree_node_blame_context.h b/content/browser/frame_host/frame_tree_node_blame_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..b268c80ae4f7b7a1f42aa7914cad911bb77e3fa6
--- /dev/null
+++ b/content/browser/frame_host/frame_tree_node_blame_context.h
@@ -0,0 +1,49 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_BLAME_CONTEXT_H
+#define CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_BLAME_CONTEXT_H
+
+#include "base/macros.h"
+#include "base/trace_event/blame_context.h"
+
+namespace base {
+namespace trace_event {
+class TracedValue;
+}
+}
+
+namespace content {
+
+class FrameTreeNode;
+
+class FrameTreeNodeBlameContext : public base::trace_event::BlameContext {
Charlie Reis 2016/04/20 16:58:58 This class needs comments explaining the context f
Xiaocheng 2016/04/21 08:01:32 Done.
+ public:
+ FrameTreeNodeBlameContext(FrameTreeNode* node);
+ ~FrameTreeNodeBlameContext() override;
+
+ // There are two patterns for getting argument values of a snapshot, both of
+ // which have potential threading issues:
+ // 1. When taking a snapshot, copy the arguments from the FrameTreeNode;
+ // 2. When a FrameTreeNode navigates, copy the arguments to BlameContext.
+ // We adopt the second approach which looks less troublesome with threading.
+ void UpdateArguments(FrameTreeNode* node);
+ void ClearArguments();
+
+ private:
+ // FIXME: A data race can occur if tracing starts when the main thread is in
+ // the middle of UpdateArguments() or ClearArguments(). AsValueInto() may
+ // generate undefined result in this case.
+ void AsValueInto(base::trace_event::TracedValue* value) override;
+
+ int process_id_;
+ int routing_id_;
+ std::string url_;
Charlie Reis 2016/04/20 16:58:58 Why is a URL being stored in a string? I would re
benjhayden 2016/04/20 17:29:45 That's my fault. You're right, there should be a c
Xiaocheng 2016/04/21 08:01:32 I agree that a URL shouldn't be stored as a string
+
+ DISALLOW_COPY_AND_ASSIGN(FrameTreeNodeBlameContext);
+};
+
+} // content
+
+#endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_BLAME_CONTEXT_H

Powered by Google App Engine
This is Rietveld 408576698