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

Side by Side Diff: chrome/browser/metrics/subprocess_metrics_provider.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Fix typo breaking a bunch of trybot builds, oops Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/metrics/subprocess_metrics_provider.h" 5 #include "chrome/browser/metrics/subprocess_metrics_provider.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/metrics/histogram_base.h" 9 #include "base/metrics/histogram_base.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 DCHECK(thread_checker_.CalledOnValidThread()); 52 DCHECK(thread_checker_.CalledOnValidThread());
53 DCHECK(!allocators_by_id_.Lookup(id)); 53 DCHECK(!allocators_by_id_.Lookup(id));
54 54
55 // Stop now if this was called without an allocator, typically because 55 // Stop now if this was called without an allocator, typically because
56 // GetSubprocessHistogramAllocatorOnIOThread exited early and returned 56 // GetSubprocessHistogramAllocatorOnIOThread exited early and returned
57 // null. 57 // null.
58 if (!allocator) 58 if (!allocator)
59 return; 59 return;
60 60
61 // Map is "MapOwnPointer" so transfer ownership to it. 61 // Map is "MapOwnPointer" so transfer ownership to it.
62 allocators_by_id_.AddWithID(allocator.release(), id); 62 allocators_by_id_.AddWithID(std::move(allocator), id);
63 } 63 }
64 64
65 void SubprocessMetricsProvider::DeregisterSubprocessAllocator(int id) { 65 void SubprocessMetricsProvider::DeregisterSubprocessAllocator(int id) {
66 DCHECK(thread_checker_.CalledOnValidThread()); 66 DCHECK(thread_checker_.CalledOnValidThread());
67 67
68 if (!allocators_by_id_.Lookup(id)) 68 if (!allocators_by_id_.Lookup(id))
69 return; 69 return;
70 70
71 // Extract the matching allocator from the list of active ones. It will 71 // Extract the matching allocator from the list of active ones. It will
72 // be automatically released when this method exits. 72 // be automatically released when this method exits.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return nullptr; 213 return nullptr;
214 214
215 std::unique_ptr<base::SharedPersistentMemoryAllocator> allocator = 215 std::unique_ptr<base::SharedPersistentMemoryAllocator> allocator =
216 host->TakeMetricsAllocator(); 216 host->TakeMetricsAllocator();
217 if (!allocator) 217 if (!allocator)
218 return nullptr; 218 return nullptr;
219 219
220 return base::MakeUnique<base::PersistentHistogramAllocator>( 220 return base::MakeUnique<base::PersistentHistogramAllocator>(
221 std::move(allocator)); 221 std::move(allocator));
222 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698