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/pickle.h" | 9 #include "base/pickle.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 using std::string; | 28 using std::string; |
29 | 29 |
30 namespace android_webview { | 30 namespace android_webview { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 // Sanity check value that we are restoring from a valid pickle. | 34 // Sanity check value that we are restoring from a valid pickle. |
35 // This can potentially used as an actual serialization version number in the | 35 // This can potentially used as an actual serialization version number in the |
36 // future if we ever decide to support restoring from older versions. | 36 // future if we ever decide to support restoring from older versions. |
37 const uint32 AW_STATE_VERSION = 20130814; | 37 const uint32 AW_STATE_VERSION = 20151204; |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 bool WriteToPickle(const content::WebContents& web_contents, | 41 bool WriteToPickle(const content::WebContents& web_contents, |
42 base::Pickle* pickle) { | 42 base::Pickle* pickle) { |
43 DCHECK(pickle); | 43 DCHECK(pickle); |
44 | 44 |
45 if (!internal::WriteHeaderToPickle(pickle)) | 45 if (!internal::WriteHeaderToPickle(pickle)) |
46 return false; | 46 return false; |
47 | 47 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 if (!pickle->WriteBool(static_cast<int>(entry.GetHasPostData()))) | 173 if (!pickle->WriteBool(static_cast<int>(entry.GetHasPostData()))) |
174 return false; | 174 return false; |
175 | 175 |
176 if (!pickle->WriteString(entry.GetOriginalRequestURL().spec())) | 176 if (!pickle->WriteString(entry.GetOriginalRequestURL().spec())) |
177 return false; | 177 return false; |
178 | 178 |
179 if (!pickle->WriteString(entry.GetBaseURLForDataURL().spec())) | 179 if (!pickle->WriteString(entry.GetBaseURLForDataURL().spec())) |
180 return false; | 180 return false; |
181 | 181 |
| 182 if (!pickle->WriteString(entry.GetDataURLAsString())) |
| 183 return false; |
| 184 |
182 if (!pickle->WriteBool(static_cast<int>(entry.GetIsOverridingUserAgent()))) | 185 if (!pickle->WriteBool(static_cast<int>(entry.GetIsOverridingUserAgent()))) |
183 return false; | 186 return false; |
184 | 187 |
185 if (!pickle->WriteInt64(entry.GetTimestamp().ToInternalValue())) | 188 if (!pickle->WriteInt64(entry.GetTimestamp().ToInternalValue())) |
186 return false; | 189 return false; |
187 | 190 |
188 if (!pickle->WriteInt(entry.GetHttpStatusCode())) | 191 if (!pickle->WriteInt(entry.GetHttpStatusCode())) |
189 return false; | 192 return false; |
190 | 193 |
191 // Please update AW_STATE_VERSION if serialization format is changed. | 194 // Please update AW_STATE_VERSION if serialization format is changed. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 257 } |
255 | 258 |
256 { | 259 { |
257 string base_url_for_data_url; | 260 string base_url_for_data_url; |
258 if (!iterator->ReadString(&base_url_for_data_url)) | 261 if (!iterator->ReadString(&base_url_for_data_url)) |
259 return false; | 262 return false; |
260 entry->SetBaseURLForDataURL(GURL(base_url_for_data_url)); | 263 entry->SetBaseURLForDataURL(GURL(base_url_for_data_url)); |
261 } | 264 } |
262 | 265 |
263 { | 266 { |
| 267 string data_url; |
| 268 if (!iterator->ReadString(&data_url)) |
| 269 return false; |
| 270 entry->SetDataURLAsString(data_url); |
| 271 } |
| 272 |
| 273 { |
264 bool is_overriding_user_agent; | 274 bool is_overriding_user_agent; |
265 if (!iterator->ReadBool(&is_overriding_user_agent)) | 275 if (!iterator->ReadBool(&is_overriding_user_agent)) |
266 return false; | 276 return false; |
267 entry->SetIsOverridingUserAgent(is_overriding_user_agent); | 277 entry->SetIsOverridingUserAgent(is_overriding_user_agent); |
268 } | 278 } |
269 | 279 |
270 { | 280 { |
271 int64 timestamp; | 281 int64 timestamp; |
272 if (!iterator->ReadInt64(×tamp)) | 282 if (!iterator->ReadInt64(×tamp)) |
273 return false; | 283 return false; |
274 entry->SetTimestamp(base::Time::FromInternalValue(timestamp)); | 284 entry->SetTimestamp(base::Time::FromInternalValue(timestamp)); |
275 } | 285 } |
276 | 286 |
277 { | 287 { |
278 int http_status_code; | 288 int http_status_code; |
279 if (!iterator->ReadInt(&http_status_code)) | 289 if (!iterator->ReadInt(&http_status_code)) |
280 return false; | 290 return false; |
281 entry->SetHttpStatusCode(http_status_code); | 291 entry->SetHttpStatusCode(http_status_code); |
282 } | 292 } |
283 | 293 |
284 return true; | 294 return true; |
285 } | 295 } |
286 | 296 |
287 } // namespace internal | 297 } // namespace internal |
288 | 298 |
289 } // namespace android_webview | 299 } // namespace android_webview |
OLD | NEW |