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

Side by Side Diff: base/process/process_info_mac.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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
« no previous file with comments | « base/process/process_handle_win.cc ('k') | base/process/process_info_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/process_info.h" 5 #include "base/process/process_info.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <sys/sysctl.h> 8 #include <sys/sysctl.h>
9 #include <sys/time.h> 9 #include <sys/time.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #include <memory>
13
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/free_deleter.h" 15 #include "base/memory/free_deleter.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 17
17 namespace base { 18 namespace base {
18 19
19 // static 20 // static
20 const Time CurrentProcessInfo::CreationTime() { 21 const Time CurrentProcessInfo::CreationTime() {
21 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() }; 22 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
22 size_t len = 0; 23 size_t len = 0;
23 if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0) 24 if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0)
24 return Time(); 25 return Time();
25 26
26 scoped_ptr<struct kinfo_proc, base::FreeDeleter> 27 std::unique_ptr<struct kinfo_proc, base::FreeDeleter> proc(
27 proc(static_cast<struct kinfo_proc*>(malloc(len))); 28 static_cast<struct kinfo_proc*>(malloc(len)));
28 if (sysctl(mib, arraysize(mib), proc.get(), &len, NULL, 0) < 0) 29 if (sysctl(mib, arraysize(mib), proc.get(), &len, NULL, 0) < 0)
29 return Time(); 30 return Time();
30 return Time::FromTimeVal(proc->kp_proc.p_un.__p_starttime); 31 return Time::FromTimeVal(proc->kp_proc.p_un.__p_starttime);
31 } 32 }
32 33
33 } // namespace base 34 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_handle_win.cc ('k') | base/process/process_info_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698