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 | |
222 void ParamTraits<DictionaryValue>::Write(Message* m, const param_type& p) { | 204 void ParamTraits<DictionaryValue>::Write(Message* m, const param_type& p) { |
223 WriteValue(m, &p, 0); | 205 WriteValue(m, &p, 0); |
224 } | 206 } |
225 | 207 |
226 bool ParamTraits<DictionaryValue>::Read( | 208 bool ParamTraits<DictionaryValue>::Read( |
227 const Message* m, void** iter, param_type* r) { | 209 const Message* m, void** iter, param_type* r) { |
228 int type; | 210 int type; |
229 if (!ReadParam(m, iter, &type) || type != Value::TYPE_DICTIONARY) | 211 if (!ReadParam(m, iter, &type) || type != Value::TYPE_DICTIONARY) |
230 return false; | 212 return false; |
231 | 213 |
(...skipping 18 matching lines...) Expand all Loading... |
250 | 232 |
251 return ReadListValue(m, iter, r, 0); | 233 return ReadListValue(m, iter, r, 0); |
252 } | 234 } |
253 | 235 |
254 void ParamTraits<ListValue>::Log(const param_type& p, std::wstring* l) { | 236 void ParamTraits<ListValue>::Log(const param_type& p, std::wstring* l) { |
255 std::string json; | 237 std::string json; |
256 base::JSONWriter::Write(&p, false, &json); | 238 base::JSONWriter::Write(&p, false, &json); |
257 l->append(UTF8ToWide(json)); | 239 l->append(UTF8ToWide(json)); |
258 } | 240 } |
259 } // namespace IPC | 241 } // namespace IPC |
OLD | NEW |