OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_ |
6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "content/browser/site_instance_impl.h" | 10 #include "content/browser/site_instance_impl.h" |
11 #include "content/public/common/page_state.h" | 11 #include "content/public/common/page_state.h" |
12 #include "content/public/common/referrer.h" | 12 #include "content/public/common/referrer.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 // Represents a session history item for a particular frame. | 16 // Represents a session history item for a particular frame. |
17 // | 17 // |
18 // This class is refcounted and can be shared across multiple NavigationEntries. | 18 // This class is refcounted and can be shared across multiple NavigationEntries. |
19 // For now, it is owned by a single NavigationEntry and only tracks the main | 19 // For now, it is owned by a single NavigationEntry and only tracks the main |
20 // frame. | 20 // frame. |
21 // | 21 // |
22 // TODO(creis): In --site-per-process, fill in a tree of FrameNavigationEntries | 22 // If SiteIsolationPolicy::UseSubframeNavigationEntries is true, there will be a |
23 // in each NavigationEntry, one per frame. FrameNavigationEntries may be shared | 23 // tree of FrameNavigationEntries in each NavigationEntry, one per frame. |
24 // across NavigationEntries if the frame hasn't changed. | 24 // TODO(creis): Share these FrameNavigationEntries across NavigationEntries if |
25 // the frame hasn't changed. | |
25 class CONTENT_EXPORT FrameNavigationEntry | 26 class CONTENT_EXPORT FrameNavigationEntry |
26 : public base::RefCounted<FrameNavigationEntry> { | 27 : public base::RefCounted<FrameNavigationEntry> { |
27 public: | 28 public: |
28 // TODO(creis): We should not use FTN IDs here, since they will change if you | |
29 // leave a page and come back later. We should evaluate whether Blink's | |
30 // unique names would work instead, similar to HistoryNode. | |
31 explicit FrameNavigationEntry(int frame_tree_node_id); | 29 explicit FrameNavigationEntry(int frame_tree_node_id); |
32 FrameNavigationEntry(int frame_tree_node_id, | 30 FrameNavigationEntry(int frame_tree_node_id, |
31 std::string frame_unique_name, | |
33 int64 item_sequence_number, | 32 int64 item_sequence_number, |
34 int64 document_sequence_number, | 33 int64 document_sequence_number, |
35 SiteInstanceImpl* site_instance, | 34 SiteInstanceImpl* site_instance, |
36 const GURL& url, | 35 const GURL& url, |
37 const Referrer& referrer); | 36 const Referrer& referrer); |
38 | 37 |
39 // Creates a copy of this FrameNavigationEntry that can be modified | 38 // Creates a copy of this FrameNavigationEntry that can be modified |
40 // independently from the original. | 39 // independently from the original. |
41 FrameNavigationEntry* Clone() const; | 40 FrameNavigationEntry* Clone() const; |
42 | 41 |
43 // Updates all the members of this entry. | 42 // Updates all the members of this entry. |
44 void UpdateEntry(int64 item_sequence_number, | 43 void UpdateEntry(std::string frame_unique_name, |
dcheng
2015/11/09 23:53:33
Nit: const std::string& here and elsewhere.
Charlie Reis
2015/11/10 00:08:01
Done.
| |
44 int64 item_sequence_number, | |
45 int64 document_sequence_number, | 45 int64 document_sequence_number, |
46 SiteInstanceImpl* site_instance, | 46 SiteInstanceImpl* site_instance, |
47 const GURL& url, | 47 const GURL& url, |
48 const Referrer& referrer, | 48 const Referrer& referrer, |
49 const PageState& page_state); | 49 const PageState& page_state); |
50 | 50 |
51 // The ID of the FrameTreeNode this entry is for. -1 for the main frame, | 51 // The ID of the FrameTreeNode this entry is for. -1 for the main frame, |
52 // since we don't always know the FrameTreeNode ID when creating the overall | 52 // since we don't always know the FrameTreeNode ID when creating the overall |
53 // NavigationEntry. | 53 // NavigationEntry. |
54 // TODO(creis): Replace with frame sequence number or unique name. | 54 // TODO(creis): Consider removing |frame_tree_node_id| in favor of |
55 // |frame_unique_name|, if we can move unique name computation to the browser | |
56 // process. | |
55 int frame_tree_node_id() const { return frame_tree_node_id_; } | 57 int frame_tree_node_id() const { return frame_tree_node_id_; } |
56 | 58 |
59 // The unique name of the frame this entry is for. This is a stable name for | |
60 // the frame based on its position in the tree and relation to other named | |
61 // frames, which does not change after cross-process navigations or restores. | |
62 // Only the main frame can have an empty name. | |
63 // | |
64 // This is unique relative to other frames in the same page, but not among | |
65 // other pages (i.e., not globally unique). | |
66 std::string frame_unique_name() const { return frame_unique_name_; } | |
67 void set_frame_unique_name(std::string frame_unique_name) { | |
68 frame_unique_name_ = frame_unique_name; | |
69 } | |
70 | |
57 // Keeps track of where this entry belongs in the frame's session history. | 71 // Keeps track of where this entry belongs in the frame's session history. |
58 // The item sequence number identifies each stop in the back/forward history | 72 // The item sequence number identifies each stop in the back/forward history |
59 // and is globally unique. The document sequence number increments for each | 73 // and is globally unique. The document sequence number increments for each |
60 // new document and is also globally unique. In-page navigations get a new | 74 // new document and is also globally unique. In-page navigations get a new |
61 // item sequence number but the same document sequence number. These numbers | 75 // item sequence number but the same document sequence number. These numbers |
62 // should not change once assigned. | 76 // should not change once assigned. |
63 void set_item_sequence_number(int64 item_sequence_number); | 77 void set_item_sequence_number(int64 item_sequence_number); |
64 int64 item_sequence_number() const { return item_sequence_number_; } | 78 int64 item_sequence_number() const { return item_sequence_number_; } |
65 void set_document_sequence_number(int64 document_sequence_number); | 79 void set_document_sequence_number(int64 document_sequence_number); |
66 int64 document_sequence_number() const { return document_sequence_number_; } | 80 int64 document_sequence_number() const { return document_sequence_number_; } |
(...skipping 17 matching lines...) Expand all Loading... | |
84 const Referrer& referrer() const { return referrer_; } | 98 const Referrer& referrer() const { return referrer_; } |
85 | 99 |
86 void set_page_state(const PageState& page_state) { page_state_ = page_state; } | 100 void set_page_state(const PageState& page_state) { page_state_ = page_state; } |
87 const PageState& page_state() const { return page_state_; } | 101 const PageState& page_state() const { return page_state_; } |
88 | 102 |
89 private: | 103 private: |
90 friend class base::RefCounted<FrameNavigationEntry>; | 104 friend class base::RefCounted<FrameNavigationEntry>; |
91 virtual ~FrameNavigationEntry(); | 105 virtual ~FrameNavigationEntry(); |
92 | 106 |
93 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | 107 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |
94 // For all new fields, update |Clone|. | 108 // Add all new fields to |UpdateEntry|. |
95 // TODO(creis): These fields have implications for session restore. This is | 109 // TODO(creis): These fields have implications for session restore. This is |
96 // currently managed by NavigationEntry, but the logic will move here. | 110 // currently managed by NavigationEntry, but the logic will move here. |
97 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | 111 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |
98 | 112 |
99 // See the accessors above for descriptions. | 113 // See the accessors above for descriptions. |
100 int frame_tree_node_id_; | 114 int frame_tree_node_id_; |
115 std::string frame_unique_name_; | |
101 int64 item_sequence_number_; | 116 int64 item_sequence_number_; |
102 int64 document_sequence_number_; | 117 int64 document_sequence_number_; |
103 scoped_refptr<SiteInstanceImpl> site_instance_; | 118 scoped_refptr<SiteInstanceImpl> site_instance_; |
104 GURL url_; | 119 GURL url_; |
105 Referrer referrer_; | 120 Referrer referrer_; |
106 // TODO(creis): Change this to FrameState. | 121 // TODO(creis): Change this to FrameState. |
107 PageState page_state_; | 122 PageState page_state_; |
108 | 123 |
109 DISALLOW_COPY_AND_ASSIGN(FrameNavigationEntry); | 124 DISALLOW_COPY_AND_ASSIGN(FrameNavigationEntry); |
110 }; | 125 }; |
111 | 126 |
112 } // namespace content | 127 } // namespace content |
113 | 128 |
114 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_ | 129 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_ |
OLD | NEW |