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

Side by Side Diff: base/metrics/persistent_histogram_allocator.cc

Issue 2973863002: Remove std::string histogram name from HistogramBase object.
Patch Set: never rely on outside string permanence Created 3 years, 5 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
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 "base/metrics/persistent_histogram_allocator.h" 5 #include "base/metrics/persistent_histogram_allocator.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/atomicops.h" 9 #include "base/atomicops.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 // A second delayed allocations is defined using the same reference storage 633 // A second delayed allocations is defined using the same reference storage
634 // location as the first so the allocation of one will automatically be found 634 // location as the first so the allocation of one will automatically be found
635 // by the other. Within the block, the first half of the space is for "counts" 635 // by the other. Within the block, the first half of the space is for "counts"
636 // and the second half is for "logged counts". 636 // and the second half is for "logged counts".
637 DelayedPersistentAllocation logged_data( 637 DelayedPersistentAllocation logged_data(
638 memory_allocator_.get(), &histogram_data_ptr->counts_ref, 638 memory_allocator_.get(), &histogram_data_ptr->counts_ref,
639 kTypeIdCountsArray, counts_bytes, counts_bytes / 2, 639 kTypeIdCountsArray, counts_bytes, counts_bytes / 2,
640 /*make_iterable=*/false); 640 /*make_iterable=*/false);
641 641
642 // Create the right type of histogram. 642 // Create the right type of histogram.
643 std::string name(histogram_data_ptr->name); 643 const char* name = histogram_data_ptr->name;
644 std::unique_ptr<HistogramBase> histogram; 644 std::unique_ptr<HistogramBase> histogram;
645 switch (histogram_type) { 645 switch (histogram_type) {
646 case HISTOGRAM: 646 case HISTOGRAM:
647 histogram = Histogram::PersistentCreate( 647 histogram = Histogram::PersistentCreate(
648 name, histogram_minimum, histogram_maximum, ranges, counts_data, 648 name, histogram_minimum, histogram_maximum, ranges, counts_data,
649 logged_data, &histogram_data_ptr->samples_metadata, 649 logged_data, &histogram_data_ptr->samples_metadata,
650 &histogram_data_ptr->logged_metadata); 650 &histogram_data_ptr->logged_metadata);
651 DCHECK(histogram); 651 DCHECK(histogram);
652 break; 652 break;
653 case LINEAR_HISTOGRAM: 653 case LINEAR_HISTOGRAM:
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 } 1047 }
1048 1048
1049 // static 1049 // static
1050 FilePath GlobalHistogramAllocator::MakeMetricsFilePath(const FilePath& dir, 1050 FilePath GlobalHistogramAllocator::MakeMetricsFilePath(const FilePath& dir,
1051 StringPiece name) { 1051 StringPiece name) {
1052 return dir.AppendASCII(name).AddExtension( 1052 return dir.AppendASCII(name).AddExtension(
1053 PersistentMemoryAllocator::kFileExtension); 1053 PersistentMemoryAllocator::kFileExtension);
1054 } 1054 }
1055 1055
1056 } // namespace base 1056 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698