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

Side by Side Diff: base/trace_event/winheap_dump_provider_win.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 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
« no previous file with comments | « base/trace_event/trace_log.cc ('k') | base/tracked_objects_unittest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/trace_event/winheap_dump_provider_win.h" 5 #include "base/trace_event/winheap_dump_provider_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/debug/profiler.h" 9 #include "base/debug/profiler.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 // Retrieves the number of heaps in the current process. 74 // Retrieves the number of heaps in the current process.
75 DWORD number_of_heaps = ::GetProcessHeaps(0, NULL); 75 DWORD number_of_heaps = ::GetProcessHeaps(0, NULL);
76 WinHeapInfo all_heap_info = {0}; 76 WinHeapInfo all_heap_info = {0};
77 77
78 // Try to retrieve a handle to all the heaps owned by this process. Returns 78 // Try to retrieve a handle to all the heaps owned by this process. Returns
79 // false if the number of heaps has changed. 79 // false if the number of heaps has changed.
80 // 80 //
81 // This is inherently racy as is, but it's not something that we observe a lot 81 // This is inherently racy as is, but it's not something that we observe a lot
82 // in Chrome, the heaps tend to be created at startup only. 82 // in Chrome, the heaps tend to be created at startup only.
83 scoped_ptr<HANDLE[]> all_heaps(new HANDLE[number_of_heaps]); 83 std::unique_ptr<HANDLE[]> all_heaps(new HANDLE[number_of_heaps]);
84 if (::GetProcessHeaps(number_of_heaps, all_heaps.get()) != number_of_heaps) 84 if (::GetProcessHeaps(number_of_heaps, all_heaps.get()) != number_of_heaps)
85 return false; 85 return false;
86 86
87 // Skip the pointer to the heap array to avoid accounting the memory used by 87 // Skip the pointer to the heap array to avoid accounting the memory used by
88 // this dump provider. 88 // this dump provider.
89 std::set<void*> block_to_skip; 89 std::set<void*> block_to_skip;
90 block_to_skip.insert(all_heaps.get()); 90 block_to_skip.insert(all_heaps.get());
91 91
92 // Retrieves some metrics about each heap. 92 // Retrieves some metrics about each heap.
93 for (size_t i = 0; i < number_of_heaps; ++i) { 93 for (size_t i = 0; i < number_of_heaps; ++i) {
(...skipping 26 matching lines...) Expand all
120 } else if ((heap_entry.wFlags & PROCESS_HEAP_REGION) != 0) { 120 } else if ((heap_entry.wFlags & PROCESS_HEAP_REGION) != 0) {
121 heap_info->committed_size += heap_entry.Region.dwCommittedSize; 121 heap_info->committed_size += heap_entry.Region.dwCommittedSize;
122 } 122 }
123 } 123 }
124 CHECK(::HeapUnlock(heap_info->heap_id) == TRUE); 124 CHECK(::HeapUnlock(heap_info->heap_id) == TRUE);
125 return true; 125 return true;
126 } 126 }
127 127
128 } // namespace trace_event 128 } // namespace trace_event
129 } // namespace base 129 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_log.cc ('k') | base/tracked_objects_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698