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

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: 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 base {
16
17 //static
18 const Time* CurrentProcessInfo::CreationTime() {
19 static Time process_creation_time;
20 static bool process_creation_time_initialized = false;
21
22 if (!process_creation_time_initialized) {
23 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
24 size_t len = 0;
25 if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0)
26 return NULL;
27
28 scoped_ptr_malloc<struct kinfo_proc>
29 proc(static_cast<struct kinfo_proc*>(malloc(len)));
30 if (sysctl(mib, arraysize(mib), proc.get(), &len, NULL, 0) < 0)
31 return NULL;
32 process_creation_time =
33 base::Time::FromTimeVal(proc->kp_proc.p_un.__p_starttime);
34 process_creation_time_initialized = true;
35 }
36 return &process_creation_time;
Mark Mentovai 2012/06/15 21:18:57 Oh no! This is no good at all.
37 }
38
39 } // 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