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 "content/common/indexed_db/indexed_db_param_traits.h" | 5 #include "content/common/indexed_db/indexed_db_param_traits.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 #include "content/common/indexed_db/indexed_db_key.h" | 9 #include "content/common/indexed_db/indexed_db_key.h" |
10 #include "content/common/indexed_db/indexed_db_key_path.h" | 10 #include "content/common/indexed_db/indexed_db_key_path.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 using blink::WebIDBKeyTypeString; | 29 using blink::WebIDBKeyTypeString; |
30 | 30 |
31 namespace IPC { | 31 namespace IPC { |
32 | 32 |
33 void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) { | 33 void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) { |
34 WriteParam(m, static_cast<int>(p.type())); | 34 WriteParam(m, static_cast<int>(p.type())); |
35 switch (p.type()) { | 35 switch (p.type()) { |
36 case WebIDBKeyTypeArray: | 36 case WebIDBKeyTypeArray: |
37 WriteParam(m, p.array()); | 37 WriteParam(m, p.array()); |
38 return; | 38 return; |
39 | |
jam
2014/03/19 16:44:36
ditto
Peter Kasting
2014/03/19 21:10:57
Done.
| |
39 case WebIDBKeyTypeBinary: | 40 case WebIDBKeyTypeBinary: |
40 WriteParam(m, p.binary()); | 41 WriteParam(m, p.binary()); |
41 return; | 42 return; |
43 | |
42 case WebIDBKeyTypeString: | 44 case WebIDBKeyTypeString: |
43 WriteParam(m, p.string()); | 45 WriteParam(m, p.string()); |
44 return; | 46 return; |
47 | |
48 | |
45 case WebIDBKeyTypeDate: | 49 case WebIDBKeyTypeDate: |
46 WriteParam(m, p.date()); | 50 WriteParam(m, p.date()); |
47 return; | 51 return; |
52 | |
48 case WebIDBKeyTypeNumber: | 53 case WebIDBKeyTypeNumber: |
49 WriteParam(m, p.number()); | 54 WriteParam(m, p.number()); |
50 return; | 55 return; |
56 | |
51 case WebIDBKeyTypeInvalid: | 57 case WebIDBKeyTypeInvalid: |
52 case WebIDBKeyTypeNull: | 58 case WebIDBKeyTypeNull: |
53 return; | 59 return; |
60 | |
54 case WebIDBKeyTypeMin: | 61 case WebIDBKeyTypeMin: |
55 default: | 62 default: |
56 NOTREACHED(); | 63 NOTREACHED(); |
57 return; | 64 return; |
58 } | 65 } |
59 } | 66 } |
60 | 67 |
61 bool ParamTraits<IndexedDBKey>::Read(const Message* m, | 68 bool ParamTraits<IndexedDBKey>::Read(const Message* m, |
62 PickleIterator* iter, | 69 PickleIterator* iter, |
63 param_type* r) { | 70 param_type* r) { |
64 int type; | 71 int type; |
65 if (!ReadParam(m, iter, &type)) | 72 if (!ReadParam(m, iter, &type)) |
66 return false; | 73 return false; |
67 WebIDBKeyType web_type = static_cast<WebIDBKeyType>(type); | 74 WebIDBKeyType web_type = static_cast<WebIDBKeyType>(type); |
68 | |
69 switch (web_type) { | 75 switch (web_type) { |
70 case WebIDBKeyTypeArray: { | 76 case WebIDBKeyTypeArray: { |
71 std::vector<IndexedDBKey> array; | 77 std::vector<IndexedDBKey> array; |
72 if (!ReadParam(m, iter, &array)) | 78 if (!ReadParam(m, iter, &array)) |
73 return false; | 79 return false; |
74 *r = IndexedDBKey(array); | 80 *r = IndexedDBKey(array); |
75 return true; | 81 return true; |
76 } | 82 } |
83 | |
77 case WebIDBKeyTypeBinary: { | 84 case WebIDBKeyTypeBinary: { |
78 std::string binary; | 85 std::string binary; |
79 if (!ReadParam(m, iter, &binary)) | 86 if (!ReadParam(m, iter, &binary)) |
80 return false; | 87 return false; |
81 *r = IndexedDBKey(binary); | 88 *r = IndexedDBKey(binary); |
82 return true; | 89 return true; |
83 } | 90 } |
91 | |
84 case WebIDBKeyTypeString: { | 92 case WebIDBKeyTypeString: { |
85 base::string16 string; | 93 base::string16 string; |
86 if (!ReadParam(m, iter, &string)) | 94 if (!ReadParam(m, iter, &string)) |
87 return false; | 95 return false; |
88 *r = IndexedDBKey(string); | 96 *r = IndexedDBKey(string); |
89 return true; | 97 return true; |
90 } | 98 } |
99 | |
91 case WebIDBKeyTypeDate: | 100 case WebIDBKeyTypeDate: |
92 case WebIDBKeyTypeNumber: { | 101 case WebIDBKeyTypeNumber: { |
93 double number; | 102 double number; |
94 if (!ReadParam(m, iter, &number)) | 103 if (!ReadParam(m, iter, &number)) |
95 return false; | 104 return false; |
96 *r = IndexedDBKey(number, web_type); | 105 *r = IndexedDBKey(number, web_type); |
97 return true; | 106 return true; |
98 } | 107 } |
108 | |
99 case WebIDBKeyTypeInvalid: | 109 case WebIDBKeyTypeInvalid: |
100 case WebIDBKeyTypeNull: | 110 case WebIDBKeyTypeNull: |
101 *r = IndexedDBKey(web_type); | 111 *r = IndexedDBKey(web_type); |
102 return true; | 112 return true; |
113 | |
103 case WebIDBKeyTypeMin: | 114 case WebIDBKeyTypeMin: |
104 default: | 115 default: |
105 NOTREACHED(); | 116 NOTREACHED(); |
106 return false; | 117 return false; |
107 } | 118 } |
108 NOTREACHED(); | |
109 return false; | |
110 } | 119 } |
111 | 120 |
112 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) { | 121 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) { |
113 l->append("<IndexedDBKey>("); | 122 l->append("<IndexedDBKey>("); |
114 LogParam(static_cast<int>(p.type()), l); | 123 LogParam(static_cast<int>(p.type()), l); |
115 l->append(", "); | 124 l->append(", "); |
116 l->append("["); | 125 l->append("["); |
117 std::vector<IndexedDBKey>::const_iterator it = p.array().begin(); | 126 std::vector<IndexedDBKey>::const_iterator it = p.array().begin(); |
118 while (it != p.array().end()) { | 127 while (it != p.array().end()) { |
119 Log(*it, l); | 128 Log(*it, l); |
(...skipping 11 matching lines...) Expand all Loading... | |
131 LogParam(p.number(), l); | 140 LogParam(p.number(), l); |
132 l->append(")"); | 141 l->append(")"); |
133 } | 142 } |
134 | 143 |
135 void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) { | 144 void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) { |
136 WriteParam(m, static_cast<int>(p.type())); | 145 WriteParam(m, static_cast<int>(p.type())); |
137 switch (p.type()) { | 146 switch (p.type()) { |
138 case WebIDBKeyPathTypeArray: | 147 case WebIDBKeyPathTypeArray: |
139 WriteParam(m, p.array()); | 148 WriteParam(m, p.array()); |
140 return; | 149 return; |
150 | |
141 case WebIDBKeyPathTypeString: | 151 case WebIDBKeyPathTypeString: |
142 WriteParam(m, p.string()); | 152 WriteParam(m, p.string()); |
143 return; | 153 return; |
154 | |
144 case WebIDBKeyPathTypeNull: | 155 case WebIDBKeyPathTypeNull: |
145 return; | 156 return; |
157 | |
158 default: | |
159 NOTREACHED(); | |
160 return; | |
146 } | 161 } |
147 NOTREACHED(); | |
148 } | 162 } |
149 | 163 |
150 bool ParamTraits<IndexedDBKeyPath>::Read(const Message* m, | 164 bool ParamTraits<IndexedDBKeyPath>::Read(const Message* m, |
151 PickleIterator* iter, | 165 PickleIterator* iter, |
152 param_type* r) { | 166 param_type* r) { |
153 int type; | 167 int type; |
154 if (!ReadParam(m, iter, &type)) | 168 if (!ReadParam(m, iter, &type)) |
155 return false; | 169 return false; |
156 | |
157 switch (type) { | 170 switch (type) { |
158 case WebIDBKeyPathTypeArray: { | 171 case WebIDBKeyPathTypeArray: { |
159 std::vector<base::string16> array; | 172 std::vector<base::string16> array; |
160 if (!ReadParam(m, iter, &array)) | 173 if (!ReadParam(m, iter, &array)) |
161 return false; | 174 return false; |
162 *r = IndexedDBKeyPath(array); | 175 *r = IndexedDBKeyPath(array); |
163 return true; | 176 return true; |
164 } | 177 } |
178 | |
165 case WebIDBKeyPathTypeString: { | 179 case WebIDBKeyPathTypeString: { |
166 base::string16 string; | 180 base::string16 string; |
167 if (!ReadParam(m, iter, &string)) | 181 if (!ReadParam(m, iter, &string)) |
168 return false; | 182 return false; |
169 *r = IndexedDBKeyPath(string); | 183 *r = IndexedDBKeyPath(string); |
170 return true; | 184 return true; |
171 } | 185 } |
186 | |
172 case WebIDBKeyPathTypeNull: | 187 case WebIDBKeyPathTypeNull: |
173 *r = IndexedDBKeyPath(); | 188 *r = IndexedDBKeyPath(); |
174 return true; | 189 return true; |
190 | |
191 default: | |
192 NOTREACHED(); | |
193 return false; | |
175 } | 194 } |
176 NOTREACHED(); | |
177 return false; | |
178 } | 195 } |
179 | 196 |
180 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) { | 197 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) { |
181 l->append("<IndexedDBKeyPath>("); | 198 l->append("<IndexedDBKeyPath>("); |
182 LogParam(static_cast<int>(p.type()), l); | 199 LogParam(static_cast<int>(p.type()), l); |
183 l->append(", "); | 200 l->append(", "); |
184 LogParam(p.string(), l); | 201 LogParam(p.string(), l); |
185 l->append(", "); | 202 l->append(", "); |
186 l->append("["); | 203 l->append("["); |
187 std::vector<base::string16>::const_iterator it = p.array().begin(); | 204 std::vector<base::string16>::const_iterator it = p.array().begin(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 l->append(", upper="); | 247 l->append(", upper="); |
231 LogParam(p.upper(), l); | 248 LogParam(p.upper(), l); |
232 l->append(", lower_open="); | 249 l->append(", lower_open="); |
233 LogParam(p.lowerOpen(), l); | 250 LogParam(p.lowerOpen(), l); |
234 l->append(", upper_open="); | 251 l->append(", upper_open="); |
235 LogParam(p.upperOpen(), l); | 252 LogParam(p.upperOpen(), l); |
236 l->append(")"); | 253 l->append(")"); |
237 } | 254 } |
238 | 255 |
239 } // namespace IPC | 256 } // namespace IPC |
OLD | NEW |