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

Side by Side Diff: chrome/browser/memory_details_win.cc

Issue 6126002: Remove base/scoped_handle_win.h stub and fix up all callers to use the new location and namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 11 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) 2010 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 "chrome/browser/memory_details.h" 5 #include "chrome/browser/memory_details.h"
6
6 #include <psapi.h> 7 #include <psapi.h>
7 8
8 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
9 #include "base/file_path.h" 10 #include "base/file_path.h"
10 #include "base/file_version_info.h" 11 #include "base/file_version_info.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "base/win/scoped_handle.h"
13 #include "chrome/browser/browser_child_process_host.h" 15 #include "chrome/browser/browser_child_process_host.h"
14 #include "chrome/browser/browser_thread.h" 16 #include "chrome/browser/browser_thread.h"
15 #include "chrome/browser/renderer_host/backing_store_manager.h" 17 #include "chrome/browser/renderer_host/backing_store_manager.h"
16 #include "chrome/browser/renderer_host/render_process_host.h" 18 #include "chrome/browser/renderer_host/render_process_host.h"
17 #include "chrome/browser/tab_contents/navigation_entry.h" 19 #include "chrome/browser/tab_contents/navigation_entry.h"
18 #include "chrome/common/chrome_version_info.h" 20 #include "chrome/common/chrome_version_info.h"
19 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
20 #include "grit/chromium_strings.h" 22 #include "grit/chromium_strings.h"
21 23
22 // Known browsers which we collect details for. 24 // Known browsers which we collect details for.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 69
68 // Clear old data. 70 // Clear old data.
69 for (unsigned int index = 0; index < process_data_.size(); index++) 71 for (unsigned int index = 0; index < process_data_.size(); index++)
70 process_data_[index].processes.clear(); 72 process_data_[index].processes.clear();
71 73
72 SYSTEM_INFO system_info; 74 SYSTEM_INFO system_info;
73 GetNativeSystemInfo(&system_info); 75 GetNativeSystemInfo(&system_info);
74 bool is_64bit_os = 76 bool is_64bit_os =
75 system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64; 77 system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64;
76 78
77 ScopedHandle snapshot(::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)); 79 base::win::ScopedHandle snapshot(
80 ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0));
78 PROCESSENTRY32 process_entry = {sizeof(PROCESSENTRY32)}; 81 PROCESSENTRY32 process_entry = {sizeof(PROCESSENTRY32)};
79 if (!snapshot.Get()) { 82 if (!snapshot.Get()) {
80 LOG(ERROR) << "CreateToolhelp32Snaphot failed: " << GetLastError(); 83 LOG(ERROR) << "CreateToolhelp32Snaphot failed: " << GetLastError();
81 return; 84 return;
82 } 85 }
83 if (!::Process32First(snapshot, &process_entry)) { 86 if (!::Process32First(snapshot, &process_entry)) {
84 LOG(ERROR) << "Process32First failed: " << GetLastError(); 87 LOG(ERROR) << "Process32First failed: " << GetLastError();
85 return; 88 return;
86 } 89 }
87 do { 90 do {
88 base::ProcessId pid = process_entry.th32ProcessID; 91 base::ProcessId pid = process_entry.th32ProcessID;
89 ScopedHandle handle(::OpenProcess( 92 base::win::ScopedHandle handle(::OpenProcess(
90 PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)); 93 PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid));
91 if (!handle.Get()) 94 if (!handle.Get())
92 continue; 95 continue;
93 bool is_64bit_process = false; 96 bool is_64bit_process = false;
94 // IsWow64Process() returns FALSE for a 32bit process on a 32bit OS. 97 // IsWow64Process() returns FALSE for a 32bit process on a 32bit OS.
95 // We need to check if the real OS is 64bit. 98 // We need to check if the real OS is 64bit.
96 if (is_64bit_os) { 99 if (is_64bit_os) {
97 BOOL is_wow64 = FALSE; 100 BOOL is_wow64 = FALSE;
98 // IsWow64Process() is supported by Windows XP SP2 or later. 101 // IsWow64Process() is supported by Windows XP SP2 or later.
99 IsWow64Process(handle, &is_wow64); 102 IsWow64Process(handle, &is_wow64);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 155 }
153 break; 156 break;
154 } 157 }
155 } while (::Process32Next(snapshot, &process_entry)); 158 } while (::Process32Next(snapshot, &process_entry));
156 159
157 // Finally return to the browser thread. 160 // Finally return to the browser thread.
158 BrowserThread::PostTask( 161 BrowserThread::PostTask(
159 BrowserThread::UI, FROM_HERE, 162 BrowserThread::UI, FROM_HERE,
160 NewRunnableMethod(this, &MemoryDetails::CollectChildInfoOnUIThread)); 163 NewRunnableMethod(this, &MemoryDetails::CollectChildInfoOnUIThread));
161 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698