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 = 20130814; | 38 const uint32 AW_STATE_VERSION = 20131123; |
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 | 170 |
171 if (!pickle->WriteString(entry.GetPageState().ToEncodedData())) | 171 if (!pickle->WriteString(entry.GetPageState().ToEncodedData())) |
172 return false; | 172 return false; |
173 | 173 |
174 if (!pickle->WriteBool(static_cast<int>(entry.GetHasPostData()))) | 174 if (!pickle->WriteBool(static_cast<int>(entry.GetHasPostData()))) |
175 return false; | 175 return false; |
176 | 176 |
177 if (!pickle->WriteString(entry.GetOriginalRequestURL().spec())) | 177 if (!pickle->WriteString(entry.GetOriginalRequestURL().spec())) |
178 return false; | 178 return false; |
179 | 179 |
180 base::StringPiece data(base::RefCountedMemory::AsString( | |
181 entry.GetDataForDataURL())); | |
182 if (!pickle->WriteData(data.data(), data.size())) | |
183 return false; | |
184 | |
180 if (!pickle->WriteString(entry.GetBaseURLForDataURL().spec())) | 185 if (!pickle->WriteString(entry.GetBaseURLForDataURL().spec())) |
181 return false; | 186 return false; |
182 | 187 |
183 if (!pickle->WriteBool(static_cast<int>(entry.GetIsOverridingUserAgent()))) | 188 if (!pickle->WriteBool(static_cast<int>(entry.GetIsOverridingUserAgent()))) |
184 return false; | 189 return false; |
185 | 190 |
186 if (!pickle->WriteInt64(entry.GetTimestamp().ToInternalValue())) | 191 if (!pickle->WriteInt64(entry.GetTimestamp().ToInternalValue())) |
187 return false; | 192 return false; |
188 | 193 |
189 if (!pickle->WriteInt(entry.GetHttpStatusCode())) | 194 if (!pickle->WriteInt(entry.GetHttpStatusCode())) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 } | 253 } |
249 | 254 |
250 { | 255 { |
251 string original_request_url; | 256 string original_request_url; |
252 if (!iterator->ReadString(&original_request_url)) | 257 if (!iterator->ReadString(&original_request_url)) |
253 return false; | 258 return false; |
254 entry->SetOriginalRequestURL(GURL(original_request_url)); | 259 entry->SetOriginalRequestURL(GURL(original_request_url)); |
255 } | 260 } |
256 | 261 |
257 { | 262 { |
263 scoped_refptr<base::RefCountedString> res = new base::RefCountedString; | |
264 if (!iterator->ReadString(&res->data())) | |
boliu
2013/11/26 17:15:15
Not pickle expert, but does can ReadString be matc
joth
2013/11/27 01:31:22
The internal implementation makes them compatible,
| |
265 return false; | |
266 if (res->size()) | |
267 entry->SetDataForDataURL(res.get()); | |
268 } | |
269 | |
270 { | |
258 string base_url_for_data_url; | 271 string base_url_for_data_url; |
259 if (!iterator->ReadString(&base_url_for_data_url)) | 272 if (!iterator->ReadString(&base_url_for_data_url)) |
260 return false; | 273 return false; |
261 entry->SetBaseURLForDataURL(GURL(base_url_for_data_url)); | 274 entry->SetBaseURLForDataURL(GURL(base_url_for_data_url)); |
262 } | 275 } |
263 | 276 |
264 { | 277 { |
265 bool is_overriding_user_agent; | 278 bool is_overriding_user_agent; |
266 if (!iterator->ReadBool(&is_overriding_user_agent)) | 279 if (!iterator->ReadBool(&is_overriding_user_agent)) |
267 return false; | 280 return false; |
(...skipping 13 matching lines...) Expand all Loading... | |
281 return false; | 294 return false; |
282 entry->SetHttpStatusCode(http_status_code); | 295 entry->SetHttpStatusCode(http_status_code); |
283 } | 296 } |
284 | 297 |
285 return true; | 298 return true; |
286 } | 299 } |
287 | 300 |
288 } // namespace internal | 301 } // namespace internal |
289 | 302 |
290 } // namespace android_webview | 303 } // namespace android_webview |
OLD | NEW |