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

Side by Side Diff: base/process_util_win.cc

Issue 100111: Support for showing memory usage of 64-bit IE in a 32-bit Chromium ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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
« no previous file with comments | « no previous file | chrome/browser/memory_details.h » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <windows.h> 7 #include <windows.h>
8 #include <winternl.h> 8 #include <winternl.h>
9 #include <psapi.h> 9 #include <psapi.h>
10 10
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 513 }
514 return 0; 514 return 0;
515 } 515 }
516 516
517 void ProcessMetrics::GetCommittedKBytes(CommittedKBytes* usage) const { 517 void ProcessMetrics::GetCommittedKBytes(CommittedKBytes* usage) const {
518 MEMORY_BASIC_INFORMATION mbi = {0}; 518 MEMORY_BASIC_INFORMATION mbi = {0};
519 size_t committed_private = 0; 519 size_t committed_private = 0;
520 size_t committed_mapped = 0; 520 size_t committed_mapped = 0;
521 size_t committed_image = 0; 521 size_t committed_image = 0;
522 void* base_address = NULL; 522 void* base_address = NULL;
523 while (VirtualQueryEx(process_, base_address, &mbi, 523 while (VirtualQueryEx(process_, base_address, &mbi, sizeof(mbi)) ==
524 sizeof(MEMORY_BASIC_INFORMATION)) == 524 sizeof(mbi)) {
525 sizeof(MEMORY_BASIC_INFORMATION)) { 525 if (mbi.State == MEM_COMMIT) {
526 if (mbi.State == MEM_COMMIT) { 526 if (mbi.Type == MEM_PRIVATE) {
527 if (mbi.Type == MEM_PRIVATE) { 527 committed_private += mbi.RegionSize;
528 committed_private += mbi.RegionSize; 528 } else if (mbi.Type == MEM_MAPPED) {
529 } else if (mbi.Type == MEM_MAPPED) { 529 committed_mapped += mbi.RegionSize;
530 committed_mapped += mbi.RegionSize; 530 } else if (mbi.Type == MEM_IMAGE) {
531 } else if (mbi.Type == MEM_IMAGE) { 531 committed_image += mbi.RegionSize;
532 committed_image += mbi.RegionSize; 532 } else {
533 } else { 533 NOTREACHED();
534 NOTREACHED();
535 }
536 } 534 }
537 base_address = (static_cast<BYTE*>(mbi.BaseAddress)) + mbi.RegionSize; 535 }
536 void* new_base = (static_cast<BYTE*>(mbi.BaseAddress)) + mbi.RegionSize;
537 // Avoid infinite loop by weird MEMORY_BASIC_INFORMATION.
538 // If we query 64bit processes in a 32bit process, VirtualQueryEx()
539 // returns such data.
540 if (new_base <= base_address) {
541 usage->image = 0;
542 usage->mapped = 0;
543 usage->priv = 0;
544 return;
545 }
546 base_address = new_base;
538 } 547 }
539 usage->image = committed_image / 1024; 548 usage->image = committed_image / 1024;
540 usage->mapped = committed_mapped / 1024; 549 usage->mapped = committed_mapped / 1024;
541 usage->priv = committed_private / 1024; 550 usage->priv = committed_private / 1024;
542 } 551 }
543 552
544 bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { 553 bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
545 size_t ws_private = 0; 554 size_t ws_private = 0;
546 size_t ws_shareable = 0; 555 size_t ws_shareable = 0;
547 size_t ws_shared = 0; 556 size_t ws_shared = 0;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 void EnableTerminationOnHeapCorruption() { 737 void EnableTerminationOnHeapCorruption() {
729 // Ignore the result code. Supported on XP SP3 and Vista. 738 // Ignore the result code. Supported on XP SP3 and Vista.
730 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); 739 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
731 } 740 }
732 741
733 void RaiseProcessToHighPriority() { 742 void RaiseProcessToHighPriority() {
734 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 743 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
735 } 744 }
736 745
737 } // namespace base 746 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/memory_details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698