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 "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 Loading... |
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 Loading... |
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 |
OLD | NEW |