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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 case WebIDBKeyTypeInvalid: | 99 case WebIDBKeyTypeInvalid: |
100 case WebIDBKeyTypeNull: | 100 case WebIDBKeyTypeNull: |
101 *r = IndexedDBKey(web_type); | 101 *r = IndexedDBKey(web_type); |
102 return true; | 102 return true; |
103 case WebIDBKeyTypeMin: | 103 case WebIDBKeyTypeMin: |
104 default: | 104 default: |
105 NOTREACHED(); | 105 NOTREACHED(); |
106 return false; | 106 return false; |
107 } | 107 } |
108 NOTREACHED(); | |
109 return false; | |
110 } | 108 } |
111 | 109 |
112 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) { | 110 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) { |
113 l->append("<IndexedDBKey>("); | 111 l->append("<IndexedDBKey>("); |
114 LogParam(static_cast<int>(p.type()), l); | 112 LogParam(static_cast<int>(p.type()), l); |
115 l->append(", "); | 113 l->append(", "); |
116 l->append("["); | 114 l->append("["); |
117 std::vector<IndexedDBKey>::const_iterator it = p.array().begin(); | 115 std::vector<IndexedDBKey>::const_iterator it = p.array().begin(); |
118 while (it != p.array().end()) { | 116 while (it != p.array().end()) { |
119 Log(*it, l); | 117 Log(*it, l); |
(...skipping 16 matching lines...) Expand all Loading... |
136 WriteParam(m, static_cast<int>(p.type())); | 134 WriteParam(m, static_cast<int>(p.type())); |
137 switch (p.type()) { | 135 switch (p.type()) { |
138 case WebIDBKeyPathTypeArray: | 136 case WebIDBKeyPathTypeArray: |
139 WriteParam(m, p.array()); | 137 WriteParam(m, p.array()); |
140 return; | 138 return; |
141 case WebIDBKeyPathTypeString: | 139 case WebIDBKeyPathTypeString: |
142 WriteParam(m, p.string()); | 140 WriteParam(m, p.string()); |
143 return; | 141 return; |
144 case WebIDBKeyPathTypeNull: | 142 case WebIDBKeyPathTypeNull: |
145 return; | 143 return; |
| 144 default: |
| 145 NOTREACHED(); |
| 146 return; |
146 } | 147 } |
147 NOTREACHED(); | |
148 } | 148 } |
149 | 149 |
150 bool ParamTraits<IndexedDBKeyPath>::Read(const Message* m, | 150 bool ParamTraits<IndexedDBKeyPath>::Read(const Message* m, |
151 PickleIterator* iter, | 151 PickleIterator* iter, |
152 param_type* r) { | 152 param_type* r) { |
153 int type; | 153 int type; |
154 if (!ReadParam(m, iter, &type)) | 154 if (!ReadParam(m, iter, &type)) |
155 return false; | 155 return false; |
156 | 156 |
157 switch (type) { | 157 switch (type) { |
158 case WebIDBKeyPathTypeArray: { | 158 case WebIDBKeyPathTypeArray: { |
159 std::vector<base::string16> array; | 159 std::vector<base::string16> array; |
160 if (!ReadParam(m, iter, &array)) | 160 if (!ReadParam(m, iter, &array)) |
161 return false; | 161 return false; |
162 *r = IndexedDBKeyPath(array); | 162 *r = IndexedDBKeyPath(array); |
163 return true; | 163 return true; |
164 } | 164 } |
165 case WebIDBKeyPathTypeString: { | 165 case WebIDBKeyPathTypeString: { |
166 base::string16 string; | 166 base::string16 string; |
167 if (!ReadParam(m, iter, &string)) | 167 if (!ReadParam(m, iter, &string)) |
168 return false; | 168 return false; |
169 *r = IndexedDBKeyPath(string); | 169 *r = IndexedDBKeyPath(string); |
170 return true; | 170 return true; |
171 } | 171 } |
172 case WebIDBKeyPathTypeNull: | 172 case WebIDBKeyPathTypeNull: |
173 *r = IndexedDBKeyPath(); | 173 *r = IndexedDBKeyPath(); |
174 return true; | 174 return true; |
| 175 default: |
| 176 NOTREACHED(); |
| 177 return false; |
175 } | 178 } |
176 NOTREACHED(); | |
177 return false; | |
178 } | 179 } |
179 | 180 |
180 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) { | 181 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) { |
181 l->append("<IndexedDBKeyPath>("); | 182 l->append("<IndexedDBKeyPath>("); |
182 LogParam(static_cast<int>(p.type()), l); | 183 LogParam(static_cast<int>(p.type()), l); |
183 l->append(", "); | 184 l->append(", "); |
184 LogParam(p.string(), l); | 185 LogParam(p.string(), l); |
185 l->append(", "); | 186 l->append(", "); |
186 l->append("["); | 187 l->append("["); |
187 std::vector<base::string16>::const_iterator it = p.array().begin(); | 188 std::vector<base::string16>::const_iterator it = p.array().begin(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 l->append(", upper="); | 231 l->append(", upper="); |
231 LogParam(p.upper(), l); | 232 LogParam(p.upper(), l); |
232 l->append(", lower_open="); | 233 l->append(", lower_open="); |
233 LogParam(p.lowerOpen(), l); | 234 LogParam(p.lowerOpen(), l); |
234 l->append(", upper_open="); | 235 l->append(", upper_open="); |
235 LogParam(p.upperOpen(), l); | 236 LogParam(p.upperOpen(), l); |
236 l->append(")"); | 237 l->append(")"); |
237 } | 238 } |
238 | 239 |
239 } // namespace IPC | 240 } // namespace IPC |
OLD | NEW |