Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/process/process_info.h" | 5 #include "base/process/process_info.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/process/internal_linux.h" | 10 #include "base/process/internal_linux.h" |
| 11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 const Time CurrentProcessInfo::CreationTime() { | 17 const Time CurrentProcessInfo::CreationTime() { |
| 18 int64_t start_ticks = | 18 int64_t start_ticks = |
| 19 internal::ReadProcSelfStatsAndGetFieldAsInt64(internal::VM_STARTTIME); | 19 internal::ReadProcSelfStatsAndGetFieldAsInt64(internal::VM_STARTTIME); |
| 20 DCHECK(start_ticks); | 20 if (!start_ticks) |
|
Nico
2017/03/21 21:01:55
this is covered by tests, yes?
ssid
2017/03/22 00:41:08
I added an unittest.
| |
| 21 return Time(); | |
| 21 TimeDelta start_offset = internal::ClockTicksToTimeDelta(start_ticks); | 22 TimeDelta start_offset = internal::ClockTicksToTimeDelta(start_ticks); |
| 22 Time boot_time = internal::GetBootTime(); | 23 Time boot_time = internal::GetBootTime(); |
| 23 DCHECK(!boot_time.is_null()); | 24 if (boot_time.is_null()) |
| 25 return Time(); | |
| 24 return Time(boot_time + start_offset); | 26 return Time(boot_time + start_offset); |
| 25 } | 27 } |
| 26 | 28 |
| 27 } // namespace base | 29 } // namespace base |
| OLD | NEW |