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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "content/browser/site_instance_impl.h" | 12 #include "content/browser/site_instance_impl.h" |
13 #include "content/common/resource_request_body.h" | |
13 #include "content/public/common/page_state.h" | 14 #include "content/public/common/page_state.h" |
14 #include "content/public/common/referrer.h" | 15 #include "content/public/common/referrer.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 // Represents a session history item for a particular frame. | 19 // Represents a session history item for a particular frame. |
19 // | 20 // |
20 // This class is refcounted and can be shared across multiple NavigationEntries. | 21 // This class is refcounted and can be shared across multiple NavigationEntries. |
21 // For now, it is owned by a single NavigationEntry and only tracks the main | 22 // For now, it is owned by a single NavigationEntry and only tracks the main |
22 // frame. | 23 // frame. |
23 // | 24 // |
24 // If SiteIsolationPolicy::UseSubframeNavigationEntries is true, there will be a | 25 // If SiteIsolationPolicy::UseSubframeNavigationEntries is true, there will be a |
25 // tree of FrameNavigationEntries in each NavigationEntry, one per frame. | 26 // tree of FrameNavigationEntries in each NavigationEntry, one per frame. |
26 // TODO(creis): Share these FrameNavigationEntries across NavigationEntries if | 27 // TODO(creis): Share these FrameNavigationEntries across NavigationEntries if |
27 // the frame hasn't changed. | 28 // the frame hasn't changed. |
28 class CONTENT_EXPORT FrameNavigationEntry | 29 class CONTENT_EXPORT FrameNavigationEntry |
29 : public base::RefCounted<FrameNavigationEntry> { | 30 : public base::RefCounted<FrameNavigationEntry> { |
30 public: | 31 public: |
31 explicit FrameNavigationEntry(int frame_tree_node_id); | 32 explicit FrameNavigationEntry(int frame_tree_node_id); |
32 FrameNavigationEntry(int frame_tree_node_id, | 33 FrameNavigationEntry(int frame_tree_node_id, |
33 const std::string& frame_unique_name, | 34 const std::string& frame_unique_name, |
34 int64_t item_sequence_number, | 35 int64_t item_sequence_number, |
35 int64_t document_sequence_number, | 36 int64_t document_sequence_number, |
36 scoped_refptr<SiteInstanceImpl> site_instance, | 37 scoped_refptr<SiteInstanceImpl> site_instance, |
37 const GURL& url, | 38 const GURL& url, |
38 const Referrer& referrer, | 39 const Referrer& referrer, |
39 const std::string& method, | 40 const std::string& method, |
40 int64_t post_id); | 41 int64_t post_id, |
42 scoped_refptr<ResourceRequestBody> post_data); | |
41 | 43 |
42 // Creates a copy of this FrameNavigationEntry that can be modified | 44 // Creates a copy of this FrameNavigationEntry that can be modified |
43 // independently from the original. | 45 // independently from the original. |
44 FrameNavigationEntry* Clone() const; | 46 FrameNavigationEntry* Clone() const; |
45 | 47 |
46 // Updates all the members of this entry. | 48 // Updates all the members of this entry. |
47 void UpdateEntry(const std::string& frame_unique_name, | 49 void UpdateEntry(const std::string& frame_unique_name, |
48 int64_t item_sequence_number, | 50 int64_t item_sequence_number, |
49 int64_t document_sequence_number, | 51 int64_t document_sequence_number, |
50 SiteInstanceImpl* site_instance, | 52 SiteInstanceImpl* site_instance, |
51 const GURL& url, | 53 const GURL& url, |
52 const Referrer& referrer, | 54 const Referrer& referrer, |
53 const PageState& page_state, | 55 const PageState& page_state, |
54 const std::string& method, | 56 const std::string& method, |
55 int64_t post_id); | 57 int64_t post_id, |
58 scoped_refptr<ResourceRequestBody> post_data); | |
56 | 59 |
57 // The ID of the FrameTreeNode this entry is for. -1 for the main frame, | 60 // The ID of the FrameTreeNode this entry is for. -1 for the main frame, |
58 // since we don't always know the FrameTreeNode ID when creating the overall | 61 // since we don't always know the FrameTreeNode ID when creating the overall |
59 // NavigationEntry. | 62 // NavigationEntry. |
60 // TODO(creis): Consider removing |frame_tree_node_id| in favor of | 63 // TODO(creis): Consider removing |frame_tree_node_id| in favor of |
61 // |frame_unique_name|, if we can move unique name computation to the browser | 64 // |frame_unique_name|, if we can move unique name computation to the browser |
62 // process. | 65 // process. |
63 int frame_tree_node_id() const { return frame_tree_node_id_; } | 66 int frame_tree_node_id() const { return frame_tree_node_id_; } |
64 void set_frame_tree_node_id(int frame_tree_node_id) { | 67 void set_frame_tree_node_id(int frame_tree_node_id) { |
65 frame_tree_node_id_ = frame_tree_node_id; | 68 frame_tree_node_id_ = frame_tree_node_id; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 | 114 |
112 // The HTTP method used to navigate. | 115 // The HTTP method used to navigate. |
113 const std::string& method() const { return method_; } | 116 const std::string& method() const { return method_; } |
114 void set_method(const std::string& method) { method_ = method; } | 117 void set_method(const std::string& method) { method_ = method; } |
115 | 118 |
116 // The id of the post corresponding to this navigation or -1 if the | 119 // The id of the post corresponding to this navigation or -1 if the |
117 // navigation was not a POST. | 120 // navigation was not a POST. |
118 int64_t post_id() const { return post_id_; } | 121 int64_t post_id() const { return post_id_; } |
119 void set_post_id(int64_t post_id) { post_id_ = post_id; } | 122 void set_post_id(int64_t post_id) { post_id_ = post_id; } |
120 | 123 |
124 // The data sent during a POST navigation. Returns nullptr if the navigation | |
125 // is not a POST. | |
126 ResourceRequestBody* post_data() const { return post_data_.get(); } | |
127 void set_post_data(scoped_refptr<ResourceRequestBody> post_data) { | |
128 DCHECK(!post_data || method_ == "POST"); | |
129 post_data_ = post_data; | |
130 } | |
131 | |
121 private: | 132 private: |
122 friend class base::RefCounted<FrameNavigationEntry>; | 133 friend class base::RefCounted<FrameNavigationEntry>; |
123 virtual ~FrameNavigationEntry(); | 134 virtual ~FrameNavigationEntry(); |
124 | 135 |
125 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | 136 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |
126 // Add all new fields to |UpdateEntry|. | 137 // Add all new fields to |UpdateEntry|. |
127 // TODO(creis): These fields have implications for session restore. This is | 138 // TODO(creis): These fields have implications for session restore. This is |
128 // currently managed by NavigationEntry, but the logic will move here. | 139 // currently managed by NavigationEntry, but the logic will move here. |
129 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | 140 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |
130 | 141 |
131 // See the accessors above for descriptions. | 142 // See the accessors above for descriptions. |
132 int frame_tree_node_id_; | 143 int frame_tree_node_id_; |
133 std::string frame_unique_name_; | 144 std::string frame_unique_name_; |
134 int64_t item_sequence_number_; | 145 int64_t item_sequence_number_; |
135 int64_t document_sequence_number_; | 146 int64_t document_sequence_number_; |
136 scoped_refptr<SiteInstanceImpl> site_instance_; | 147 scoped_refptr<SiteInstanceImpl> site_instance_; |
137 GURL url_; | 148 GURL url_; |
138 Referrer referrer_; | 149 Referrer referrer_; |
139 // TODO(creis): Change this to FrameState. | 150 // TODO(creis): Change this to FrameState. |
140 PageState page_state_; | 151 PageState page_state_; |
141 std::string method_; | 152 std::string method_; |
142 int64_t post_id_; | 153 int64_t post_id_; |
154 scoped_refptr<ResourceRequestBody> post_data_; | |
Charlie Reis
2016/04/27 23:00:55
This wasn't stored on NavigationEntry before, was
clamy
2016/04/29 16:07:16
Done.
| |
143 | 155 |
144 DISALLOW_COPY_AND_ASSIGN(FrameNavigationEntry); | 156 DISALLOW_COPY_AND_ASSIGN(FrameNavigationEntry); |
145 }; | 157 }; |
146 | 158 |
147 } // namespace content | 159 } // namespace content |
148 | 160 |
149 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_ | 161 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_ |
OLD | NEW |