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

Side by Side Diff: webkit/glue/glue_serialize.cc

Issue 9447084: Refactor Pickle Read methods to use higher performance PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile (racing with incoming CLs) Created 8 years, 9 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 | « webkit/fileapi/file_system_usage_cache.cc ('k') | webkit/glue/npruntime_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/glue/glue_serialize.h" 5 #include "webkit/glue/glue_serialize.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 14 matching lines...) Expand all
25 using WebKit::WebPoint; 25 using WebKit::WebPoint;
26 using WebKit::WebSerializedScriptValue; 26 using WebKit::WebSerializedScriptValue;
27 using WebKit::WebString; 27 using WebKit::WebString;
28 using WebKit::WebUChar; 28 using WebKit::WebUChar;
29 using WebKit::WebVector; 29 using WebKit::WebVector;
30 30
31 namespace webkit_glue { 31 namespace webkit_glue {
32 32
33 namespace { 33 namespace {
34 struct SerializeObject { 34 struct SerializeObject {
35 SerializeObject() : iter(NULL), version(0) {} 35 SerializeObject() : version(0) {}
36 SerializeObject(const char* data, int len) 36 SerializeObject(const char* data, int len)
37 : pickle(data, len), iter(NULL), version(0) {} 37 : pickle(data, len), version(0) { iter = PickleIterator(pickle); }
38 38
39 std::string GetAsString() { 39 std::string GetAsString() {
40 return std::string(static_cast<const char*>(pickle.data()), pickle.size()); 40 return std::string(static_cast<const char*>(pickle.data()), pickle.size());
41 } 41 }
42 42
43 Pickle pickle; 43 Pickle pickle;
44 mutable void* iter; 44 mutable PickleIterator iter;
45 mutable int version; 45 mutable int version;
46 }; 46 };
47 47
48 // TODO(mpcomplete): obsolete versions 1 and 2 after 1/1/2008. 48 // TODO(mpcomplete): obsolete versions 1 and 2 after 1/1/2008.
49 // Version ID used in reading/writing history items. 49 // Version ID used in reading/writing history items.
50 // 1: Initial revision. 50 // 1: Initial revision.
51 // 2: Added case for NULL string versus "". Version 2 code can read Version 1 51 // 2: Added case for NULL string versus "". Version 2 code can read Version 1
52 // data, but not vice versa. 52 // data, but not vice versa.
53 // 3: Version 2 was broken, it stored number of WebUChars, not number of bytes. 53 // 3: Version 2 was broken, it stored number of WebUChars, not number of bytes.
54 // This version checks and reads v1 and v2 correctly. 54 // This version checks and reads v1 and v2 correctly.
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 kVersion = version; 534 kVersion = version;
535 535
536 SerializeObject obj; 536 SerializeObject obj;
537 WriteHistoryItem(item, &obj); 537 WriteHistoryItem(item, &obj);
538 *serialized_item = obj.GetAsString(); 538 *serialized_item = obj.GetAsString();
539 539
540 kVersion = real_version; 540 kVersion = real_version;
541 } 541 }
542 542
543 } // namespace webkit_glue 543 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_usage_cache.cc ('k') | webkit/glue/npruntime_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698