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 "ipc/ipc_message_utils.h" | 5 #include "ipc/ipc_message_utils.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/nullable_string16.h" | 10 #include "base/nullable_string16.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 if (!m->ReadBytes(iter, &data, sizeof(param_type))) | 244 if (!m->ReadBytes(iter, &data, sizeof(param_type))) |
245 return false; | 245 return false; |
246 memcpy(r, data, sizeof(param_type)); | 246 memcpy(r, data, sizeof(param_type)); |
247 return true; | 247 return true; |
248 } | 248 } |
249 | 249 |
250 void ParamTraits<unsigned short>::Log(const param_type& p, std::string* l) { | 250 void ParamTraits<unsigned short>::Log(const param_type& p, std::string* l) { |
251 l->append(base::UintToString(p)); | 251 l->append(base::UintToString(p)); |
252 } | 252 } |
253 | 253 |
| 254 void ParamTraits<base::PlatformFileInfo>::Write( |
| 255 Message* m, const param_type& p) { |
| 256 WriteParam(m, p.size); |
| 257 WriteParam(m, p.is_directory); |
| 258 WriteParam(m, p.last_modified.ToDoubleT()); |
| 259 WriteParam(m, p.last_accessed.ToDoubleT()); |
| 260 WriteParam(m, p.creation_time.ToDoubleT()); |
| 261 } |
| 262 |
| 263 bool ParamTraits<base::PlatformFileInfo>::Read( |
| 264 const Message* m, PickleIterator* iter, param_type* p) { |
| 265 double last_modified; |
| 266 double last_accessed; |
| 267 double creation_time; |
| 268 bool result = |
| 269 ReadParam(m, iter, &p->size) && |
| 270 ReadParam(m, iter, &p->is_directory) && |
| 271 ReadParam(m, iter, &last_modified) && |
| 272 ReadParam(m, iter, &last_accessed) && |
| 273 ReadParam(m, iter, &creation_time); |
| 274 if (result) { |
| 275 p->last_modified = base::Time::FromDoubleT(last_modified); |
| 276 p->last_accessed = base::Time::FromDoubleT(last_accessed); |
| 277 p->creation_time = base::Time::FromDoubleT(creation_time); |
| 278 } |
| 279 return result; |
| 280 } |
| 281 |
| 282 void ParamTraits<base::PlatformFileInfo>::Log( |
| 283 const param_type& p, std::string* l) { |
| 284 l->append("("); |
| 285 LogParam(p.size, l); |
| 286 l->append(","); |
| 287 LogParam(p.is_directory, l); |
| 288 l->append(","); |
| 289 LogParam(p.last_modified.ToDoubleT(), l); |
| 290 l->append(","); |
| 291 LogParam(p.last_accessed.ToDoubleT(), l); |
| 292 l->append(","); |
| 293 LogParam(p.creation_time.ToDoubleT(), l); |
| 294 l->append(")"); |
| 295 } |
| 296 |
254 void ParamTraits<base::Time>::Write(Message* m, const param_type& p) { | 297 void ParamTraits<base::Time>::Write(Message* m, const param_type& p) { |
255 ParamTraits<int64>::Write(m, p.ToInternalValue()); | 298 ParamTraits<int64>::Write(m, p.ToInternalValue()); |
256 } | 299 } |
257 | 300 |
258 bool ParamTraits<base::Time>::Read(const Message* m, PickleIterator* iter, | 301 bool ParamTraits<base::Time>::Read(const Message* m, PickleIterator* iter, |
259 param_type* r) { | 302 param_type* r) { |
260 int64 value; | 303 int64 value; |
261 if (!ParamTraits<int64>::Read(m, iter, &value)) | 304 if (!ParamTraits<int64>::Read(m, iter, &value)) |
262 return false; | 305 return false; |
263 *r = base::Time::FromInternalValue(value); | 306 *r = base::Time::FromInternalValue(value); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 ReadParam(m, iter, &r->routing_id) && | 539 ReadParam(m, iter, &r->routing_id) && |
497 ReadParam(m, iter, &r->type) && | 540 ReadParam(m, iter, &r->type) && |
498 ReadParam(m, iter, &r->flags) && | 541 ReadParam(m, iter, &r->flags) && |
499 ReadParam(m, iter, &r->sent) && | 542 ReadParam(m, iter, &r->sent) && |
500 ReadParam(m, iter, &r->receive) && | 543 ReadParam(m, iter, &r->receive) && |
501 ReadParam(m, iter, &r->dispatch) && | 544 ReadParam(m, iter, &r->dispatch) && |
502 ReadParam(m, iter, &r->params); | 545 ReadParam(m, iter, &r->params); |
503 } | 546 } |
504 | 547 |
505 } // namespace IPC | 548 } // namespace IPC |
OLD | NEW |