diff options
author | miu <miu@chromium.org> | 2015-05-29 16:57:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-29 23:57:41 +0000 |
commit | 1ab506aa9720454e32b815090a3fa3dd8d7145bc (patch) | |
tree | 04f6d6885936d1cc23228ce4b6e8ecb3c483262e /ipc | |
parent | 6cccd7e7965c94f7a7872addca15efaf1a4fd168 (diff) | |
download | chromium_src-1ab506aa9720454e32b815090a3fa3dd8d7145bc.zip chromium_src-1ab506aa9720454e32b815090a3fa3dd8d7145bc.tar.gz chromium_src-1ab506aa9720454e32b815090a3fa3dd8d7145bc.tar.bz2 |
Fixit: Fork base::TimeTicks --> TimeTicks + ThreadTicks + TraceTicks
TimeTicks was being overused for time values from three different clock
sources. This change splits the class into three separate classes: The
general-purpose monotonic time (TimeTicks), the thread-local run time
(ThreadTicks), and the global system trace time (TraceTicks). With this
change, the compiler is now able to use type-checking to guarantee
values from different clocks are not being mixed when doing time math.
This is the 2nd in a two-part change. Part 1 factored-out the
comparison and math operator overloads common to base::Time and
base::TimeTicks into a templated base class. The new ThreadTicks and
TraceTicks time classes also inherit from that base class.
Updated base/trace_event/* and a handful of outside-of-base uses of
ThreadNow() and NowFromSystemTraceTime() to use the new classes. A bug
was identified and fixed, in src/ui/gl/angle_platform_impl.cc, where
values from TimeTicks::Now() were being erroneously provided to
base::TraceEvent instead of values from NowFromSystemTraceTime().
BUG=467417
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
NOTRY=true
Review URL: https://codereview.chromium.org/1122153002
Cr-Commit-Position: refs/heads/master@{#332080}
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/ipc_message_utils.cc | 19 | ||||
-rw-r--r-- | ipc/ipc_message_utils.h | 9 |
2 files changed, 28 insertions, 0 deletions
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc index a00e857..58dc510 100644 --- a/ipc/ipc_message_utils.cc +++ b/ipc/ipc_message_utils.cc @@ -660,6 +660,25 @@ void ParamTraits<base::TimeTicks>::Log(const param_type& p, std::string* l) { ParamTraits<int64>::Log(p.ToInternalValue(), l); } +void ParamTraits<base::TraceTicks>::Write(Message* m, const param_type& p) { + ParamTraits<int64>::Write(m, p.ToInternalValue()); +} + +bool ParamTraits<base::TraceTicks>::Read(const Message* m, + PickleIterator* iter, + param_type* r) { + int64 value; + bool ret = ParamTraits<int64>::Read(m, iter, &value); + if (ret) + *r = base::TraceTicks::FromInternalValue(value); + + return ret; +} + +void ParamTraits<base::TraceTicks>::Log(const param_type& p, std::string* l) { + ParamTraits<int64>::Log(p.ToInternalValue(), l); +} + void ParamTraits<IPC::ChannelHandle>::Write(Message* m, const param_type& p) { #if defined(OS_WIN) // On Windows marshalling pipe handle is not supported. diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 71bfbdf..1e3ee0c 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -55,6 +55,7 @@ class NullableString16; class Time; class TimeDelta; class TimeTicks; +class TraceTicks; struct FileDescriptor; } @@ -503,6 +504,14 @@ struct IPC_EXPORT ParamTraits<base::TimeTicks> { }; template <> +struct IPC_EXPORT ParamTraits<base::TraceTicks> { + typedef base::TraceTicks param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, PickleIterator* iter, param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> struct ParamTraits<base::Tuple<>> { typedef base::Tuple<> param_type; static void Write(Message* m, const param_type& p) { |