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

Side by Side Diff: Source/core/loader/HistoryItem.cpp

Issue 239993011: Lazily generate HistoryItem's serialized form state (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merged to trunk Created 6 years, 8 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
« no previous file with comments | « Source/core/loader/HistoryItem.h ('k') | Source/core/testing/Internals.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/loader/HistoryItem.h" 27 #include "core/loader/HistoryItem.h"
28 28
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/html/forms/FormController.h"
30 #include "platform/network/ResourceRequest.h" 31 #include "platform/network/ResourceRequest.h"
31 #include "wtf/CurrentTime.h" 32 #include "wtf/CurrentTime.h"
32 #include "wtf/text/CString.h" 33 #include "wtf/text/CString.h"
33 34
34 namespace WebCore { 35 namespace WebCore {
35 36
36 static long long generateSequenceNumber() 37 static long long generateSequenceNumber()
37 { 38 {
38 // Initialize to the current time to reduce the likelihood of generating 39 // Initialize to the current time to reduce the likelihood of generating
39 // identifiers that overlap with those from past/future browser sessions. 40 // identifiers that overlap with those from past/future browser sessions.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 void HistoryItem::setURLString(const String& urlString) 82 void HistoryItem::setURLString(const String& urlString)
82 { 83 {
83 if (m_urlString != urlString) 84 if (m_urlString != urlString)
84 m_urlString = urlString; 85 m_urlString = urlString;
85 } 86 }
86 87
87 void HistoryItem::setURL(const KURL& url) 88 void HistoryItem::setURL(const KURL& url)
88 { 89 {
89 setURLString(url.string()); 90 setURLString(url.string());
90 clearDocumentState();
91 } 91 }
92 92
93 void HistoryItem::setReferrer(const Referrer& referrer) 93 void HistoryItem::setReferrer(const Referrer& referrer)
94 { 94 {
95 m_referrer = referrer; 95 m_referrer = referrer;
96 } 96 }
97 97
98 void HistoryItem::setTarget(const String& target) 98 void HistoryItem::setTarget(const String& target)
99 { 99 {
100 m_target = target; 100 m_target = target;
(...skipping 20 matching lines...) Expand all
121 return m_pageScaleFactor; 121 return m_pageScaleFactor;
122 } 122 }
123 123
124 void HistoryItem::setPageScaleFactor(float scaleFactor) 124 void HistoryItem::setPageScaleFactor(float scaleFactor)
125 { 125 {
126 m_pageScaleFactor = scaleFactor; 126 m_pageScaleFactor = scaleFactor;
127 } 127 }
128 128
129 void HistoryItem::setDocumentState(const Vector<String>& state) 129 void HistoryItem::setDocumentState(const Vector<String>& state)
130 { 130 {
131 ASSERT(!m_documentState);
132 m_documentStateVector = state;
133 }
134
135 void HistoryItem::setDocumentState(DocumentState* state)
136 {
131 m_documentState = state; 137 m_documentState = state;
132 } 138 }
133 139
134 const Vector<String>& HistoryItem::documentState() const 140 const Vector<String>& HistoryItem::documentState()
135 { 141 {
136 return m_documentState; 142 if (m_documentState)
143 m_documentStateVector = m_documentState->toStateVector();
144 return m_documentStateVector;
145 }
146
147 Vector<String> HistoryItem::getReferencedFilePaths()
148 {
149 return FormController::getReferencedFilePaths(documentState());
137 } 150 }
138 151
139 void HistoryItem::clearDocumentState() 152 void HistoryItem::clearDocumentState()
140 { 153 {
141 m_documentState.clear(); 154 m_documentState.clear();
155 m_documentStateVector.clear();
142 } 156 }
143 157
144 void HistoryItem::setStateObject(PassRefPtr<SerializedScriptValue> object) 158 void HistoryItem::setStateObject(PassRefPtr<SerializedScriptValue> object)
145 { 159 {
146 m_stateObject = object; 160 m_stateObject = object;
147 } 161 }
148 162
149 void HistoryItem::deprecatedAddChildItem(PassRefPtr<HistoryItem> child) 163 void HistoryItem::deprecatedAddChildItem(PassRefPtr<HistoryItem> child)
150 { 164 {
151 m_children.append(child); 165 m_children.append(child);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 209 }
196 210
197 bool HistoryItem::isCurrentDocument(Document* doc) const 211 bool HistoryItem::isCurrentDocument(Document* doc) const
198 { 212 {
199 // FIXME: We should find a better way to check if this is the current docume nt. 213 // FIXME: We should find a better way to check if this is the current docume nt.
200 return equalIgnoringFragmentIdentifier(url(), doc->url()); 214 return equalIgnoringFragmentIdentifier(url(), doc->url());
201 } 215 }
202 216
203 } // namespace WebCore 217 } // namespace WebCore
204 218
OLDNEW
« no previous file with comments | « Source/core/loader/HistoryItem.h ('k') | Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698