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

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

Issue 1874483002: Remove "from all browsers" memory details mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rip out ProcessInfoSnapshot 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
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 "chrome/browser/memory_details.h" 5 #include "chrome/browser/memory_details.h"
6 6
7 #include <psapi.h> 7 #include <psapi.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <TlHelp32.h> 9 #include <TlHelp32.h>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 process.process_name = process_template[index].process_name; 66 process.process_name = process_template[index].process_name;
67 process_data_.push_back(process); 67 process_data_.push_back(process);
68 } 68 }
69 } 69 }
70 70
71 ProcessData* MemoryDetails::ChromeBrowser() { 71 ProcessData* MemoryDetails::ChromeBrowser() {
72 return &process_data_[CHROME_BROWSER]; 72 return &process_data_[CHROME_BROWSER];
73 } 73 }
74 74
75 void MemoryDetails::CollectProcessData( 75 void MemoryDetails::CollectProcessData(
76 CollectionMode mode,
77 const std::vector<ProcessMemoryInformation>& child_info) { 76 const std::vector<ProcessMemoryInformation>& child_info) {
78 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 77 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
79 78
80 // Clear old data. 79 // Clear old data.
81 for (unsigned int index = 0; index < process_data_.size(); index++) 80 for (unsigned int index = 0; index < process_data_.size(); index++)
82 process_data_[index].processes.clear(); 81 process_data_[index].processes.clear();
83 82
84 base::win::OSInfo::WindowsArchitecture windows_architecture = 83 base::win::OSInfo::WindowsArchitecture windows_architecture =
85 base::win::OSInfo::GetInstance()->architecture(); 84 base::win::OSInfo::GetInstance()->architecture();
86 85
(...skipping 12 matching lines...) Expand all
99 base::ProcessId pid = process_entry.th32ProcessID; 98 base::ProcessId pid = process_entry.th32ProcessID;
100 base::win::ScopedHandle process_handle(::OpenProcess( 99 base::win::ScopedHandle process_handle(::OpenProcess(
101 PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)); 100 PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid));
102 if (!process_handle.IsValid()) 101 if (!process_handle.IsValid())
103 continue; 102 continue;
104 bool is_64bit_process = 103 bool is_64bit_process =
105 ((windows_architecture == base::win::OSInfo::X64_ARCHITECTURE) || 104 ((windows_architecture == base::win::OSInfo::X64_ARCHITECTURE) ||
106 (windows_architecture == base::win::OSInfo::IA64_ARCHITECTURE)) && 105 (windows_architecture == base::win::OSInfo::IA64_ARCHITECTURE)) &&
107 (base::win::OSInfo::GetWOW64StatusForProcess(process_handle.Get()) == 106 (base::win::OSInfo::GetWOW64StatusForProcess(process_handle.Get()) ==
108 base::win::OSInfo::WOW64_DISABLED); 107 base::win::OSInfo::WOW64_DISABLED);
109 const size_t browser_list_size = 108 const size_t browser_list_size = 1;
110 (mode == FROM_CHROME_ONLY ? 1 : process_data_.size());
111 for (size_t index2 = 0; index2 < browser_list_size; ++index2) { 109 for (size_t index2 = 0; index2 < browser_list_size; ++index2) {
Nico 2016/04/08 19:47:44 this loop now always runs exactly once
Elly Fong-Jones 2016/04/13 17:18:24 I'm scared of this code and it has no tests that I
112 if (_wcsicmp(process_data_[index2].process_name.c_str(), 110 if (_wcsicmp(process_data_[index2].process_name.c_str(),
113 process_entry.szExeFile) != 0) 111 process_entry.szExeFile) != 0)
114 continue; 112 continue;
115 if (index2 == IE_BROWSER && is_64bit_process) 113 if (index2 == IE_BROWSER && is_64bit_process)
116 continue; // Should use IE_64BIT_BROWSER 114 continue; // Should use IE_64BIT_BROWSER
117 // Get Memory Information. 115 // Get Memory Information.
118 ProcessMemoryInformation info; 116 ProcessMemoryInformation info;
119 info.pid = pid; 117 info.pid = pid;
120 if (info.pid == GetCurrentProcessId()) 118 if (info.pid == GetCurrentProcessId())
121 info.process_type = content::PROCESS_TYPE_BROWSER; 119 info.process_type = content::PROCESS_TYPE_BROWSER;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 159 }
162 break; 160 break;
163 } 161 }
164 } while (::Process32Next(snapshot.Get(), &process_entry)); 162 } while (::Process32Next(snapshot.Get(), &process_entry));
165 163
166 // Finally return to the browser thread. 164 // Finally return to the browser thread.
167 BrowserThread::PostTask( 165 BrowserThread::PostTask(
168 BrowserThread::UI, FROM_HERE, 166 BrowserThread::UI, FROM_HERE,
169 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); 167 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this));
170 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698