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

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

Issue 10204003: Use WebIDBKeyPath type in WebKit API, implement IndexedDBKeyPath type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Delete stray space. Created 8 years, 7 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_range.h" 9 #include "content/common/indexed_db/indexed_db_key_range.h"
9 #include "content/public/common/serialized_script_value.h" 10 #include "content/public/common/serialized_script_value.h"
10 #include "ipc/ipc_message_utils.h" 11 #include "ipc/ipc_message_utils.h"
11 12
12 namespace IPC { 13 namespace IPC {
13 14
14 void ParamTraits<content::SerializedScriptValue>::Write(Message* m, 15 void ParamTraits<content::SerializedScriptValue>::Write(Message* m,
15 const param_type& p) { 16 const param_type& p) {
16 WriteParam(m, p.is_null()); 17 WriteParam(m, p.is_null());
17 WriteParam(m, p.is_invalid()); 18 WriteParam(m, p.is_invalid());
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 135 }
135 l->append("], "); 136 l->append("], ");
136 LogParam(p.string(), l); 137 LogParam(p.string(), l);
137 l->append(", "); 138 l->append(", ");
138 LogParam(p.date(), l); 139 LogParam(p.date(), l);
139 l->append(", "); 140 l->append(", ");
140 LogParam(p.number(), l); 141 LogParam(p.number(), l);
141 l->append(")"); 142 l->append(")");
142 } 143 }
143 144
145 void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) {
146 WriteParam(m, int(p.type()));
147 switch (p.type()) {
148 case WebKit::WebIDBKeyPath::ArrayType:
149 WriteParam(m, p.array());
150 return;
151 case WebKit::WebIDBKeyPath::StringType:
152 WriteParam(m, p.string());
153 return;
154 case WebKit::WebIDBKeyPath::NullType:
155 return;
156 }
157 NOTREACHED();
158 }
159
160 bool ParamTraits<IndexedDBKeyPath>::Read(const Message* m,
161 PickleIterator* iter,
162 param_type* r) {
163 int type;
164 if (!ReadParam(m, iter, &type))
165 return false;
166
167 switch (type) {
168 case WebKit::WebIDBKeyPath::ArrayType:
169 {
jam 2012/04/30 16:01:29 ditto
jsbell 2012/04/30 18:08:23 Done.
170 std::vector<string16> array;
171 if (!ReadParam(m, iter, &array))
172 return false;
173 r->SetArray(array);
174 return true;
175 }
176 case WebKit::WebIDBKeyPath::StringType:
177 {
178 string16 string;
179 if (!ReadParam(m, iter, &string))
180 return false;
181 r->SetString(string);
182 return true;
183 }
184 case WebKit::WebIDBKeyPath::NullType:
185 r->SetNull();
186 return true;
187 }
188 NOTREACHED();
189 return false;
190 }
191
192 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) {
193 l->append("<IndexedDBKeyPath>(");
194 LogParam(int(p.type()), l);
195 l->append(", ");
196 LogParam(p.string(), l);
197 l->append(", ");
198 l->append("[");
199 std::vector<string16>::const_iterator it = p.array().begin();
200 while (it != p.array().end()) {
201 LogParam(*it, l);
202 ++it;
203 if (it != p.array().end())
204 l->append(", ");
205 }
206 l->append("])");
207 }
208
144 void ParamTraits<IndexedDBKeyRange>::Write(Message* m, const param_type& p) { 209 void ParamTraits<IndexedDBKeyRange>::Write(Message* m, const param_type& p) {
145 WriteParam(m, p.lower()); 210 WriteParam(m, p.lower());
146 WriteParam(m, p.upper()); 211 WriteParam(m, p.upper());
147 WriteParam(m, p.lowerOpen()); 212 WriteParam(m, p.lowerOpen());
148 WriteParam(m, p.upperOpen()); 213 WriteParam(m, p.upperOpen());
149 } 214 }
150 215
151 bool ParamTraits<IndexedDBKeyRange>::Read(const Message* m, 216 bool ParamTraits<IndexedDBKeyRange>::Read(const Message* m,
152 PickleIterator* iter, 217 PickleIterator* iter,
153 param_type* r) { 218 param_type* r) {
(...skipping 24 matching lines...) Expand all
178 l->append(", upper="); 243 l->append(", upper=");
179 LogParam(p.upper(), l); 244 LogParam(p.upper(), l);
180 l->append(", lower_open="); 245 l->append(", lower_open=");
181 LogParam(p.lowerOpen(), l); 246 LogParam(p.lowerOpen(), l);
182 l->append(", upper_open="); 247 l->append(", upper_open=");
183 LogParam(p.upperOpen(), l); 248 LogParam(p.upperOpen(), l);
184 l->append(")"); 249 l->append(")");
185 } 250 }
186 251
187 } // namespace IPC 252 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698