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

Side by Side Diff: content/browser/frame_host/navigation_entry_impl.h

Issue 281653003: DRAFT CL: Add FrameNavigationEntry and track subframe session histories. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 5 years, 9 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 | Annotate | Revision Log
OLDNEW
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/time/time.h" 11 #include "base/time/time.h"
11 #include "content/browser/frame_host/frame_navigation_entry.h" 12 #include "content/browser/frame_host/frame_navigation_entry.h"
13 #include "content/browser/frame_host/frame_tree_node.h"
12 #include "content/browser/site_instance_impl.h" 14 #include "content/browser/site_instance_impl.h"
13 #include "content/common/frame_message_enums.h" 15 #include "content/common/frame_message_enums.h"
14 #include "content/public/browser/favicon_status.h" 16 #include "content/public/browser/favicon_status.h"
15 #include "content/public/browser/global_request_id.h" 17 #include "content/public/browser/global_request_id.h"
16 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/common/page_state.h" 19 #include "content/public/common/page_state.h"
18 #include "content/public/common/ssl_status.h" 20 #include "content/public/common/ssl_status.h"
19 21
20 namespace content { 22 namespace content {
21 class NavigationControllerImpl; 23 class NavigationControllerImpl;
22 struct CommitNavigationParams; 24 struct CommitNavigationParams;
23 struct CommonNavigationParams; 25 struct CommonNavigationParams;
24 struct HistoryNavigationParams; 26 struct HistoryNavigationParams;
25 struct StartNavigationParams; 27 struct StartNavigationParams;
26 28
27 class CONTENT_EXPORT NavigationEntryImpl 29 class CONTENT_EXPORT NavigationEntryImpl
28 : public NON_EXPORTED_BASE(NavigationEntry) { 30 : public NON_EXPORTED_BASE(NavigationEntry) {
29 public: 31 public:
30 // Represents a tree of FrameNavigationEntries that make up this joint session 32 // Represents a tree of FrameNavigationEntries that make up this joint session
31 // history item. The tree currently only tracks the main frame. 33 // history item. The tree currently only tracks the main frame.
32 // TODO(creis): Populate the tree with subframe entries in --site-per-process. 34 // TODO(creis): Populate the tree with subframe entries in --site-per-process.
33 struct TreeNode { 35 struct TreeNode {
34 TreeNode(FrameNavigationEntry* frame_entry); 36 TreeNode(NavigationEntryImpl* entry,
37 FrameNavigationEntry* frame_entry);
35 ~TreeNode(); 38 ~TreeNode();
36 39
37 // Returns a deep copy of the tree with copies of each node's 40 // Returns a deep copy of the tree with copies of each node's
38 // FrameNavigationEntries. We do not yet share FrameNavigationEntries 41 // FrameNavigationEntries. We do not yet share FrameNavigationEntries
39 // across trees. 42 // across trees.
40 // TODO(creis): For --site-per-process, share FrameNavigationEntries between 43 // TODO(creis): For --site-per-process, share FrameNavigationEntries between
41 // NavigationEntries of the same tab. 44 // NavigationEntries of the same tab.
42 TreeNode* Clone() const; 45 TreeNode* Clone() const;
43 46
47 void SetFrameEntry(FrameNavigationEntry* new_frame_entry);
48
49 // Pointer to the NavigationEntry that owns us.
50 // TODO(creis): Remove this.
51 NavigationEntryImpl* entry;
52
44 // Ref counted pointer that keeps the FrameNavigationEntry alive as long as 53 // Ref counted pointer that keeps the FrameNavigationEntry alive as long as
45 // it is needed by this node's NavigationEntry. 54 // it is needed by this node's NavigationEntry.
46 scoped_refptr<FrameNavigationEntry> frame_entry; 55 scoped_refptr<FrameNavigationEntry> frame_entry;
56
57 // List of child TreeNodes, which will be deleted when this node is.
58 ScopedVector<TreeNode> children;
47 }; 59 };
48 60
49 static NavigationEntryImpl* FromNavigationEntry(NavigationEntry* entry); 61 static NavigationEntryImpl* FromNavigationEntry(NavigationEntry* entry);
50 62
51 // The value of bindings() before it is set during commit. 63 // The value of bindings() before it is set during commit.
52 static int kInvalidBindings; 64 static int kInvalidBindings;
53 65
54 NavigationEntryImpl(); 66 NavigationEntryImpl();
55 NavigationEntryImpl(SiteInstanceImpl* instance, 67 NavigationEntryImpl(SiteInstanceImpl* instance,
56 int page_id, 68 int page_id,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const base::string16& data) override; 120 const base::string16& data) override;
109 bool GetExtraData(const std::string& key, 121 bool GetExtraData(const std::string& key,
110 base::string16* data) const override; 122 base::string16* data) const override;
111 void ClearExtraData(const std::string& key) override; 123 void ClearExtraData(const std::string& key) override;
112 void SetHttpStatusCode(int http_status_code) override; 124 void SetHttpStatusCode(int http_status_code) override;
113 int GetHttpStatusCode() const override; 125 int GetHttpStatusCode() const override;
114 void SetRedirectChain(const std::vector<GURL>& redirects) override; 126 void SetRedirectChain(const std::vector<GURL>& redirects) override;
115 const std::vector<GURL>& GetRedirectChain() const override; 127 const std::vector<GURL>& GetRedirectChain() const override;
116 bool IsRestored() const override; 128 bool IsRestored() const override;
117 129
130 TreeNode* root_node() const {
131 return frame_tree_.get();
132 }
133
118 // Creates a copy of this NavigationEntryImpl that can be modified 134 // Creates a copy of this NavigationEntryImpl that can be modified
119 // independently from the original. Does not copy any value that would be 135 // independently from the original. Does not copy any value that would be
120 // cleared in ResetForCommit. 136 // cleared in ResetForCommit.
121 // TODO(creis): Once we start sharing FrameNavigationEntries between 137 // TODO(creis): Once we start sharing FrameNavigationEntries between
122 // NavigationEntryImpls, we will need to support two versions of Clone: one 138 // NavigationEntryImpls, we will need to support two versions of Clone: one
123 // that shares the existing FrameNavigationEntries (for use within the same 139 // that shares the existing FrameNavigationEntries (for use within the same
124 // tab) and one that draws them from a different pool (for use in a new tab). 140 // tab) and one that draws them from a different pool (for use in a new tab).
125 NavigationEntryImpl* Clone() const; 141 NavigationEntryImpl* Clone() const;
126 142
143 // Clears the frame tree before adding new TreeNodes to it.
144 void ResetFrameTree();
145
146 TreeNode* GetTreeNodeForFrame(FrameTreeNode* frame_tree_node);
147
148 // Returns the FrameNavigationEntry corresponding to |frame_tree_node|.
149 FrameNavigationEntry* GetFrameEntryForFrame(FrameTreeNode* frame_tree_node);
150
127 // Once a navigation entry is committed, we should no longer track several 151 // Once a navigation entry is committed, we should no longer track several
128 // pieces of non-persisted state, as documented on the members below. 152 // pieces of non-persisted state, as documented on the members below.
129 void ResetForCommit(); 153 void ResetForCommit();
130 154
131 void set_unique_id(int unique_id) { 155 void set_unique_id(int unique_id) {
132 unique_id_ = unique_id; 156 unique_id_ = unique_id;
133 } 157 }
134 158
135 // The SiteInstance represents which pages must share processes. This is a 159 // The SiteInstance represents which pages must share processes. This is a
136 // reference counted pointer to a shared SiteInstance. 160 // reference counted pointer to a shared SiteInstance.
137 // 161 //
138 // Note that the SiteInstance should usually not be changed after it is set, 162 // Note that the SiteInstance should usually not be changed after it is set,
139 // but this may happen if the NavigationEntry was cloned and needs to use a 163 // but this may happen if the NavigationEntry was cloned and needs to use a
140 // different SiteInstance. 164 // different SiteInstance.
165 // TODO(creis): This should live on the FNE, not here.
141 void set_site_instance(SiteInstanceImpl* site_instance); 166 void set_site_instance(SiteInstanceImpl* site_instance);
142 SiteInstanceImpl* site_instance() const { 167 SiteInstanceImpl* site_instance() const {
143 return frame_tree_->frame_entry->site_instance(); 168 return frame_tree_->frame_entry->site_instance();
144 } 169 }
145 170
146 // The |source_site_instance| is used to identify the SiteInstance of the 171 // The |source_site_instance| is used to identify the SiteInstance of the
147 // frame that initiated the navigation. 172 // frame that initiated the navigation.
148 void set_source_site_instance(SiteInstanceImpl* source_site_instance); 173 void set_source_site_instance(SiteInstanceImpl* source_site_instance);
149 SiteInstanceImpl* source_site_instance() const { 174 SiteInstanceImpl* source_site_instance() const {
150 return source_site_instance_.get(); 175 return source_site_instance_.get();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 268
244 // Whether this (pending) navigation should clear the session history. Resets 269 // Whether this (pending) navigation should clear the session history. Resets
245 // to false after commit. 270 // to false after commit.
246 bool should_clear_history_list() const { 271 bool should_clear_history_list() const {
247 return should_clear_history_list_; 272 return should_clear_history_list_;
248 } 273 }
249 void set_should_clear_history_list(bool should_clear_history_list) { 274 void set_should_clear_history_list(bool should_clear_history_list) {
250 should_clear_history_list_ = should_clear_history_list; 275 should_clear_history_list_ = should_clear_history_list;
251 } 276 }
252 277
253 // Indicates which FrameTreeNode to navigate. Currently only used if the
254 // --site-per-process flag is passed.
255 int64 frame_tree_node_id() const {
256 return frame_tree_node_id_;
257 }
258 void set_frame_tree_node_id(int64 frame_tree_node_id) {
259 frame_tree_node_id_ = frame_tree_node_id;
260 }
261
262 // Returns the history URL for a data URL to use in Blink. 278 // Returns the history URL for a data URL to use in Blink.
263 GURL GetHistoryURLForDataURL() const; 279 GURL GetHistoryURLForDataURL() const;
264 280
265 CommonNavigationParams ConstructCommonNavigationParams( 281 CommonNavigationParams ConstructCommonNavigationParams(
282 const FrameNavigationEntry& frame_entry,
266 FrameMsg_Navigate_Type::Value navigation_type) const; 283 FrameMsg_Navigate_Type::Value navigation_type) const;
267 CommitNavigationParams ConstructCommitNavigationParams( 284 CommitNavigationParams ConstructCommitNavigationParams(
268 base::TimeTicks navigation_start) const; 285 base::TimeTicks navigation_start) const;
286 // TODO(creis): NavigationEntry should not depend on NavigationController.
269 HistoryNavigationParams ConstructHistoryNavigationParams( 287 HistoryNavigationParams ConstructHistoryNavigationParams(
288 const FrameNavigationEntry& frame_entry,
270 NavigationControllerImpl* controller) const; 289 NavigationControllerImpl* controller) const;
271 StartNavigationParams ConstructStartNavigationParams() const; 290 StartNavigationParams ConstructStartNavigationParams() const;
272 291
273 #if defined(OS_ANDROID) 292 #if defined(OS_ANDROID)
274 base::TimeTicks intent_received_timestamp() const { 293 base::TimeTicks intent_received_timestamp() const {
275 return intent_received_timestamp_; 294 return intent_received_timestamp_;
276 } 295 }
277 296
278 void set_intent_received_timestamp( 297 void set_intent_received_timestamp(
279 const base::TimeTicks intent_received_timestamp) { 298 const base::TimeTicks intent_received_timestamp) {
280 intent_received_timestamp_ = intent_received_timestamp; 299 intent_received_timestamp_ = intent_received_timestamp;
281 } 300 }
282 #endif 301 #endif
283 302
284 private: 303 private:
285 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 304 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
286 // Session/Tab restore save portions of this class so that it can be recreated 305 // Session/Tab restore save portions of this class so that it can be recreated
287 // later. If you add a new field that needs to be persisted you'll have to 306 // later. If you add a new field that needs to be persisted you'll have to
288 // update SessionService/TabRestoreService and Android WebView 307 // update SessionService/TabRestoreService and Android WebView
289 // state_serializer.cc appropriately. 308 // state_serializer.cc appropriately.
290 // For all new fields, update |Clone| and possibly |ResetForCommit|. 309 // For all new fields, update |Clone| and possibly |ResetForCommit|.
291 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 310 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
292 311
312 typedef base::hash_map<int64, TreeNode*> FramesToItems;
313 FramesToItems frames_to_items_;
314
315 typedef base::hash_map<std::string, TreeNode*> UniqueNamesToItems;
316 UniqueNamesToItems unique_names_to_items_;
317
293 // Tree of FrameNavigationEntries, one for each frame on the page. 318 // Tree of FrameNavigationEntries, one for each frame on the page.
294 // TODO(creis): Once FrameNavigationEntries can be shared across multiple 319 // TODO(creis): Once FrameNavigationEntries can be shared across multiple
295 // NavigationEntries, we will need to update Session/Tab restore. For now, 320 // NavigationEntries, we will need to update Session/Tab restore. For now,
296 // each NavigationEntry's tree has its own unshared FrameNavigationEntries. 321 // each NavigationEntry's tree has its own unshared FrameNavigationEntries.
297 scoped_ptr<TreeNode> frame_tree_; 322 scoped_ptr<TreeNode> frame_tree_;
298 323
299 // See the accessors above for descriptions. 324 // See the accessors above for descriptions.
300 int unique_id_; 325 int unique_id_;
301 // TODO(creis): Persist bindings_. http://crbug.com/173672. 326 // TODO(creis): Persist bindings_. http://crbug.com/173672.
302 int bindings_; 327 int bindings_;
303 PageType page_type_; 328 PageType page_type_;
304 GURL virtual_url_; 329 GURL virtual_url_;
305 bool update_virtual_url_with_url_; 330 bool update_virtual_url_with_url_;
306 base::string16 title_; 331 base::string16 title_;
307 FaviconStatus favicon_; 332 FaviconStatus favicon_;
308 PageState page_state_;
309 int32 page_id_; 333 int32 page_id_;
310 SSLStatus ssl_; 334 SSLStatus ssl_;
311 ui::PageTransition transition_type_; 335 ui::PageTransition transition_type_;
312 GURL user_typed_url_; 336 GURL user_typed_url_;
313 bool has_post_data_; 337 bool has_post_data_;
314 int64 post_id_; 338 int64 post_id_;
315 RestoreType restore_type_; 339 RestoreType restore_type_;
316 GURL original_request_url_; 340 GURL original_request_url_;
317 bool is_overriding_user_agent_; 341 bool is_overriding_user_agent_;
318 base::Time timestamp_; 342 base::Time timestamp_;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 bool should_clear_history_list_; 413 bool should_clear_history_list_;
390 414
391 // Set when this entry should be able to access local file:// resources. This 415 // Set when this entry should be able to access local file:// resources. This
392 // value is not needed after the entry commits and is not persisted. 416 // value is not needed after the entry commits and is not persisted.
393 bool can_load_local_resources_; 417 bool can_load_local_resources_;
394 418
395 // If not empty, the name of the frame to navigate. This field is not 419 // If not empty, the name of the frame to navigate. This field is not
396 // persisted, because it is currently only used in tests. 420 // persisted, because it is currently only used in tests.
397 std::string frame_to_navigate_; 421 std::string frame_to_navigate_;
398 422
399 // If not -1, this indicates which FrameTreeNode to navigate. This field is
400 // not persisted because it is experimental and only used when the
401 // --site-per-process flag is passed. It is cleared in |ResetForCommit|
402 // because we only use it while the navigation is pending.
403 // TODO(creis): Move this to FrameNavigationEntry.
404 int64 frame_tree_node_id_;
405
406 #if defined(OS_ANDROID) 423 #if defined(OS_ANDROID)
407 // The time at which Chrome received the Android Intent that triggered this 424 // The time at which Chrome received the Android Intent that triggered this
408 // URL load operation. Reset at commit and not persisted. 425 // URL load operation. Reset at commit and not persisted.
409 base::TimeTicks intent_received_timestamp_; 426 base::TimeTicks intent_received_timestamp_;
410 #endif 427 #endif
411 428
412 // Used to store extra data to support browser features. This member is not 429 // Used to store extra data to support browser features. This member is not
413 // persisted, unless specific data is taken out/put back in at save/restore 430 // persisted, unless specific data is taken out/put back in at save/restore
414 // time (see TabNavigation for an example of this). 431 // time (see TabNavigation for an example of this).
415 std::map<std::string, base::string16> extra_data_; 432 std::map<std::string, base::string16> extra_data_;
416 433
417 DISALLOW_COPY_AND_ASSIGN(NavigationEntryImpl); 434 DISALLOW_COPY_AND_ASSIGN(NavigationEntryImpl);
418 }; 435 };
419 436
420 } // namespace content 437 } // namespace content
421 438
422 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_ENTRY_IMPL_H_ 439 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_ENTRY_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl_unittest.cc ('k') | content/browser/frame_host/navigation_entry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698