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

Side by Side Diff: base/process_info_mac.cc

Issue 10561009: Consolidate RecordBrowserStartupTime() into one location (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix review comments - utilize Time::is_null() Created 8 years, 6 months 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
OLDNEW
(Empty)
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 #include "base/process_info.h"
6
7 #include <sys/sysctl.h>
8 #include <sys/time.h>
9 #include <unistd.h>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/time.h"
14
15 namespace {
16
17 using base::Time;
18
19 // Returns the process creation time, or a null time object if an error
20 // occurred.
21 Time ProcessCreationTimeInternal() {
22 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
23 size_t len = 0;
24 if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0)
25 return Time();
26
27 scoped_ptr_malloc<struct kinfo_proc>
28 proc(static_cast<struct kinfo_proc*>(malloc(len)));
29 if (sysctl(mib, arraysize(mib), proc.get(), &len, NULL, 0) < 0)
30 return Time();
31 return Time::FromTimeVal(proc->kp_proc.p_un.__p_starttime);
32 }
33
34 } // namespace
35
36 namespace base {
37
38 //static
39 const Time* CurrentProcessInfo::CreationTime() {
40 static Time process_creation_time = ProcessCreationTimeInternal();
Mark Mentovai 2012/06/19 16:08:00 Did “new Time()” and using the Time* interface to
41 return &process_creation_time;
42 }
43
44 } // namespace base
OLDNEW
« no previous file with comments | « base/process_info.h ('k') | base/process_info_win.cc » ('j') | base/process_info_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698