Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/process/process_info.h" | |
| 6 | |
| 7 #include "base/basictypes.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "base/process/internal_linux.h" | |
| 10 #include "base/process/process_handle.h" | |
| 11 #include "base/time/time.h" | |
| 12 | |
| 13 namespace base { | |
| 14 namespace { | |
| 15 | |
| 16 using base::Time; | |
| 17 | |
| 18 Time* ProcessCreationTimeInternal() { | |
| 19 ProcessHandle pid = GetCurrentProcessHandle(); | |
| 20 int start_ticks = internal::ReadProcStatsAndGetFieldAsInt( | |
| 21 pid, internal::VM_STARTTIME); | |
| 22 DCHECK(start_ticks); | |
| 23 TimeDelta start_offset = internal::ClockTicksToTimeDelta(start_ticks); | |
| 24 Time boot_time = internal::GetBootTime(); | |
| 25 DCHECK(!boot_time.is_null()); | |
| 26 return new Time(boot_time + start_offset); | |
| 27 } | |
| 28 | |
| 29 } // namespace | |
| 30 | |
| 31 //static | |
| 32 const Time* CurrentProcessInfo::CreationTime() { | |
| 33 static Time* process_creation_time = ProcessCreationTimeInternal(); | |
|
jln (very slow on Chromium)
2013/08/06 18:57:29
This caching seems a bit dangerous on Linux.
We u
James Simonsen
2013/08/06 19:09:08
I'll just remove it. It's done this way because th
| |
| 34 return process_creation_time; | |
| 35 } | |
| 36 | |
| 37 } // namespace base | |
| OLD | NEW |