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

Side by Side Diff: base/process_util_win.cc

Issue 6713107: Make the windows_version.h functions threadsafe by using a singleton. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_util.h" 5 #include "base/process_util.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <io.h> 8 #include <io.h>
9 #include <windows.h> 9 #include <windows.h>
10 #include <userenv.h> 10 #include <userenv.h>
11 #include <psapi.h> 11 #include <psapi.h>
12 12
13 #include <ios> 13 #include <ios>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/debug/stack_trace.h" 16 #include "base/debug/stack_trace.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/sys_info.h"
20 #include "base/win/scoped_handle.h" 21 #include "base/win/scoped_handle.h"
21 #include "base/win/windows_version.h" 22 #include "base/win/windows_version.h"
22 23
23 // userenv.dll is required for CreateEnvironmentBlock(). 24 // userenv.dll is required for CreateEnvironmentBlock().
24 #pragma comment(lib, "userenv.lib") 25 #pragma comment(lib, "userenv.lib")
25 26
26 namespace base { 27 namespace base {
27 28
28 namespace { 29 namespace {
29 30
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 wait_milliseconds, 558 wait_milliseconds,
558 filter); 559 filter);
559 if (!exited_cleanly) 560 if (!exited_cleanly)
560 KillProcesses(executable_name, exit_code, filter); 561 KillProcesses(executable_name, exit_code, filter);
561 return exited_cleanly; 562 return exited_cleanly;
562 } 563 }
563 564
564 /////////////////////////////////////////////////////////////////////////////// 565 ///////////////////////////////////////////////////////////////////////////////
565 // ProcesMetrics 566 // ProcesMetrics
566 567
567 ProcessMetrics::ProcessMetrics(ProcessHandle process) : process_(process), 568 ProcessMetrics::ProcessMetrics(ProcessHandle process)
568 last_time_(0), 569 : process_(process),
569 last_system_time_(0) { 570 processor_count_(base::SysInfo::NumberOfProcessors()),
570 SYSTEM_INFO system_info; 571 last_time_(0),
571 GetSystemInfo(&system_info); 572 last_system_time_(0) {
572 processor_count_ = system_info.dwNumberOfProcessors;
573 } 573 }
574 574
575 // static 575 // static
576 ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) { 576 ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) {
577 return new ProcessMetrics(process); 577 return new ProcessMetrics(process);
578 } 578 }
579 579
580 ProcessMetrics::~ProcessMetrics() { } 580 ProcessMetrics::~ProcessMetrics() { }
581 581
582 size_t ProcessMetrics::GetPagefileUsage() const { 582 size_t ProcessMetrics::GetPagefileUsage() const {
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 909
910 PERFORMANCE_INFORMATION info; 910 PERFORMANCE_INFORMATION info;
911 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { 911 if (!InternalGetPerformanceInfo(&info, sizeof(info))) {
912 LOG(ERROR) << "Failed to fetch internal performance info."; 912 LOG(ERROR) << "Failed to fetch internal performance info.";
913 return 0; 913 return 0;
914 } 914 }
915 return (info.CommitTotal * system_info.dwPageSize) / 1024; 915 return (info.CommitTotal * system_info.dwPageSize) / 1024;
916 } 916 }
917 917
918 } // namespace base 918 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698