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

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: Make changes requested by danakj, fix a few more headers Created 4 years 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 <utility>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
9 #include "base/metrics/histogram_base.h" 11 #include "base/metrics/histogram_base.h"
10 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
11 #include "base/metrics/persistent_histogram_allocator.h" 13 #include "base/metrics/persistent_histogram_allocator.h"
12 #include "base/metrics/persistent_memory_allocator.h" 14 #include "base/metrics/persistent_memory_allocator.h"
13 #include "components/metrics/metrics_service.h" 15 #include "components/metrics/metrics_service.h"
14 #include "content/public/browser/browser_child_process_host.h" 16 #include "content/public/browser/browser_child_process_host.h"
15 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/child_process_data.h" 18 #include "content/public/browser/child_process_data.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 DCHECK(thread_checker_.CalledOnValidThread()); 54 DCHECK(thread_checker_.CalledOnValidThread());
53 DCHECK(!allocators_by_id_.Lookup(id)); 55 DCHECK(!allocators_by_id_.Lookup(id));
54 56
55 // Stop now if this was called without an allocator, typically because 57 // Stop now if this was called without an allocator, typically because
56 // GetSubprocessHistogramAllocatorOnIOThread exited early and returned 58 // GetSubprocessHistogramAllocatorOnIOThread exited early and returned
57 // null. 59 // null.
58 if (!allocator) 60 if (!allocator)
59 return; 61 return;
60 62
61 // Map is "MapOwnPointer" so transfer ownership to it. 63 // Map is "MapOwnPointer" so transfer ownership to it.
62 allocators_by_id_.AddWithID(allocator.release(), id); 64 allocators_by_id_.AddWithID(std::move(allocator), id);
63 } 65 }
64 66
65 void SubprocessMetricsProvider::DeregisterSubprocessAllocator(int id) { 67 void SubprocessMetricsProvider::DeregisterSubprocessAllocator(int id) {
66 DCHECK(thread_checker_.CalledOnValidThread()); 68 DCHECK(thread_checker_.CalledOnValidThread());
67 69
68 if (!allocators_by_id_.Lookup(id)) 70 if (!allocators_by_id_.Lookup(id))
69 return; 71 return;
70 72
71 // Extract the matching allocator from the list of active ones. It will 73 // Extract the matching allocator from the list of active ones. It will
72 // be automatically released when this method exits. 74 // be automatically released when this method exits.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return nullptr; 215 return nullptr;
214 216
215 std::unique_ptr<base::SharedPersistentMemoryAllocator> allocator = 217 std::unique_ptr<base::SharedPersistentMemoryAllocator> allocator =
216 host->TakeMetricsAllocator(); 218 host->TakeMetricsAllocator();
217 if (!allocator) 219 if (!allocator)
218 return nullptr; 220 return nullptr;
219 221
220 return base::MakeUnique<base::PersistentHistogramAllocator>( 222 return base::MakeUnique<base::PersistentHistogramAllocator>(
221 std::move(allocator)); 223 std::move(allocator));
222 } 224 }
OLDNEW
« no previous file with comments | « chrome/browser/media/cast_transport_host_filter.cc ('k') | chrome/browser/permissions/permission_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698