Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: base/profiler/tracked_time.cc

Issue 8496008: Revert 108752 - Support tracking of IPC messages as tasks in profiler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/profiler/tracked_time.h ('k') | base/profiler/tracked_time_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/profiler/tracked_time.h"
6
7 #include "build/build_config.h"
8
9 #if defined(OS_WIN)
10 #include <mmsystem.h> // Declare timeGetTime()... after including build_config.
11 #endif
12
13 namespace tracked_objects {
14
15 #if defined(USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS)
16
17 Duration::Duration() : ms_(0) {}
18 Duration::Duration(int32 duration) : ms_(duration) {}
19
20 Duration& Duration::operator+=(const Duration& other) {
21 ms_ += other.ms_;
22 return *this;
23 }
24
25 Duration Duration::operator+(const Duration& other) const {
26 return Duration(ms_ + other.ms_);
27 }
28
29 bool Duration::operator==(const Duration& other) const {
30 return ms_ == other.ms_;
31 }
32
33 bool Duration::operator!=(const Duration& other) const {
34 return ms_ != other.ms_;
35 }
36
37 bool Duration::operator>(const Duration& other) const {
38 return ms_ > other.ms_;
39 }
40
41 // static
42 Duration Duration::FromMilliseconds(int ms) { return Duration(ms); }
43
44 int32 Duration::InMilliseconds() const { return ms_; }
45
46 //------------------------------------------------------------------------------
47
48 TrackedTime::TrackedTime() : ms_(0) {}
49 TrackedTime::TrackedTime(int32 ms) : ms_(ms) {}
50 TrackedTime::TrackedTime(const base::TimeTicks& time)
51 : ms_((time - base::TimeTicks()).InMilliseconds()) {
52 }
53
54 // static
55 TrackedTime TrackedTime::Now() {
56 #if defined(OS_WIN)
57 // Use lock-free accessor to 32 bit time.
58 // Note that TimeTicks::Now() is built on this, so we have "compatible"
59 // times when we down-convert a TimeTicks sample.
60 // TODO(jar): Surface this interface via something in base/time.h.
61 return TrackedTime(static_cast<int32>(timeGetTime()));
62 #else
63 // Posix has nice cheap 64 bit times, so we just down-convert it.
64 return TrackedTime(base::TimeTicks::Now());
65 #endif // OS_WIN
66 }
67
68 Duration TrackedTime::operator-(const TrackedTime& other) const {
69 return Duration(ms_ - other.ms_);
70 }
71
72 TrackedTime TrackedTime::operator+(const Duration& other) const {
73 return TrackedTime(ms_ + other.ms_);
74 }
75
76 bool TrackedTime::is_null() const { return ms_ == 0; }
77
78 #endif // USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS
79
80 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « base/profiler/tracked_time.h ('k') | base/profiler/tracked_time_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698