| 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 <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" | 10 #include "content/common/indexed_db/indexed_db_key_path.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 using blink::WebIDBKeyTypeBinary; | 23 using blink::WebIDBKeyTypeBinary; |
| 24 using blink::WebIDBKeyTypeDate; | 24 using blink::WebIDBKeyTypeDate; |
| 25 using blink::WebIDBKeyTypeInvalid; | 25 using blink::WebIDBKeyTypeInvalid; |
| 26 using blink::WebIDBKeyTypeMin; | 26 using blink::WebIDBKeyTypeMin; |
| 27 using blink::WebIDBKeyTypeNull; | 27 using blink::WebIDBKeyTypeNull; |
| 28 using blink::WebIDBKeyTypeNumber; | 28 using blink::WebIDBKeyTypeNumber; |
| 29 using blink::WebIDBKeyTypeString; | 29 using blink::WebIDBKeyTypeString; |
| 30 | 30 |
| 31 namespace IPC { | 31 namespace IPC { |
| 32 | 32 |
| 33 void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) { | 33 void ParamTraits<IndexedDBKey>::Write(base::Pickle* m, const param_type& p) { |
| 34 WriteParam(m, static_cast<int>(p.type())); | 34 WriteParam(m, static_cast<int>(p.type())); |
| 35 switch (p.type()) { | 35 switch (p.type()) { |
| 36 case WebIDBKeyTypeArray: | 36 case WebIDBKeyTypeArray: |
| 37 WriteParam(m, p.array()); | 37 WriteParam(m, p.array()); |
| 38 return; | 38 return; |
| 39 case WebIDBKeyTypeBinary: | 39 case WebIDBKeyTypeBinary: |
| 40 WriteParam(m, p.binary()); | 40 WriteParam(m, p.binary()); |
| 41 return; | 41 return; |
| 42 case WebIDBKeyTypeString: | 42 case WebIDBKeyTypeString: |
| 43 WriteParam(m, p.string()); | 43 WriteParam(m, p.string()); |
| 44 return; | 44 return; |
| 45 case WebIDBKeyTypeDate: | 45 case WebIDBKeyTypeDate: |
| 46 WriteParam(m, p.date()); | 46 WriteParam(m, p.date()); |
| 47 return; | 47 return; |
| 48 case WebIDBKeyTypeNumber: | 48 case WebIDBKeyTypeNumber: |
| 49 WriteParam(m, p.number()); | 49 WriteParam(m, p.number()); |
| 50 return; | 50 return; |
| 51 case WebIDBKeyTypeInvalid: | 51 case WebIDBKeyTypeInvalid: |
| 52 case WebIDBKeyTypeNull: | 52 case WebIDBKeyTypeNull: |
| 53 return; | 53 return; |
| 54 case WebIDBKeyTypeMin: | 54 case WebIDBKeyTypeMin: |
| 55 default: | 55 default: |
| 56 NOTREACHED(); | 56 NOTREACHED(); |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool ParamTraits<IndexedDBKey>::Read(const Message* m, | 61 bool ParamTraits<IndexedDBKey>::Read(const base::Pickle* m, |
| 62 base::PickleIterator* iter, | 62 base::PickleIterator* iter, |
| 63 param_type* r) { | 63 param_type* r) { |
| 64 int type; | 64 int type; |
| 65 if (!ReadParam(m, iter, &type)) | 65 if (!ReadParam(m, iter, &type)) |
| 66 return false; | 66 return false; |
| 67 WebIDBKeyType web_type = static_cast<WebIDBKeyType>(type); | 67 WebIDBKeyType web_type = static_cast<WebIDBKeyType>(type); |
| 68 | 68 |
| 69 switch (web_type) { | 69 switch (web_type) { |
| 70 case WebIDBKeyTypeArray: { | 70 case WebIDBKeyTypeArray: { |
| 71 std::vector<IndexedDBKey> array; | 71 std::vector<IndexedDBKey> array; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 l->append("null"); | 146 l->append("null"); |
| 147 break; | 147 break; |
| 148 case WebIDBKeyTypeMin: | 148 case WebIDBKeyTypeMin: |
| 149 default: | 149 default: |
| 150 NOTREACHED(); | 150 NOTREACHED(); |
| 151 break; | 151 break; |
| 152 } | 152 } |
| 153 l->append(")"); | 153 l->append(")"); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) { | 156 void ParamTraits<IndexedDBKeyPath>::Write(base::Pickle* m, |
| 157 const param_type& p) { |
| 157 WriteParam(m, static_cast<int>(p.type())); | 158 WriteParam(m, static_cast<int>(p.type())); |
| 158 switch (p.type()) { | 159 switch (p.type()) { |
| 159 case WebIDBKeyPathTypeArray: | 160 case WebIDBKeyPathTypeArray: |
| 160 WriteParam(m, p.array()); | 161 WriteParam(m, p.array()); |
| 161 return; | 162 return; |
| 162 case WebIDBKeyPathTypeString: | 163 case WebIDBKeyPathTypeString: |
| 163 WriteParam(m, p.string()); | 164 WriteParam(m, p.string()); |
| 164 return; | 165 return; |
| 165 case WebIDBKeyPathTypeNull: | 166 case WebIDBKeyPathTypeNull: |
| 166 return; | 167 return; |
| 167 default: | 168 default: |
| 168 NOTREACHED(); | 169 NOTREACHED(); |
| 169 return; | 170 return; |
| 170 } | 171 } |
| 171 } | 172 } |
| 172 | 173 |
| 173 bool ParamTraits<IndexedDBKeyPath>::Read(const Message* m, | 174 bool ParamTraits<IndexedDBKeyPath>::Read(const base::Pickle* m, |
| 174 base::PickleIterator* iter, | 175 base::PickleIterator* iter, |
| 175 param_type* r) { | 176 param_type* r) { |
| 176 int type; | 177 int type; |
| 177 if (!ReadParam(m, iter, &type)) | 178 if (!ReadParam(m, iter, &type)) |
| 178 return false; | 179 return false; |
| 179 | 180 |
| 180 switch (type) { | 181 switch (type) { |
| 181 case WebIDBKeyPathTypeArray: { | 182 case WebIDBKeyPathTypeArray: { |
| 182 std::vector<base::string16> array; | 183 std::vector<base::string16> array; |
| 183 if (!ReadParam(m, iter, &array)) | 184 if (!ReadParam(m, iter, &array)) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 case WebIDBKeyPathTypeNull: | 224 case WebIDBKeyPathTypeNull: |
| 224 l->append("null"); | 225 l->append("null"); |
| 225 break; | 226 break; |
| 226 default: | 227 default: |
| 227 NOTREACHED(); | 228 NOTREACHED(); |
| 228 break; | 229 break; |
| 229 } | 230 } |
| 230 l->append(")"); | 231 l->append(")"); |
| 231 } | 232 } |
| 232 | 233 |
| 233 void ParamTraits<IndexedDBKeyRange>::Write(Message* m, const param_type& p) { | 234 void ParamTraits<IndexedDBKeyRange>::Write(base::Pickle* m, |
| 235 const param_type& p) { |
| 234 WriteParam(m, p.lower()); | 236 WriteParam(m, p.lower()); |
| 235 WriteParam(m, p.upper()); | 237 WriteParam(m, p.upper()); |
| 236 WriteParam(m, p.lower_open()); | 238 WriteParam(m, p.lower_open()); |
| 237 WriteParam(m, p.upper_open()); | 239 WriteParam(m, p.upper_open()); |
| 238 } | 240 } |
| 239 | 241 |
| 240 bool ParamTraits<IndexedDBKeyRange>::Read(const Message* m, | 242 bool ParamTraits<IndexedDBKeyRange>::Read(const base::Pickle* m, |
| 241 base::PickleIterator* iter, | 243 base::PickleIterator* iter, |
| 242 param_type* r) { | 244 param_type* r) { |
| 243 IndexedDBKey lower; | 245 IndexedDBKey lower; |
| 244 if (!ReadParam(m, iter, &lower)) | 246 if (!ReadParam(m, iter, &lower)) |
| 245 return false; | 247 return false; |
| 246 | 248 |
| 247 IndexedDBKey upper; | 249 IndexedDBKey upper; |
| 248 if (!ReadParam(m, iter, &upper)) | 250 if (!ReadParam(m, iter, &upper)) |
| 249 return false; | 251 return false; |
| 250 | 252 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 266 l->append(", upper="); | 268 l->append(", upper="); |
| 267 LogParam(p.upper(), l); | 269 LogParam(p.upper(), l); |
| 268 l->append(", lower_open="); | 270 l->append(", lower_open="); |
| 269 LogParam(p.lower_open(), l); | 271 LogParam(p.lower_open(), l); |
| 270 l->append(", upper_open="); | 272 l->append(", upper_open="); |
| 271 LogParam(p.upper_open(), l); | 273 LogParam(p.upper_open(), l); |
| 272 l->append(")"); | 274 l->append(")"); |
| 273 } | 275 } |
| 274 | 276 |
| 275 } // namespace IPC | 277 } // namespace IPC |
| OLD | NEW |