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

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

Issue 10533057: IPC plumbing for IndexedDB to snapshot metadata to the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't CamelCase "metadata" Created 8 years, 6 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
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 "content/common/indexed_db/indexed_db_key.h" 7 #include "content/common/indexed_db/indexed_db_key.h"
8 #include "content/common/indexed_db/indexed_db_key_path.h" 8 #include "content/common/indexed_db/indexed_db_key_path.h"
9 #include "content/common/indexed_db/indexed_db_key_range.h" 9 #include "content/common/indexed_db/indexed_db_key_range.h"
10 #include "content/common/indexed_db/indexed_db_metadata.h"
10 #include "content/public/common/serialized_script_value.h" 11 #include "content/public/common/serialized_script_value.h"
11 #include "ipc/ipc_message_utils.h" 12 #include "ipc/ipc_message_utils.h"
12 13
13 using content::IndexedDBKey; 14 using content::IndexedDBKey;
14 using content::IndexedDBKeyPath; 15 using content::IndexedDBKeyPath;
15 using content::IndexedDBKeyRange; 16 using content::IndexedDBKeyRange;
17 using content::IndexedDBDatabaseMetadata;
18 using content::IndexedDBObjectStoreMetadata;
19 using content::IndexedDBIndexMetadata;
16 using content::SerializedScriptValue; 20 using content::SerializedScriptValue;
17 21
18 namespace IPC { 22 namespace IPC {
19 23
20 void ParamTraits<SerializedScriptValue>::Write(Message* m, 24 void ParamTraits<SerializedScriptValue>::Write(Message* m,
21 const param_type& p) { 25 const param_type& p) {
22 WriteParam(m, p.is_null()); 26 WriteParam(m, p.is_null());
23 WriteParam(m, p.is_invalid()); 27 WriteParam(m, p.is_invalid());
24 WriteParam(m, p.data()); 28 WriteParam(m, p.data());
25 } 29 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 LogParam(p.lower(), l); 250 LogParam(p.lower(), l);
247 l->append(", upper="); 251 l->append(", upper=");
248 LogParam(p.upper(), l); 252 LogParam(p.upper(), l);
249 l->append(", lower_open="); 253 l->append(", lower_open=");
250 LogParam(p.lowerOpen(), l); 254 LogParam(p.lowerOpen(), l);
251 l->append(", upper_open="); 255 l->append(", upper_open=");
252 LogParam(p.upperOpen(), l); 256 LogParam(p.upperOpen(), l);
253 l->append(")"); 257 l->append(")");
254 } 258 }
255 259
260 void ParamTraits<IndexedDBDatabaseMetadata>::Write(Message* m,
261 const param_type& p) {
262 WriteParam(m, p.name());
263 WriteParam(m, p.version());
264 WriteParam(m, p.object_stores());
265 }
266
267 bool ParamTraits<IndexedDBDatabaseMetadata>::Read(const Message* m,
268 PickleIterator* iter,
269 param_type* r) {
270 string16 name;
271 if (!ReadParam(m, iter, &name))
272 return false;
273
274 string16 version;
275 if (!ReadParam(m, iter, &version))
276 return false;
277
278 std::vector<IndexedDBObjectStoreMetadata> object_stores;
279 if (!ReadParam(m, iter, &object_stores))
280 return false;
281
282 r->Set(name, version, object_stores);
283 return true;
284 }
285
286 void ParamTraits<IndexedDBDatabaseMetadata>::Log(const param_type& p,
287 std::string* l) {
288 l->append("<IndexedDBDatabaseMetadata>(name=");
289 LogParam(p.name(), l);
290 l->append(", version=");
291 LogParam(p.version(), l);
292 l->append(", object_stores=");
293 LogParam(p.object_stores(), l);
294 l->append(")");
295 }
296
297 void ParamTraits<IndexedDBObjectStoreMetadata>::Write(Message* m,
298 const param_type& p) {
299 WriteParam(m, p.name());
300 WriteParam(m, p.key_path());
301 WriteParam(m, p.auto_increment());
302 WriteParam(m, p.indexes());
303 }
304
305 bool ParamTraits<IndexedDBObjectStoreMetadata>::Read(const Message* m,
306 PickleIterator* iter,
307 param_type* r) {
308 string16 name;
309 if (!ReadParam(m, iter, &name))
310 return false;
311
312 IndexedDBKeyPath key_path;
313 if (!ReadParam(m, iter, &key_path))
314 return false;
315
316 bool auto_increment;
317 if (!ReadParam(m, iter, &auto_increment))
318 return false;
319
320 std::vector<IndexedDBIndexMetadata> indexes;
321 if (!ReadParam(m, iter, &indexes))
322 return false;
323
324 r->Set(name, key_path, auto_increment, indexes);
325 return true;
326 }
327
328 void ParamTraits<IndexedDBObjectStoreMetadata>::Log(const param_type& p,
329 std::string* l) {
330 l->append("<IndexedDBObjectStoreMetadata>(name=");
331 LogParam(p.name(), l);
332 l->append(", key_path=");
333 LogParam(p.key_path(), l);
334 l->append(", auto_increment=");
335 LogParam(p.auto_increment(), l);
336 l->append(", indexes=");
337 LogParam(p.indexes(), l);
338 l->append(")");
339 }
340
341 void ParamTraits<IndexedDBIndexMetadata>::Write(Message* m,
342 const param_type& p) {
343 WriteParam(m, p.name());
344 WriteParam(m, p.key_path());
345 WriteParam(m, p.unique());
346 WriteParam(m, p.multi_entry());
347 }
348
349 bool ParamTraits<IndexedDBIndexMetadata>::Read(const Message* m,
350 PickleIterator* iter,
351 param_type* r) {
352 string16 name;
353 if (!ReadParam(m, iter, &name))
354 return false;
355
356 IndexedDBKeyPath key_path;
357 if (!ReadParam(m, iter, &key_path))
358 return false;
359
360 bool unique;
361 if (!ReadParam(m, iter, &unique))
362 return false;
363
364 bool multi_entry;
365 if (!ReadParam(m, iter, &multi_entry))
366 return false;
367
368 r->Set(name, key_path, unique, multi_entry);
369 return true;
370 }
371
372 void ParamTraits<IndexedDBIndexMetadata>::Log(const param_type& p,
373 std::string* l) {
374 l->append("<IndexedDBIndexMetadata>(name=");
375 LogParam(p.name(), l);
376 l->append(", key_path=");
377 LogParam(p.key_path(), l);
378 l->append(", unique=");
379 LogParam(p.unique(), l);
380 l->append(", multi_entry=");
381 LogParam(p.multi_entry(), l);
382 l->append(")");
383 }
384
256 } // namespace IPC 385 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698