summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-21 22:04:52 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-21 22:04:52 +0000
commitd84e48bd89792839904c2374c29be7178016c8f3 (patch)
tree953660d570974d48178bb0ce5aa078150888e44e /ipc
parentca340e836e37e450e86a2a180e02c77af319e4d7 (diff)
downloadchromium_src-d84e48bd89792839904c2374c29be7178016c8f3.zip
chromium_src-d84e48bd89792839904c2374c29be7178016c8f3.tar.gz
chromium_src-d84e48bd89792839904c2374c29be7178016c8f3.tar.bz2
Added IPC ParamTraits for TimeDelta.
Already reviewed as part of http://codereview.chromium.org/3794011/show TBR=kbr@chromium.org TEST=try BUG=none Review URL: http://codereview.chromium.org/4026004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc_message_utils.cc19
-rw-r--r--ipc/ipc_message_utils.h9
2 files changed, 28 insertions, 0 deletions
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc
index 9664810..cc10cc2 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -250,6 +250,25 @@ void ParamTraits<base::Time>::Log(const param_type& p, std::string* l) {
ParamTraits<int64>::Log(p.ToInternalValue(), l);
}
+void ParamTraits<base::TimeDelta> ::Write(Message* m, const param_type& p) {
+ ParamTraits<int64> ::Write(m, p.InMicroseconds());
+}
+
+bool ParamTraits<base::TimeDelta> ::Read(const Message* m,
+ void** iter,
+ param_type* r) {
+ int64 value;
+ bool ret = ParamTraits<int64> ::Read(m, iter, &value);
+ if (ret)
+ *r = base::TimeDelta::FromMicroseconds(value);
+
+ return ret;
+}
+
+void ParamTraits<base::TimeDelta> ::Log(const param_type& p, std::string* l) {
+ ParamTraits<int64> ::Log(p.InMicroseconds(), l);
+}
+
void ParamTraits<DictionaryValue>::Write(Message* m, const param_type& p) {
WriteValue(m, &p, 0);
}
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 0e22c6b..9629fac 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -88,6 +88,7 @@ class NullableString16;
namespace base {
class Time;
+class TimeDelta;
struct FileDescriptor;
}
@@ -293,6 +294,14 @@ struct ParamTraits<base::Time> {
static void Log(const param_type& p, std::string* l);
};
+template <>
+struct ParamTraits<base::TimeDelta> {
+ typedef base::TimeDelta param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::string* l);
+};
+
#if defined(OS_WIN)
template <>
struct ParamTraits<LOGFONT> {