OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "ipc/ipc_message_utils.h" | 5 #include "ipc/ipc_message_utils.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 *value = val.release(); | 194 *value = val.release(); |
195 break; | 195 break; |
196 } | 196 } |
197 default: | 197 default: |
198 return false; | 198 return false; |
199 } | 199 } |
200 | 200 |
201 return true; | 201 return true; |
202 } | 202 } |
203 | 203 |
| 204 |
| 205 void ParamTraits<base::Time>::Write(Message* m, const param_type& p) { |
| 206 ParamTraits<int64>::Write(m, p.ToInternalValue()); |
| 207 } |
| 208 |
| 209 bool ParamTraits<base::Time>::Read(const Message* m, void** iter, |
| 210 param_type* r) { |
| 211 int64 value; |
| 212 if (!ParamTraits<int64>::Read(m, iter, &value)) |
| 213 return false; |
| 214 *r = base::Time::FromInternalValue(value); |
| 215 return true; |
| 216 } |
| 217 |
| 218 void ParamTraits<base::Time>::Log(const param_type& p, std::wstring* l) { |
| 219 ParamTraits<int64>::Log(p.ToInternalValue(), l); |
| 220 } |
| 221 |
204 void ParamTraits<DictionaryValue>::Write(Message* m, const param_type& p) { | 222 void ParamTraits<DictionaryValue>::Write(Message* m, const param_type& p) { |
205 WriteValue(m, &p, 0); | 223 WriteValue(m, &p, 0); |
206 } | 224 } |
207 | 225 |
208 bool ParamTraits<DictionaryValue>::Read( | 226 bool ParamTraits<DictionaryValue>::Read( |
209 const Message* m, void** iter, param_type* r) { | 227 const Message* m, void** iter, param_type* r) { |
210 int type; | 228 int type; |
211 if (!ReadParam(m, iter, &type) || type != Value::TYPE_DICTIONARY) | 229 if (!ReadParam(m, iter, &type) || type != Value::TYPE_DICTIONARY) |
212 return false; | 230 return false; |
213 | 231 |
(...skipping 18 matching lines...) Expand all Loading... |
232 | 250 |
233 return ReadListValue(m, iter, r, 0); | 251 return ReadListValue(m, iter, r, 0); |
234 } | 252 } |
235 | 253 |
236 void ParamTraits<ListValue>::Log(const param_type& p, std::wstring* l) { | 254 void ParamTraits<ListValue>::Log(const param_type& p, std::wstring* l) { |
237 std::string json; | 255 std::string json; |
238 base::JSONWriter::Write(&p, false, &json); | 256 base::JSONWriter::Write(&p, false, &json); |
239 l->append(UTF8ToWide(json)); | 257 l->append(UTF8ToWide(json)); |
240 } | 258 } |
241 } // namespace IPC | 259 } // namespace IPC |
OLD | NEW |