OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_info.h" | 5 #include "base/process_info.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/time.h" | 10 #include "base/time/time.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 using base::Time; | 14 using base::Time; |
15 | 15 |
16 // Returns the process creation time, or NULL if an error occurred. | 16 // Returns the process creation time, or NULL if an error occurred. |
17 Time* ProcessCreationTimeInternal() { | 17 Time* ProcessCreationTimeInternal() { |
18 FILETIME creation_time = {}; | 18 FILETIME creation_time = {}; |
19 FILETIME ignore = {}; | 19 FILETIME ignore = {}; |
20 if (::GetProcessTimes(::GetCurrentProcess(), &creation_time, &ignore, | 20 if (::GetProcessTimes(::GetCurrentProcess(), &creation_time, &ignore, |
21 &ignore, &ignore) == false) | 21 &ignore, &ignore) == false) |
22 return NULL; | 22 return NULL; |
23 | 23 |
24 return new Time(Time::FromFileTime(creation_time)); | 24 return new Time(Time::FromFileTime(creation_time)); |
25 } | 25 } |
26 | 26 |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 namespace base { | 29 namespace base { |
30 | 30 |
31 //static | 31 //static |
32 const Time* CurrentProcessInfo::CreationTime() { | 32 const Time* CurrentProcessInfo::CreationTime() { |
33 static Time* process_creation_time = ProcessCreationTimeInternal(); | 33 static Time* process_creation_time = ProcessCreationTimeInternal(); |
34 return process_creation_time; | 34 return process_creation_time; |
35 } | 35 } |
36 | 36 |
37 } // namespace base | 37 } // namespace base |
OLD | NEW |