OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "android_webview/native/state_serializer.h" | 5 #include "android_webview/native/state_serializer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 using std::string; | 29 using std::string; |
30 | 30 |
31 namespace android_webview { | 31 namespace android_webview { |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 // Sanity check value that we are restoring from a valid pickle. | 35 // Sanity check value that we are restoring from a valid pickle. |
36 // This can potentially used as an actual serialization version number in the | 36 // This can potentially used as an actual serialization version number in the |
37 // future if we ever decide to support restoring from older versions. | 37 // future if we ever decide to support restoring from older versions. |
38 const uint32 AW_STATE_VERSION = 20121126; | 38 const uint32 AW_STATE_VERSION = 20130814; |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 bool WriteToPickle(const content::WebContents& web_contents, | 42 bool WriteToPickle(const content::WebContents& web_contents, |
43 Pickle* pickle) { | 43 Pickle* pickle) { |
44 DCHECK(pickle); | 44 DCHECK(pickle); |
45 | 45 |
46 if (!internal::WriteHeaderToPickle(pickle)) | 46 if (!internal::WriteHeaderToPickle(pickle)) |
47 return false; | 47 return false; |
48 | 48 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 if (!pickle->WriteString(entry.GetBaseURLForDataURL().spec())) | 180 if (!pickle->WriteString(entry.GetBaseURLForDataURL().spec())) |
181 return false; | 181 return false; |
182 | 182 |
183 if (!pickle->WriteBool(static_cast<int>(entry.GetIsOverridingUserAgent()))) | 183 if (!pickle->WriteBool(static_cast<int>(entry.GetIsOverridingUserAgent()))) |
184 return false; | 184 return false; |
185 | 185 |
186 if (!pickle->WriteInt64(entry.GetTimestamp().ToInternalValue())) | 186 if (!pickle->WriteInt64(entry.GetTimestamp().ToInternalValue())) |
187 return false; | 187 return false; |
188 | 188 |
| 189 if (!pickle->WriteInt(entry.GetHttpStatusCode())) |
| 190 return false; |
| 191 |
189 // Please update AW_STATE_VERSION if serialization format is changed. | 192 // Please update AW_STATE_VERSION if serialization format is changed. |
190 | 193 |
191 return true; | 194 return true; |
192 } | 195 } |
193 | 196 |
194 bool RestoreNavigationEntryFromPickle(PickleIterator* iterator, | 197 bool RestoreNavigationEntryFromPickle(PickleIterator* iterator, |
195 content::NavigationEntry* entry) { | 198 content::NavigationEntry* entry) { |
196 { | 199 { |
197 string url; | 200 string url; |
198 if (!iterator->ReadString(&url)) | 201 if (!iterator->ReadString(&url)) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 entry->SetIsOverridingUserAgent(is_overriding_user_agent); | 268 entry->SetIsOverridingUserAgent(is_overriding_user_agent); |
266 } | 269 } |
267 | 270 |
268 { | 271 { |
269 int64 timestamp; | 272 int64 timestamp; |
270 if (!iterator->ReadInt64(×tamp)) | 273 if (!iterator->ReadInt64(×tamp)) |
271 return false; | 274 return false; |
272 entry->SetTimestamp(base::Time::FromInternalValue(timestamp)); | 275 entry->SetTimestamp(base::Time::FromInternalValue(timestamp)); |
273 } | 276 } |
274 | 277 |
| 278 { |
| 279 int http_status_code; |
| 280 if (!iterator->ReadInt(&http_status_code)) |
| 281 return false; |
| 282 entry->SetHttpStatusCode(http_status_code); |
| 283 } |
| 284 |
275 return true; | 285 return true; |
276 } | 286 } |
277 | 287 |
278 } // namespace internal | 288 } // namespace internal |
279 | 289 |
280 } // namespace android_webview | 290 } // namespace android_webview |
OLD | NEW |