OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // | 139 // |
140 void MemoryDetails::StartFetch() { | 140 void MemoryDetails::StartFetch() { |
141 // This might get called from the UI or FILE threads, but should not be | 141 // This might get called from the UI or FILE threads, but should not be |
142 // getting called from the IO thread. | 142 // getting called from the IO thread. |
143 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); | 143 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); |
144 | 144 |
145 // In order to process this request, we need to use the plugin information. | 145 // In order to process this request, we need to use the plugin information. |
146 // However, plugin process information is only available from the IO thread. | 146 // However, plugin process information is only available from the IO thread. |
147 BrowserThread::PostTask( | 147 BrowserThread::PostTask( |
148 BrowserThread::IO, FROM_HERE, | 148 BrowserThread::IO, FROM_HERE, |
149 base::Bind(&MemoryDetails::CollectChildInfoOnIOThread, this)); | 149 base::BindOnce(&MemoryDetails::CollectChildInfoOnIOThread, this)); |
150 } | 150 } |
151 | 151 |
152 MemoryDetails::~MemoryDetails() {} | 152 MemoryDetails::~MemoryDetails() {} |
153 | 153 |
154 std::string MemoryDetails::ToLogString() { | 154 std::string MemoryDetails::ToLogString() { |
155 std::string log; | 155 std::string log; |
156 log.reserve(4096); | 156 log.reserve(4096); |
157 ProcessMemoryInformationList processes = ChromeBrowser()->processes; | 157 ProcessMemoryInformationList processes = ChromeBrowser()->processes; |
158 // Sort by memory consumption, low to high. | 158 // Sort by memory consumption, low to high. |
159 std::sort(processes.begin(), processes.end()); | 159 std::sort(processes.begin(), processes.end()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 info.process_type = iter.GetData().process_type; | 209 info.process_type = iter.GetData().process_type; |
210 info.renderer_type = ProcessMemoryInformation::RENDERER_UNKNOWN; | 210 info.renderer_type = ProcessMemoryInformation::RENDERER_UNKNOWN; |
211 info.titles.push_back(iter.GetData().name); | 211 info.titles.push_back(iter.GetData().name); |
212 child_info.push_back(info); | 212 child_info.push_back(info); |
213 } | 213 } |
214 | 214 |
215 // Now go do expensive memory lookups on the blocking pool. | 215 // Now go do expensive memory lookups on the blocking pool. |
216 BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior( | 216 BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior( |
217 FROM_HERE, | 217 FROM_HERE, |
218 base::Bind(&MemoryDetails::CollectProcessData, this, child_info), | 218 base::BindOnce(&MemoryDetails::CollectProcessData, this, child_info), |
219 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 219 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
220 } | 220 } |
221 | 221 |
222 void MemoryDetails::CollectChildInfoOnUIThread() { | 222 void MemoryDetails::CollectChildInfoOnUIThread() { |
223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
224 ProcessData* const chrome_browser = ChromeBrowser(); | 224 ProcessData* const chrome_browser = ChromeBrowser(); |
225 | 225 |
226 // First pass, collate the widgets by process ID. | 226 // First pass, collate the widgets by process ID. |
227 std::map<base::ProcessId, std::vector<RenderWidgetHost*>> widgets_by_pid; | 227 std::map<base::ProcessId, std::vector<RenderWidgetHost*>> widgets_by_pid; |
228 std::unique_ptr<content::RenderWidgetHostIterator> widget_it( | 228 std::unique_ptr<content::RenderWidgetHostIterator> widget_it( |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // Get rid of other Chrome processes that are from a different profile. | 353 // Get rid of other Chrome processes that are from a different profile. |
354 auto is_unknown = [](ProcessMemoryInformation& process) { | 354 auto is_unknown = [](ProcessMemoryInformation& process) { |
355 return process.process_type == content::PROCESS_TYPE_UNKNOWN; | 355 return process.process_type == content::PROCESS_TYPE_UNKNOWN; |
356 }; | 356 }; |
357 auto& vector = chrome_browser->processes; | 357 auto& vector = chrome_browser->processes; |
358 vector.erase(std::remove_if(vector.begin(), vector.end(), is_unknown), | 358 vector.erase(std::remove_if(vector.begin(), vector.end(), is_unknown), |
359 vector.end()); | 359 vector.end()); |
360 | 360 |
361 OnDetailsAvailable(); | 361 OnDetailsAvailable(); |
362 } | 362 } |
OLD | NEW |