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"
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
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
> {
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 // frame sequence numbers or unique names would work instead, similar to
32 explicit FrameNavigationEntry(int64 frame_tree_node_id
);
33 FrameNavigationEntry(int64 frame_tree_node_id
,
34 SiteInstanceImpl
* site_instance
,
36 const Referrer
& referrer
);
38 // Creates a copy of this FrameNavigationEntry that can be modified
39 // independently from the original.
40 FrameNavigationEntry
* Clone() const;
42 // Updates all the members of this entry.
43 void UpdateEntry(SiteInstanceImpl
* site_instance
,
45 const Referrer
& referrer
,
46 const PageState
& page_state
);
48 // The ID of the FrameTreeNode this entry is for. -1 for the main frame,
49 // since we don't always know the FrameTreeNode ID when creating the overall
51 // TODO(creis): Replace with frame sequence number or unique name.
52 int64
frame_tree_node_id() const { return frame_tree_node_id_
; }
54 // The SiteInstance responsible for rendering this frame. All frames sharing
55 // a SiteInstance must live in the same process. This is a refcounted pointer
56 // that keeps the SiteInstance (not necessarily the process) alive as long as
57 // this object remains in the session history.
58 void set_site_instance(SiteInstanceImpl
* site_instance
) {
59 site_instance_
= site_instance
;
61 SiteInstanceImpl
* site_instance() const { return site_instance_
.get(); }
63 // The actual URL loaded in the frame. This is in contrast to the virtual
64 // URL, which is shown to the user.
65 void set_url(const GURL
& url
) { url_
= url
; }
66 const GURL
& url() const { return url_
; }
68 // The referring URL. Can be empty.
69 void set_referrer(const Referrer
& referrer
) { referrer_
= referrer
; }
70 const Referrer
& referrer() const { return referrer_
; }
72 void set_page_state(const PageState
& page_state
) { page_state_
= page_state
; }
73 const PageState
& page_state() const { return page_state_
; }
76 friend class base::RefCounted
<FrameNavigationEntry
>;
77 virtual ~FrameNavigationEntry();
79 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
80 // For all new fields, update |Clone|.
81 // TODO(creis): These fields have implications for session restore. This is
82 // currently managed by NavigationEntry, but the logic will move here.
83 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
85 // See the accessors above for descriptions.
86 int64 frame_tree_node_id_
;
87 scoped_refptr
<SiteInstanceImpl
> site_instance_
;
90 // TODO(creis): Change this to FrameState.
91 PageState page_state_
;
93 DISALLOW_COPY_AND_ASSIGN(FrameNavigationEntry
);
96 } // namespace content
98 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_NAVIGATION_ENTRY_H_