Commit b7c35726 authored by Xi Cheng's avatar Xi Cheng Committed by Commit Bot

Introduce notification_helper_constants.* to improve code consistency

Bug: 734095
Change-Id: Idf5637bb57a7cbfb0b5831cf99e45806d8a9abc6
Reviewed-on: https://chromium-review.googlesource.com/1026972Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Xi Cheng <chengx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553451}
parent 708062c2
...@@ -2925,6 +2925,7 @@ jumbo_split_static_library("browser") { ...@@ -2925,6 +2925,7 @@ jumbo_split_static_library("browser") {
"//chrome/common:metrics_constants_util_win", "//chrome/common:metrics_constants_util_win",
"//chrome/common:version_header", "//chrome/common:version_header",
"//chrome/install_static:install_static_util", "//chrome/install_static:install_static_util",
"//chrome/notification_helper:constants",
"//chrome/services/util_win/public/mojom", "//chrome/services/util_win/public/mojom",
"//chrome_elf:blacklist", "//chrome_elf:blacklist",
"//chrome_elf:constants", "//chrome_elf:constants",
......
...@@ -6,6 +6,7 @@ include_rules = [ ...@@ -6,6 +6,7 @@ include_rules = [
"+chrome/grit", "+chrome/grit",
"+chrome/install_static", "+chrome/install_static",
"+chrome/installer/util", "+chrome/installer/util",
"+chrome/notification_helper/notification_helper_constants.h",
"+chrome/services/file_util/public", "+chrome/services/file_util/public",
"+chrome/services/media_gallery_util/public", "+chrome/services/media_gallery_util/public",
"+chrome/services/printing/public", "+chrome/services/printing/public",
......
...@@ -134,6 +134,7 @@ ...@@ -134,6 +134,7 @@
#include "chrome/browser/metrics/google_update_metrics_provider_win.h" #include "chrome/browser/metrics/google_update_metrics_provider_win.h"
#include "chrome/common/metrics_constants_util_win.h" #include "chrome/common/metrics_constants_util_win.h"
#include "chrome/install_static/install_util.h" #include "chrome/install_static/install_util.h"
#include "chrome/notification_helper/notification_helper_constants.h"
#include "components/browser_watcher/watcher_metrics_provider_win.h" #include "components/browser_watcher/watcher_metrics_provider_win.h"
#endif #endif
...@@ -166,13 +167,6 @@ const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds. ...@@ -166,13 +167,6 @@ const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds.
// third_party/crashpad/crashpad/handler/handler_main.cc. // third_party/crashpad/crashpad/handler/handler_main.cc.
const char kCrashpadHistogramAllocatorName[] = "CrashpadMetrics"; const char kCrashpadHistogramAllocatorName[] = "CrashpadMetrics";
#if defined(OS_WIN)
// Must be kept in sync with the allocator name in
// notification_helper/notification_helper.cc.
constexpr char kNotificationHelperHistogramAllocatorName[] =
"NotificationHelperMetrics";
#endif
#if defined(OS_WIN) || defined(OS_MACOSX) #if defined(OS_WIN) || defined(OS_MACOSX)
// The stream type assigned to the minidump stream that holds the serialized // The stream type assigned to the minidump stream that holds the serialized
// system profile proto. // system profile proto.
...@@ -198,7 +192,7 @@ void RegisterFileMetricsPreferences(PrefRegistrySimple* registry) { ...@@ -198,7 +192,7 @@ void RegisterFileMetricsPreferences(PrefRegistrySimple* registry) {
registry, installer::kSetupHistogramAllocatorName); registry, installer::kSetupHistogramAllocatorName);
metrics::FileMetricsProvider::RegisterPrefs( metrics::FileMetricsProvider::RegisterPrefs(
registry, kNotificationHelperHistogramAllocatorName); registry, notification_helper::kNotificationHelperHistogramAllocatorName);
#endif #endif
} }
...@@ -306,7 +300,8 @@ std::unique_ptr<metrics::FileMetricsProvider> CreateFileMetricsProvider( ...@@ -306,7 +300,8 @@ std::unique_ptr<metrics::FileMetricsProvider> CreateFileMetricsProvider(
// potential duplicate code. // potential duplicate code.
if (!user_data_dir.empty()) { if (!user_data_dir.empty()) {
base::FilePath notification_helper_metrics_upload_dir = base::FilePath notification_helper_metrics_upload_dir =
user_data_dir.AppendASCII(kNotificationHelperHistogramAllocatorName); user_data_dir.AppendASCII(
notification_helper::kNotificationHelperHistogramAllocatorName);
if (metrics_reporting_enabled) { if (metrics_reporting_enabled) {
file_metrics_provider->RegisterSource( file_metrics_provider->RegisterSource(
...@@ -314,7 +309,7 @@ std::unique_ptr<metrics::FileMetricsProvider> CreateFileMetricsProvider( ...@@ -314,7 +309,7 @@ std::unique_ptr<metrics::FileMetricsProvider> CreateFileMetricsProvider(
notification_helper_metrics_upload_dir, notification_helper_metrics_upload_dir,
metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_DIR, metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_DIR,
metrics::FileMetricsProvider::ASSOCIATE_CURRENT_RUN, metrics::FileMetricsProvider::ASSOCIATE_CURRENT_RUN,
kNotificationHelperHistogramAllocatorName)); notification_helper::kNotificationHelperHistogramAllocatorName));
} else { } else {
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, FROM_HERE,
......
...@@ -18,6 +18,7 @@ executable("notification_helper") { ...@@ -18,6 +18,7 @@ executable("notification_helper") {
configs += [ "//build/config/win:windowed" ] configs += [ "//build/config/win:windowed" ]
deps = [ deps = [
":constants",
":lib", ":lib",
":version_resources", ":version_resources",
"//base", "//base",
...@@ -52,6 +53,13 @@ source_set("lib") { ...@@ -52,6 +53,13 @@ source_set("lib") {
] ]
} }
source_set("constants") {
sources = [
"notification_helper_constants.cc",
"notification_helper_constants.h",
]
}
process_version_rc_template("version_resources") { process_version_rc_template("version_resources") {
sources = [ sources = [
"notification_helper_exe.ver", "notification_helper_exe.ver",
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "chrome/install_static/product_install_details.h" #include "chrome/install_static/product_install_details.h"
#include "chrome/install_static/user_data_dir.h" #include "chrome/install_static/user_data_dir.h"
#include "chrome/notification_helper/com_server_module.h" #include "chrome/notification_helper/com_server_module.h"
#include "chrome/notification_helper/notification_helper_constants.h"
#include "chrome/notification_helper/notification_helper_crash_reporter_client.h" #include "chrome/notification_helper/notification_helper_crash_reporter_client.h"
#include "chrome/notification_helper/notification_helper_util.h" #include "chrome/notification_helper/notification_helper_util.h"
#include "chrome/notification_helper/trace_util.h" #include "chrome/notification_helper/trace_util.h"
...@@ -25,10 +26,8 @@ extern "C" int WINAPI wWinMain(HINSTANCE instance, ...@@ -25,10 +26,8 @@ extern "C" int WINAPI wWinMain(HINSTANCE instance,
wchar_t* command_line, wchar_t* command_line,
int show_command) { int show_command) {
// Persist histograms so they can be uploaded later. // Persist histograms so they can be uploaded later.
// The allocator name must be kept in sync with the writer in
// chrome/browser/metrics/chrome_metrics_service_client.cc.
base::PersistentHistogramStorage persistent_histogram_storage( base::PersistentHistogramStorage persistent_histogram_storage(
"NotificationHelperMetrics", notification_helper::kNotificationHelperHistogramAllocatorName,
base::PersistentHistogramStorage::StorageDirManagement::kCreate); base::PersistentHistogramStorage::StorageDirManagement::kCreate);
// Initialize the CommandLine singleton from the environment. // Initialize the CommandLine singleton from the environment.
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/notification_helper/notification_helper_constants.h"
namespace notification_helper {
const char kNotificationHelperHistogramAllocatorName[] =
"NotificationHelperMetrics";
} // namespace notification_helper
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_NOTIFICATION_HELPER_NOTIFICATION_HELPER_CONSTANTS_H_
#define CHROME_NOTIFICATION_HELPER_NOTIFICATION_HELPER_CONSTANTS_H_
namespace notification_helper {
extern const char kNotificationHelperHistogramAllocatorName[];
} // namespace notification_helper
#endif // CHROME_NOTIFICATION_HELPER_NOTIFICATION_HELPER_CONSTANTS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment