OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_NAVIGATION_ENTRY_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_ENTRY_IMPL_H_ |
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_ENTRY_IMPL_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_ENTRY_IMPL_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 "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 class CONTENT_EXPORT NavigationEntryImpl | 27 class CONTENT_EXPORT NavigationEntryImpl |
28 : public NON_EXPORTED_BASE(NavigationEntry) { | 28 : public NON_EXPORTED_BASE(NavigationEntry) { |
29 public: | 29 public: |
30 // Represents a tree of FrameNavigationEntries that make up this joint session | 30 // Represents a tree of FrameNavigationEntries that make up this joint session |
31 // history item. The tree currently only tracks the main frame. | 31 // history item. The tree currently only tracks the main frame. |
32 // TODO(creis): Populate the tree with subframe entries in --site-per-process. | 32 // TODO(creis): Populate the tree with subframe entries in --site-per-process. |
33 struct TreeNode { | 33 struct TreeNode { |
34 TreeNode(FrameNavigationEntry* frame_entry); | 34 TreeNode(FrameNavigationEntry* frame_entry); |
35 ~TreeNode(); | 35 ~TreeNode(); |
36 | 36 |
37 // Returns whether this TreeNode corresponds to |frame_tree_node|. | |
38 bool MatchesFrame(FrameTreeNode* frame_tree_node) const; | |
39 | |
40 // Returns a deep copy of the tree with copies of each node's | 37 // Returns a deep copy of the tree with copies of each node's |
41 // FrameNavigationEntries. We do not yet share FrameNavigationEntries | 38 // FrameNavigationEntries. We do not yet share FrameNavigationEntries |
42 // across trees. | 39 // across trees. |
43 // TODO(creis): For --site-per-process, share FrameNavigationEntries between | 40 // TODO(creis): For --site-per-process, share FrameNavigationEntries between |
44 // NavigationEntries of the same tab. | 41 // NavigationEntries of the same tab. |
45 TreeNode* Clone() const; | 42 TreeNode* Clone() const; |
46 | 43 |
47 // Ref counted pointer that keeps the FrameNavigationEntry alive as long as | 44 // Ref counted pointer that keeps the FrameNavigationEntry alive as long as |
48 // it is needed by this node's NavigationEntry. | 45 // it is needed by this node's NavigationEntry. |
49 scoped_refptr<FrameNavigationEntry> frame_entry; | 46 scoped_refptr<FrameNavigationEntry> frame_entry; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // tab) and one that draws them from a different pool (for use in a new tab). | 127 // tab) and one that draws them from a different pool (for use in a new tab). |
131 NavigationEntryImpl* Clone() const; | 128 NavigationEntryImpl* Clone() const; |
132 | 129 |
133 // Helper functions to construct NavigationParameters for a navigation to this | 130 // Helper functions to construct NavigationParameters for a navigation to this |
134 // NavigationEntry. | 131 // NavigationEntry. |
135 CommonNavigationParams ConstructCommonNavigationParams( | 132 CommonNavigationParams ConstructCommonNavigationParams( |
136 FrameMsg_Navigate_Type::Value navigation_type) const; | 133 FrameMsg_Navigate_Type::Value navigation_type) const; |
137 StartNavigationParams ConstructStartNavigationParams() const; | 134 StartNavigationParams ConstructStartNavigationParams() const; |
138 RequestNavigationParams ConstructRequestNavigationParams( | 135 RequestNavigationParams ConstructRequestNavigationParams( |
139 base::TimeTicks navigation_start, | 136 base::TimeTicks navigation_start, |
140 bool has_committed_real_load, | |
141 bool intended_as_new_entry, | 137 bool intended_as_new_entry, |
142 int pending_offset_to_send, | 138 int pending_offset_to_send, |
143 int current_offset_to_send, | 139 int current_offset_to_send, |
144 int current_length_to_send) const; | 140 int current_length_to_send) const; |
145 | 141 |
146 // Once a navigation entry is committed, we should no longer track several | 142 // Once a navigation entry is committed, we should no longer track several |
147 // pieces of non-persisted state, as documented on the members below. | 143 // pieces of non-persisted state, as documented on the members below. |
148 void ResetForCommit(); | 144 void ResetForCommit(); |
149 | 145 |
150 // Exposes the tree of FrameNavigationEntries that make up this joint session | 146 // Exposes the tree of FrameNavigationEntries that make up this joint session |
151 // history item. | 147 // history item. |
152 // In default Chrome, this tree only has a root node with an unshared | 148 // In default Chrome, this tree only has a root node with an unshared |
153 // FrameNavigationEntry. Subframes are only added to the tree if the | 149 // FrameNavigationEntry. Subframes are only added to the tree if the |
154 // --site-per-process flag is passed. | 150 // --site-per-process flag is passed. |
155 TreeNode* root_node() const { | 151 TreeNode* root_node() const { |
156 return frame_tree_.get(); | 152 return frame_tree_.get(); |
157 } | 153 } |
158 | 154 |
159 // Finds the TreeNode associated with |frame_tree_node_id| to add or update | 155 // Finds the TreeNode associated with |frame_tree_node_id| to add or update |
160 // its FrameNavigationEntry. A new FrameNavigationEntry is added if none | 156 // its FrameNavigationEntry. A new FrameNavigationEntry is added if none |
161 // exists, or else the existing one (which might be shared with other | 157 // exists, or else the existing one (which might be shared with other |
162 // NavigationEntries) is updated with the given parameters. | 158 // NavigationEntries) is updated with the given parameters. |
163 // Does nothing if there is no entry already and |url| is about:blank, since | |
164 // that does not count as a real commit. | |
165 void AddOrUpdateFrameEntry(FrameTreeNode* frame_tree_node, | 159 void AddOrUpdateFrameEntry(FrameTreeNode* frame_tree_node, |
166 SiteInstanceImpl* site_instance, | 160 SiteInstanceImpl* site_instance, |
167 const GURL& url, | 161 const GURL& url, |
168 const Referrer& referrer); | 162 const Referrer& referrer); |
169 | 163 |
170 // Returns whether this entry has a FrameNavigationEntry for the given | |
171 // |frame_tree_node|. | |
172 bool HasFrameEntry(FrameTreeNode* frame_tree_node) const; | |
173 | |
174 void set_unique_id(int unique_id) { | 164 void set_unique_id(int unique_id) { |
175 unique_id_ = unique_id; | 165 unique_id_ = unique_id; |
176 } | 166 } |
177 | 167 |
178 // The SiteInstance represents which pages must share processes. This is a | 168 // The SiteInstance represents which pages must share processes. This is a |
179 // reference counted pointer to a shared SiteInstance. | 169 // reference counted pointer to a shared SiteInstance. |
180 // | 170 // |
181 // Note that the SiteInstance should usually not be changed after it is set, | 171 // Note that the SiteInstance should usually not be changed after it is set, |
182 // but this may happen if the NavigationEntry was cloned and needs to use a | 172 // but this may happen if the NavigationEntry was cloned and needs to use a |
183 // different SiteInstance. | 173 // different SiteInstance. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 return intent_received_timestamp_; | 300 return intent_received_timestamp_; |
311 } | 301 } |
312 | 302 |
313 void set_intent_received_timestamp( | 303 void set_intent_received_timestamp( |
314 const base::TimeTicks intent_received_timestamp) { | 304 const base::TimeTicks intent_received_timestamp) { |
315 intent_received_timestamp_ = intent_received_timestamp; | 305 intent_received_timestamp_ = intent_received_timestamp; |
316 } | 306 } |
317 #endif | 307 #endif |
318 | 308 |
319 private: | 309 private: |
320 // Finds the TreeNode associated with |frame_tree_node|, if any. | |
321 NavigationEntryImpl::TreeNode* FindFrameEntry( | |
322 FrameTreeNode* frame_tree_node) const; | |
323 | |
324 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | 310 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |
325 // Session/Tab restore save portions of this class so that it can be recreated | 311 // Session/Tab restore save portions of this class so that it can be recreated |
326 // later. If you add a new field that needs to be persisted you'll have to | 312 // later. If you add a new field that needs to be persisted you'll have to |
327 // update SessionService/TabRestoreService and Android WebView | 313 // update SessionService/TabRestoreService and Android WebView |
328 // state_serializer.cc appropriately. | 314 // state_serializer.cc appropriately. |
329 // For all new fields, update |Clone| and possibly |ResetForCommit|. | 315 // For all new fields, update |Clone| and possibly |ResetForCommit|. |
330 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | 316 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |
331 | 317 |
332 // Tree of FrameNavigationEntries, one for each frame on the page. | 318 // Tree of FrameNavigationEntries, one for each frame on the page. |
333 // TODO(creis): Once FrameNavigationEntries can be shared across multiple | 319 // TODO(creis): Once FrameNavigationEntries can be shared across multiple |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 // persisted, unless specific data is taken out/put back in at save/restore | 434 // persisted, unless specific data is taken out/put back in at save/restore |
449 // time (see TabNavigation for an example of this). | 435 // time (see TabNavigation for an example of this). |
450 std::map<std::string, base::string16> extra_data_; | 436 std::map<std::string, base::string16> extra_data_; |
451 | 437 |
452 DISALLOW_COPY_AND_ASSIGN(NavigationEntryImpl); | 438 DISALLOW_COPY_AND_ASSIGN(NavigationEntryImpl); |
453 }; | 439 }; |
454 | 440 |
455 } // namespace content | 441 } // namespace content |
456 | 442 |
457 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_ENTRY_IMPL_H_ | 443 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_ENTRY_IMPL_H_ |
OLD | NEW |