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

Side by Side Diff: components/metrics/call_stack_profile_metrics_provider.cc

Issue 1476633003: Move HashMetricName to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed unittest Created 5 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
« no previous file with comments | « components/metrics/BUILD.gn ('k') | components/metrics/cloned_install_detector.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 "components/metrics/call_stack_profile_metrics_provider.h" 5 #include "components/metrics/call_stack_profile_metrics_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
18 #include "base/metrics/field_trial.h" 18 #include "base/metrics/field_trial.h"
19 #include "base/metrics/metrics_hashes.h"
19 #include "base/profiler/stack_sampling_profiler.h" 20 #include "base/profiler/stack_sampling_profiler.h"
20 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
21 #include "base/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
22 #include "base/thread_task_runner_handle.h" 23 #include "base/thread_task_runner_handle.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "components/metrics/metrics_hashes.h"
25 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" 25 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
26 26
27 using base::StackSamplingProfiler; 27 using base::StackSamplingProfiler;
28 28
29 namespace metrics { 29 namespace metrics {
30 30
31 namespace { 31 namespace {
32 32
33 // ProfilesState -------------------------------------------------------------- 33 // ProfilesState --------------------------------------------------------------
34 34
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // Functions to encode protobufs ---------------------------------------------- 201 // Functions to encode protobufs ----------------------------------------------
202 202
203 // The protobuf expects the MD5 checksum prefix of the module name. 203 // The protobuf expects the MD5 checksum prefix of the module name.
204 uint64 HashModuleFilename(const base::FilePath& filename) { 204 uint64 HashModuleFilename(const base::FilePath& filename) {
205 const base::FilePath::StringType basename = filename.BaseName().value(); 205 const base::FilePath::StringType basename = filename.BaseName().value();
206 // Copy the bytes in basename into a string buffer. 206 // Copy the bytes in basename into a string buffer.
207 size_t basename_length_in_bytes = 207 size_t basename_length_in_bytes =
208 basename.size() * sizeof(base::FilePath::CharType); 208 basename.size() * sizeof(base::FilePath::CharType);
209 std::string name_bytes(basename_length_in_bytes, '\0'); 209 std::string name_bytes(basename_length_in_bytes, '\0');
210 memcpy(&name_bytes[0], &basename[0], basename_length_in_bytes); 210 memcpy(&name_bytes[0], &basename[0], basename_length_in_bytes);
211 return HashMetricName(name_bytes); 211 return base::HashMetricName(name_bytes);
212 } 212 }
213 213
214 // Transcode |sample| into |proto_sample|, using base addresses in |modules| to 214 // Transcode |sample| into |proto_sample|, using base addresses in |modules| to
215 // compute module instruction pointer offsets. 215 // compute module instruction pointer offsets.
216 void CopySampleToProto( 216 void CopySampleToProto(
217 const StackSamplingProfiler::Sample& sample, 217 const StackSamplingProfiler::Sample& sample,
218 const std::vector<StackSamplingProfiler::Module>& modules, 218 const std::vector<StackSamplingProfiler::Module>& modules,
219 CallStackProfile::Sample* proto_sample) { 219 CallStackProfile::Sample* proto_sample) {
220 for (const StackSamplingProfiler::Frame& frame : sample) { 220 for (const StackSamplingProfiler::Frame& frame : sample) {
221 CallStackProfile::Entry* entry = proto_sample->add_entry(); 221 CallStackProfile::Entry* entry = proto_sample->add_entry();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 // static 385 // static
386 bool CallStackProfileMetricsProvider::IsReportingEnabledByFieldTrial() { 386 bool CallStackProfileMetricsProvider::IsReportingEnabledByFieldTrial() {
387 const std::string group_name = base::FieldTrialList::FindFullName( 387 const std::string group_name = base::FieldTrialList::FindFullName(
388 CallStackProfileMetricsProvider::kFieldTrialName); 388 CallStackProfileMetricsProvider::kFieldTrialName);
389 return group_name == 389 return group_name ==
390 CallStackProfileMetricsProvider::kReportProfilesGroupName; 390 CallStackProfileMetricsProvider::kReportProfilesGroupName;
391 } 391 }
392 392
393 } // namespace metrics 393 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/BUILD.gn ('k') | components/metrics/cloned_install_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698