| 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 "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 Loading... |
| 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<content::IndexedDBKeyPath>::Write(Message* m, |
| 146 const param_type& p) { |
| 147 WriteParam(m, int(p.type())); |
| 148 switch (p.type()) { |
| 149 case WebKit::WebIDBKeyPath::ArrayType: |
| 150 WriteParam(m, p.array()); |
| 151 return; |
| 152 case WebKit::WebIDBKeyPath::StringType: |
| 153 WriteParam(m, p.string()); |
| 154 return; |
| 155 case WebKit::WebIDBKeyPath::NullType: |
| 156 return; |
| 157 } |
| 158 NOTREACHED(); |
| 159 } |
| 160 |
| 161 bool ParamTraits<content::IndexedDBKeyPath>::Read(const Message* m, |
| 162 PickleIterator* iter, |
| 163 param_type* r) { |
| 164 int type; |
| 165 if (!ReadParam(m, iter, &type)) |
| 166 return false; |
| 167 |
| 168 switch (type) { |
| 169 case WebKit::WebIDBKeyPath::ArrayType: { |
| 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 string16 string; |
| 178 if (!ReadParam(m, iter, &string)) |
| 179 return false; |
| 180 r->SetString(string); |
| 181 return true; |
| 182 } |
| 183 case WebKit::WebIDBKeyPath::NullType: |
| 184 r->SetNull(); |
| 185 return true; |
| 186 } |
| 187 NOTREACHED(); |
| 188 return false; |
| 189 } |
| 190 |
| 191 void ParamTraits<content::IndexedDBKeyPath>::Log(const param_type& p, |
| 192 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 Loading... |
| 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 |
| OLD | NEW |