Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / frame_host / frame_navigation_entry.h
blob9dbaff20dcf0024a3102051fc9f8b8afd82ac6ab
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_
6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/browser/site_instance_impl.h"
11 #include "content/public/common/page_state.h"
12 #include "content/public/common/referrer.h"
14 namespace content {
16 // Represents a session history item for a particular frame.
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
20 // frame.
22 // TODO(creis): In --site-per-process, fill in a tree of FrameNavigationEntries
23 // in each NavigationEntry, one per frame. FrameNavigationEntries may be shared
24 // across NavigationEntries if the frame hasn't changed.
25 class CONTENT_EXPORT FrameNavigationEntry
26 : public base::RefCounted<FrameNavigationEntry> {
27 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);
32 FrameNavigationEntry(int frame_tree_node_id,
33 int64 item_sequence_number,
34 int64 document_sequence_number,
35 SiteInstanceImpl* site_instance,
36 const GURL& url,
37 const Referrer& referrer);
39 // Creates a copy of this FrameNavigationEntry that can be modified
40 // independently from the original.
41 FrameNavigationEntry* Clone() const;
43 // Updates all the members of this entry.
44 void UpdateEntry(int64 item_sequence_number,
45 int64 document_sequence_number,
46 SiteInstanceImpl* site_instance,
47 const GURL& url,
48 const Referrer& referrer,
49 const PageState& page_state);
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
53 // NavigationEntry.
54 // TODO(creis): Replace with frame sequence number or unique name.
55 int frame_tree_node_id() const { return frame_tree_node_id_; }
57 // 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
59 // 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
61 // item sequence number but the same document sequence number.
62 void set_item_sequence_number(int64 item_sequence_number) {
63 item_sequence_number_ = item_sequence_number;
65 int64 item_sequence_number() const { return item_sequence_number_; }
66 void set_document_sequence_number(int64 document_sequence_number) {
67 document_sequence_number_ = document_sequence_number;
69 int64 document_sequence_number() const { return document_sequence_number_; }
71 // The SiteInstance responsible for rendering this frame. All frames sharing
72 // a SiteInstance must live in the same process. This is a refcounted pointer
73 // that keeps the SiteInstance (not necessarily the process) alive as long as
74 // this object remains in the session history.
75 void set_site_instance(SiteInstanceImpl* site_instance) {
76 site_instance_ = site_instance;
78 SiteInstanceImpl* site_instance() const { return site_instance_.get(); }
80 // The actual URL loaded in the frame. This is in contrast to the virtual
81 // URL, which is shown to the user.
82 void set_url(const GURL& url) { url_ = url; }
83 const GURL& url() const { return url_; }
85 // The referring URL. Can be empty.
86 void set_referrer(const Referrer& referrer) { referrer_ = referrer; }
87 const Referrer& referrer() const { return referrer_; }
89 void set_page_state(const PageState& page_state) { page_state_ = page_state; }
90 const PageState& page_state() const { return page_state_; }
92 private:
93 friend class base::RefCounted<FrameNavigationEntry>;
94 virtual ~FrameNavigationEntry();
96 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
97 // For all new fields, update |Clone|.
98 // TODO(creis): These fields have implications for session restore. This is
99 // currently managed by NavigationEntry, but the logic will move here.
100 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
102 // See the accessors above for descriptions.
103 int frame_tree_node_id_;
104 int64 item_sequence_number_;
105 int64 document_sequence_number_;
106 scoped_refptr<SiteInstanceImpl> site_instance_;
107 GURL url_;
108 Referrer referrer_;
109 // TODO(creis): Change this to FrameState.
110 PageState page_state_;
112 DISALLOW_COPY_AND_ASSIGN(FrameNavigationEntry);
115 } // namespace content
117 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_