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

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

Issue 8980002: Move indexeddb code to its own directory inside of content/{browser,common,renderer} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase onto ToT Created 9 years 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 | « content/common/indexed_db_param_traits.h ('k') | content/common/utility_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/common/indexed_db_param_traits.h"
6
7 #include "content/common/indexed_db_key.h"
8 #include "content/public/common/serialized_script_value.h"
9 #include "ipc/ipc_message_utils.h"
10
11 namespace IPC {
12
13 void ParamTraits<content::SerializedScriptValue>::Write(Message* m,
14 const param_type& p) {
15 WriteParam(m, p.is_null());
16 WriteParam(m, p.is_invalid());
17 WriteParam(m, p.data());
18 }
19
20 bool ParamTraits<content::SerializedScriptValue>::Read(const Message* m,
21 void** iter,
22 param_type* r) {
23 bool is_null;
24 bool is_invalid;
25 string16 data;
26 bool ok =
27 ReadParam(m, iter, &is_null) &&
28 ReadParam(m, iter, &is_invalid) &&
29 ReadParam(m, iter, &data);
30 if (!ok)
31 return false;
32 r->set_is_null(is_null);
33 r->set_is_invalid(is_invalid);
34 r->set_data(data);
35 return true;
36 }
37
38 void ParamTraits<content::SerializedScriptValue>::Log(const param_type& p,
39 std::string* l) {
40 l->append("<SerializedScriptValue>(");
41 LogParam(p.is_null(), l);
42 l->append(", ");
43 LogParam(p.is_invalid(), l);
44 l->append(", ");
45 LogParam(p.data(), l);
46 l->append(")");
47 }
48
49 void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) {
50 WriteParam(m, int(p.type()));
51 switch (p.type()) {
52 case WebKit::WebIDBKey::ArrayType:
53 WriteParam(m, p.array());
54 return;
55 case WebKit::WebIDBKey::StringType:
56 WriteParam(m, p.string());
57 return;
58 case WebKit::WebIDBKey::DateType:
59 WriteParam(m, p.date());
60 return;
61 case WebKit::WebIDBKey::NumberType:
62 WriteParam(m, p.number());
63 return;
64 case WebKit::WebIDBKey::InvalidType:
65 return;
66 }
67 NOTREACHED();
68 }
69
70 bool ParamTraits<IndexedDBKey>::Read(const Message* m,
71 void** iter,
72 param_type* r) {
73 int type;
74 if (!ReadParam(m, iter, &type))
75 return false;
76
77 switch (type) {
78 case WebKit::WebIDBKey::ArrayType:
79 {
80 std::vector<IndexedDBKey> array;
81 if (!ReadParam(m, iter, &array))
82 return false;
83 r->SetArray(array);
84 return true;
85 }
86 case WebKit::WebIDBKey::StringType:
87 {
88 string16 string;
89 if (!ReadParam(m, iter, &string))
90 return false;
91 r->SetString(string);
92 return true;
93 }
94 case WebKit::WebIDBKey::DateType:
95 {
96 double date;
97 if (!ReadParam(m, iter, &date))
98 return false;
99 r->SetDate(date);
100 return true;
101 }
102 case WebKit::WebIDBKey::NumberType:
103 {
104 double number;
105 if (!ReadParam(m, iter, &number))
106 return false;
107 r->SetNumber(number);
108 return true;
109 }
110 case WebKit::WebIDBKey::InvalidType:
111 r->SetInvalid();
112 return true;
113 }
114 NOTREACHED();
115 return false;
116 }
117
118 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) {
119 l->append("<IndexedDBKey>(");
120 LogParam(int(p.type()), l);
121 l->append(", ");
122 l->append("[");
123 std::vector<IndexedDBKey>::const_iterator it = p.array().begin();
124 while (it != p.array().end()) {
125 Log(*it, l);
126 ++it;
127 if (it != p.array().end())
128 l->append(", ");
129 }
130 l->append("], ");
131 LogParam(p.string(), l);
132 l->append(", ");
133 LogParam(p.date(), l);
134 l->append(", ");
135 LogParam(p.number(), l);
136 l->append(")");
137 }
138
139 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/indexed_db_param_traits.h ('k') | content/common/utility_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698