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

Side by Side 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: Fix compile error Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_BLAME_CONTEXT_H
6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_BLAME_CONTEXT_H
7
8 #include "base/macros.h"
9 #include "base/synchronization/lock.h"
10 #include "base/trace_event/blame_context.h"
11 #include "url/gurl.h"
12
13 namespace base {
14 namespace trace_event {
15 class TracedValue;
16 }
17 }
18
19 namespace content {
20
21 class FrameTreeNode;
22
23 // FrameTreeNodeBlameContext is a helper class for tracing snapshots of each
24 // FrameTreeNode and attributing browser activities to frames (when possible),
25 // in the framework of FrameBlamer (crbug.com/546021).
26 //
27 //
28 // *** LIFECYCLE ***
29 //
30 // Each FrameTreeNodeBlameContext is owned by a FrameTreeNode, and each
31 // FrameTreeNode owns at most one FrameTreeNodeBlameContext. The lifecycle
32 // of each FrameTreeNodeBlameContext is managed by its owner node.
33 // Creation: For each root FrameTreeNode, its blame context is created right
34 // after the node's intialization. For each other node, its blame context is
35 // created after the node is attached to a parent node. If the owner node is
36 // reattached to a different parent node, its original blame context gets
37 // destroyed and replaced by a new one.
38 // Update: Whenever the owner node navigates, it calls UpdateArguments() of
39 // its blame context to update its value. The is the only way to update the
40 // value of a FrameTreeNodeBlameContext.
41 // Deletion: A FrameTreeNodeBlameContext is deleted when its owner node is
42 // deleted or reattached to a different parent node.
43 //
44 //
45 // *** THREAD SAFETY ***
46 //
47 // FrameTreeNodeBlameContexts live in the main thread, with their lifecycle
48 // managed by their owner FrameTreeNodes. The creation, update and deletion
49 // can only be done in the main thread. However, a FrameTreeNodeBlameContext
50 // can be read from a different thread, e.g., from the File thread at tracing
51 // startup. To prevent data race while minimizing architectural impact, locks
52 // are applied so that AsValueInto() will be blocked when the main thread is
53 // running UpdateArguments().
54
55 class FrameTreeNodeBlameContext : public base::trace_event::BlameContext {
56 public:
57 // Public functions are callable only from the main thread by the owner node.
58 FrameTreeNodeBlameContext(FrameTreeNode* node);
dcheng 2016/04/26 20:06:29 Nit: explicit
59 ~FrameTreeNodeBlameContext() override;
60 void UpdateArguments();
61
62 private:
63 void AsValueInto(base::trace_event::TracedValue* value) override;
64
65 // Buffered information of the owner node, maintained by UpdateArguments().
66 int process_id_;
67 int routing_id_;
68 GURL url_;
69
70 FrameTreeNode* const owner_;
71
72 mutable base::Lock lock_;
73
74 DISALLOW_COPY_AND_ASSIGN(FrameTreeNodeBlameContext);
75 };
76
77 } // content
78
79 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_BLAME_CONTEXT_H
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree_node.cc ('k') | content/browser/frame_host/frame_tree_node_blame_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698