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

Side by Side Diff: content/common/indexed_db/indexed_db_param_traits.cc

Issue 2509913002: Implement StructTraits for remaining IndexedDB IPC types. (Closed)
Patch Set: Fix compile error on GCC. Created 4 years, 1 month 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
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 "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"
11 #include "content/common/indexed_db/indexed_db_key_range.h" 10 #include "content/common/indexed_db/indexed_db_key_range.h"
12 #include "ipc/ipc_message_utils.h" 11 #include "ipc/ipc_message_utils.h"
13 12
14 using content::IndexedDBKey; 13 using content::IndexedDBKey;
15 using content::IndexedDBKeyPath;
16 using content::IndexedDBKeyRange; 14 using content::IndexedDBKeyRange;
17 15
18 using blink::WebIDBKeyPathTypeArray;
19 using blink::WebIDBKeyPathTypeNull;
20 using blink::WebIDBKeyPathTypeString;
21 using blink::WebIDBKeyType; 16 using blink::WebIDBKeyType;
22 using blink::WebIDBKeyTypeArray; 17 using blink::WebIDBKeyTypeArray;
23 using blink::WebIDBKeyTypeBinary; 18 using blink::WebIDBKeyTypeBinary;
24 using blink::WebIDBKeyTypeDate; 19 using blink::WebIDBKeyTypeDate;
25 using blink::WebIDBKeyTypeInvalid; 20 using blink::WebIDBKeyTypeInvalid;
26 using blink::WebIDBKeyTypeMin; 21 using blink::WebIDBKeyTypeMin;
27 using blink::WebIDBKeyTypeNull; 22 using blink::WebIDBKeyTypeNull;
28 using blink::WebIDBKeyTypeNumber; 23 using blink::WebIDBKeyTypeNumber;
29 using blink::WebIDBKeyTypeString; 24 using blink::WebIDBKeyTypeString;
30 25
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 l->append("null"); 170 l->append("null");
176 break; 171 break;
177 case WebIDBKeyTypeMin: 172 case WebIDBKeyTypeMin:
178 default: 173 default:
179 NOTREACHED(); 174 NOTREACHED();
180 break; 175 break;
181 } 176 }
182 l->append(")"); 177 l->append(")");
183 } 178 }
184 179
185 void ParamTraits<IndexedDBKeyPath>::GetSize(base::PickleSizer* s,
186 const param_type& p) {
187 GetParamSize(s, static_cast<int>(p.type()));
188 switch (p.type()) {
189 case WebIDBKeyPathTypeArray:
190 GetParamSize(s, p.array());
191 return;
192 case WebIDBKeyPathTypeString:
193 GetParamSize(s, p.string());
194 return;
195 case WebIDBKeyPathTypeNull:
196 return;
197 default:
198 NOTREACHED();
199 return;
200 }
201 }
202
203 void ParamTraits<IndexedDBKeyPath>::Write(base::Pickle* m,
204 const param_type& p) {
205 WriteParam(m, static_cast<int>(p.type()));
206 switch (p.type()) {
207 case WebIDBKeyPathTypeArray:
208 WriteParam(m, p.array());
209 return;
210 case WebIDBKeyPathTypeString:
211 WriteParam(m, p.string());
212 return;
213 case WebIDBKeyPathTypeNull:
214 return;
215 default:
216 NOTREACHED();
217 return;
218 }
219 }
220
221 bool ParamTraits<IndexedDBKeyPath>::Read(const base::Pickle* m,
222 base::PickleIterator* iter,
223 param_type* r) {
224 int type;
225 if (!ReadParam(m, iter, &type))
226 return false;
227
228 switch (type) {
229 case WebIDBKeyPathTypeArray: {
230 std::vector<base::string16> array;
231 if (!ReadParam(m, iter, &array))
232 return false;
233 *r = IndexedDBKeyPath(array);
234 return true;
235 }
236 case WebIDBKeyPathTypeString: {
237 base::string16 string;
238 if (!ReadParam(m, iter, &string))
239 return false;
240 *r = IndexedDBKeyPath(string);
241 return true;
242 }
243 case WebIDBKeyPathTypeNull:
244 *r = IndexedDBKeyPath();
245 return true;
246 default:
247 NOTREACHED();
248 return false;
249 }
250 }
251
252 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) {
253 l->append("<IndexedDBKeyPath>(");
254 switch (p.type()) {
255 case WebIDBKeyPathTypeArray: {
256 l->append("array=[");
257 bool first = true;
258 for (const base::string16& entry : p.array()) {
259 if (!first)
260 l->append(", ");
261 first = false;
262 LogParam(entry, l);
263 }
264 l->append("]");
265 break;
266 }
267 case WebIDBKeyPathTypeString:
268 l->append("string=");
269 LogParam(p.string(), l);
270 break;
271 case WebIDBKeyPathTypeNull:
272 l->append("null");
273 break;
274 default:
275 NOTREACHED();
276 break;
277 }
278 l->append(")");
279 }
280
281 void ParamTraits<IndexedDBKeyRange>::GetSize(base::PickleSizer* s, 180 void ParamTraits<IndexedDBKeyRange>::GetSize(base::PickleSizer* s,
282 const param_type& p) { 181 const param_type& p) {
283 GetParamSize(s, p.lower()); 182 GetParamSize(s, p.lower());
284 GetParamSize(s, p.upper()); 183 GetParamSize(s, p.upper());
285 GetParamSize(s, p.lower_open()); 184 GetParamSize(s, p.lower_open());
286 GetParamSize(s, p.upper_open()); 185 GetParamSize(s, p.upper_open());
287 } 186 }
288 187
289 void ParamTraits<IndexedDBKeyRange>::Write(base::Pickle* m, 188 void ParamTraits<IndexedDBKeyRange>::Write(base::Pickle* m,
290 const param_type& p) { 189 const param_type& p) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 l->append(", upper="); 222 l->append(", upper=");
324 LogParam(p.upper(), l); 223 LogParam(p.upper(), l);
325 l->append(", lower_open="); 224 l->append(", lower_open=");
326 LogParam(p.lower_open(), l); 225 LogParam(p.lower_open(), l);
327 l->append(", upper_open="); 226 l->append(", upper_open=");
328 LogParam(p.upper_open(), l); 227 LogParam(p.upper_open(), l);
329 l->append(")"); 228 l->append(")");
330 } 229 }
331 230
332 } // namespace IPC 231 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_param_traits.h ('k') | content/common/indexed_db/indexed_db_struct_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698