~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/third_party/chromium/src/base/profiler/tracked_time.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
3
 
// found in the LICENSE file.
4
 
 
5
 
#ifndef BASE_PROFILER_TRACKED_TIME_H_
6
 
#define BASE_PROFILER_TRACKED_TIME_H_
7
 
 
8
 
 
9
 
#include "base/base_export.h"
10
 
#include "base/basictypes.h"
11
 
#include "base/time/time.h"
12
 
 
13
 
namespace tracked_objects {
14
 
 
15
 
//------------------------------------------------------------------------------
16
 
 
17
 
// TimeTicks maintains a wasteful 64 bits of data (we need less than 32), and on
18
 
// windows, a 64 bit timer is expensive to even obtain. We use a simple
19
 
// millisecond counter for most of our time values, as well as millisecond units
20
 
// of duration between those values.  This means we can only handle durations
21
 
// up to 49 days (range), or 24 days (non-negative time durations).
22
 
// We only define enough methods to service the needs of the tracking classes,
23
 
// and our interfaces are modeled after what TimeTicks and TimeDelta use (so we
24
 
// can swap them into place if we want to use the "real" classes).
25
 
 
26
 
class BASE_EXPORT Duration {  // Similar to base::TimeDelta.
27
 
 public:
28
 
  Duration();
29
 
 
30
 
  Duration& operator+=(const Duration& other);
31
 
  Duration operator+(const Duration& other) const;
32
 
 
33
 
  bool operator==(const Duration& other) const;
34
 
  bool operator!=(const Duration& other) const;
35
 
  bool operator>(const Duration& other) const;
36
 
 
37
 
  static Duration FromMilliseconds(int ms);
38
 
 
39
 
  int32 InMilliseconds() const;
40
 
 
41
 
 private:
42
 
  friend class TrackedTime;
43
 
  explicit Duration(int32 duration);
44
 
 
45
 
  // Internal time is stored directly in milliseconds.
46
 
  int32 ms_;
47
 
};
48
 
 
49
 
class BASE_EXPORT TrackedTime {  // Similar to base::TimeTicks.
50
 
 public:
51
 
  TrackedTime();
52
 
  explicit TrackedTime(const base::TimeTicks& time);
53
 
 
54
 
  static TrackedTime Now();
55
 
  Duration operator-(const TrackedTime& other) const;
56
 
  TrackedTime operator+(const Duration& other) const;
57
 
  bool is_null() const;
58
 
 
59
 
  static TrackedTime FromMilliseconds(int32 ms) { return TrackedTime(ms); }
60
 
 
61
 
 private:
62
 
  friend class Duration;
63
 
  explicit TrackedTime(int32 ms);
64
 
 
65
 
  // Internal duration is stored directly in milliseconds.
66
 
  uint32 ms_;
67
 
};
68
 
 
69
 
}  // namespace tracked_objects
70
 
 
71
 
#endif  // BASE_PROFILER_TRACKED_TIME_H_