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

Side by Side Diff: android_webview/native/state_serializer.cc

Issue 84703003: Allow data URL > 2MB for loadDataWithBaseURL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bo comments Created 7 years 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
OLDNEW
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
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
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
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 const char* data;
264 int len;
265 if (!iterator->ReadData(&data, &len))
266 return false;
267 if (len > 0) {
268 scoped_refptr<base::RefCountedString> ref = new base::RefCountedString;
269 ref->data().assign(data, len);
270 entry->SetDataForDataURL(ref.get());
271 }
272 }
273
274 {
258 string base_url_for_data_url; 275 string base_url_for_data_url;
259 if (!iterator->ReadString(&base_url_for_data_url)) 276 if (!iterator->ReadString(&base_url_for_data_url))
260 return false; 277 return false;
261 entry->SetBaseURLForDataURL(GURL(base_url_for_data_url)); 278 entry->SetBaseURLForDataURL(GURL(base_url_for_data_url));
262 } 279 }
263 280
264 { 281 {
265 bool is_overriding_user_agent; 282 bool is_overriding_user_agent;
266 if (!iterator->ReadBool(&is_overriding_user_agent)) 283 if (!iterator->ReadBool(&is_overriding_user_agent))
267 return false; 284 return false;
(...skipping 13 matching lines...) Expand all
281 return false; 298 return false;
282 entry->SetHttpStatusCode(http_status_code); 299 entry->SetHttpStatusCode(http_status_code);
283 } 300 }
284 301
285 return true; 302 return true;
286 } 303 }
287 304
288 } // namespace internal 305 } // namespace internal
289 306
290 } // namespace android_webview 307 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698