OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |