summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 13:49:39 +0000
committerblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 13:49:39 +0000
commit66d176ad38d72eabc969893b2b09ad6759109836 (patch)
treeb49f61dcb41744b0fab09f0a7893dd84e940d1f8
parent5a23d6986317ab9018521c3eaa87957a214d189d (diff)
downloadchromium_src-66d176ad38d72eabc969893b2b09ad6759109836.zip
chromium_src-66d176ad38d72eabc969893b2b09ad6759109836.tar.gz
chromium_src-66d176ad38d72eabc969893b2b09ad6759109836.tar.bz2
Move ClonedInstallDetector and MachineIdProvider into the metrics component
cloned_install_detector_unittest is left in //chrome at the current time as it still has //chrome-level dependencies. BUG=374212 R=isherman@chromium.org TBR=thakis Review URL: https://codereview.chromium.org/290033003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272172 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/metrics/cloned_install_detector_unittest.cc6
-rw-r--r--chrome/browser/metrics/metrics_state_manager.cc44
-rw-r--r--chrome/browser/metrics/metrics_state_manager_unittest.cc5
-rw-r--r--chrome/chrome_browser.gypi6
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--chrome/common/pref_names.cc9
-rw-r--r--chrome/common/pref_names.h2
-rw-r--r--components/components_tests.gyp1
-rw-r--r--components/metrics.gypi10
-rw-r--r--components/metrics/cloned_install_detector.cc (renamed from chrome/browser/metrics/cloned_install_detector.cc)20
-rw-r--r--components/metrics/cloned_install_detector.h (renamed from chrome/browser/metrics/cloned_install_detector.h)6
-rw-r--r--components/metrics/machine_id_provider.h (renamed from chrome/browser/metrics/machine_id_provider.h)9
-rw-r--r--components/metrics/machine_id_provider_stub.cc (renamed from chrome/browser/metrics/machine_id_provider_stub.cc)11
-rw-r--r--components/metrics/machine_id_provider_win.cc (renamed from chrome/browser/metrics/machine_id_provider_win.cc)51
-rw-r--r--components/metrics/machine_id_provider_win_unittest.cc (renamed from chrome/browser/metrics/machine_id_provider_win_unittest.cc)2
-rw-r--r--components/metrics/metrics_pref_names.cc8
-rw-r--r--components/metrics/metrics_pref_names.h2
17 files changed, 106 insertions, 87 deletions
diff --git a/chrome/browser/metrics/cloned_install_detector_unittest.cc b/chrome/browser/metrics/cloned_install_detector_unittest.cc
index 6114632..f35ffc8 100644
--- a/chrome/browser/metrics/cloned_install_detector_unittest.cc
+++ b/chrome/browser/metrics/cloned_install_detector_unittest.cc
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/metrics/cloned_install_detector.h"
+#include "components/metrics/cloned_install_detector.h"
#include "base/prefs/testing_pref_service.h"
-#include "chrome/browser/metrics/machine_id_provider.h"
#include "chrome/browser/metrics/metrics_state_manager.h"
-#include "chrome/common/pref_names.h"
+#include "components/metrics/machine_id_provider.h"
+#include "components/metrics/metrics_pref_names.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace metrics {
diff --git a/chrome/browser/metrics/metrics_state_manager.cc b/chrome/browser/metrics/metrics_state_manager.cc
index f8d088e..e602470 100644
--- a/chrome/browser/metrics/metrics_state_manager.cc
+++ b/chrome/browser/metrics/metrics_state_manager.cc
@@ -13,10 +13,11 @@
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
-#include "chrome/browser/metrics/cloned_install_detector.h"
-#include "chrome/browser/metrics/machine_id_provider.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "components/metrics/cloned_install_detector.h"
+#include "components/metrics/machine_id_provider.h"
+#include "components/metrics/metrics_pref_names.h"
#include "components/variations/caching_permuted_entropy_provider.h"
namespace metrics {
@@ -28,8 +29,8 @@ namespace {
// [0, 7999] as the entropy source (12.97 bits of entropy).
const int kMaxLowEntropySize = 8000;
-// Default prefs value for prefs::kMetricsLowEntropySource to indicate that the
-// value has not yet been set.
+// Default prefs value for ::prefs::kMetricsLowEntropySource to indicate that
+// the value has not yet been set.
const int kLowEntropySourceNotSet = -1;
// Generates a new non-identifying entropy source used to seed persistent
@@ -71,21 +72,21 @@ void MetricsStateManager::ForceClientIdCreation() {
if (!client_id_.empty())
return;
- client_id_ = local_state_->GetString(prefs::kMetricsClientID);
+ client_id_ = local_state_->GetString(::prefs::kMetricsClientID);
if (!client_id_.empty())
return;
client_id_ = base::GenerateGUID();
- local_state_->SetString(prefs::kMetricsClientID, client_id_);
+ local_state_->SetString(::prefs::kMetricsClientID, client_id_);
- if (local_state_->GetString(prefs::kMetricsOldClientID).empty()) {
+ if (local_state_->GetString(::prefs::kMetricsOldClientID).empty()) {
// Record the timestamp of when the user opted in to UMA.
- local_state_->SetInt64(prefs::kMetricsReportingEnabledTimestamp,
+ local_state_->SetInt64(::prefs::kMetricsReportingEnabledTimestamp,
base::Time::Now().ToTimeT());
} else {
UMA_HISTOGRAM_BOOLEAN("UMA.ClientIdMigrated", true);
}
- local_state_->ClearPref(prefs::kMetricsOldClientID);
+ local_state_->ClearPref(::prefs::kMetricsOldClientID);
}
void MetricsStateManager::CheckForClonedInstall(
@@ -154,9 +155,9 @@ scoped_ptr<MetricsStateManager> MetricsStateManager::Create(
// static
void MetricsStateManager::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kMetricsResetIds, false);
- registry->RegisterStringPref(prefs::kMetricsClientID, std::string());
- registry->RegisterInt64Pref(prefs::kMetricsReportingEnabledTimestamp, 0);
- registry->RegisterIntegerPref(prefs::kMetricsLowEntropySource,
+ registry->RegisterStringPref(::prefs::kMetricsClientID, std::string());
+ registry->RegisterInt64Pref(::prefs::kMetricsReportingEnabledTimestamp, 0);
+ registry->RegisterIntegerPref(::prefs::kMetricsLowEntropySource,
kLowEntropySourceNotSet);
ClonedInstallDetector::RegisterPrefs(registry);
@@ -164,8 +165,8 @@ void MetricsStateManager::RegisterPrefs(PrefRegistrySimple* registry) {
// TODO(asvitkine): Remove these once a couple of releases have passed.
// http://crbug.com/357704
- registry->RegisterStringPref(prefs::kMetricsOldClientID, std::string());
- registry->RegisterIntegerPref(prefs::kMetricsOldLowEntropySource, 0);
+ registry->RegisterStringPref(::prefs::kMetricsOldClientID, std::string());
+ registry->RegisterIntegerPref(::prefs::kMetricsOldLowEntropySource, 0);
}
int MetricsStateManager::GetLowEntropySource() {
@@ -176,10 +177,11 @@ int MetricsStateManager::GetLowEntropySource() {
return low_entropy_source_;
const CommandLine* command_line(CommandLine::ForCurrentProcess());
- // Only try to load the value from prefs if the user did not request a reset.
+ // Only try to load the value from ::prefs if the user did not request a
+ // reset.
// Otherwise, skip to generating a new value.
if (!command_line->HasSwitch(switches::kResetVariationState)) {
- int value = local_state_->GetInteger(prefs::kMetricsLowEntropySource);
+ int value = local_state_->GetInteger(::prefs::kMetricsLowEntropySource);
// If the value is outside the [0, kMaxLowEntropySize) range, re-generate
// it below.
if (value >= 0 && value < kMaxLowEntropySize) {
@@ -191,10 +193,10 @@ int MetricsStateManager::GetLowEntropySource() {
UMA_HISTOGRAM_BOOLEAN("UMA.GeneratedLowEntropySource", true);
low_entropy_source_ = GenerateLowEntropySource();
- local_state_->SetInteger(prefs::kMetricsLowEntropySource,
+ local_state_->SetInteger(::prefs::kMetricsLowEntropySource,
low_entropy_source_);
- local_state_->ClearPref(prefs::kMetricsOldLowEntropySource);
- metrics::CachingPermutedEntropyProvider::ClearCache(local_state_);
+ local_state_->ClearPref(::prefs::kMetricsOldLowEntropySource);
+ CachingPermutedEntropyProvider::ClearCache(local_state_);
return low_entropy_source_;
}
@@ -208,8 +210,8 @@ void MetricsStateManager::ResetMetricsIDsIfNecessary() {
DCHECK(client_id_.empty());
DCHECK_EQ(kLowEntropySourceNotSet, low_entropy_source_);
- local_state_->ClearPref(prefs::kMetricsClientID);
- local_state_->ClearPref(prefs::kMetricsLowEntropySource);
+ local_state_->ClearPref(::prefs::kMetricsClientID);
+ local_state_->ClearPref(::prefs::kMetricsLowEntropySource);
local_state_->ClearPref(prefs::kMetricsResetIds);
}
diff --git a/chrome/browser/metrics/metrics_state_manager_unittest.cc b/chrome/browser/metrics/metrics_state_manager_unittest.cc
index 11b9622..1ad825c 100644
--- a/chrome/browser/metrics/metrics_state_manager_unittest.cc
+++ b/chrome/browser/metrics/metrics_state_manager_unittest.cc
@@ -12,6 +12,7 @@
#include "base/prefs/testing_pref_service.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "components/metrics/metrics_pref_names.h"
#include "components/variations/caching_permuted_entropy_provider.h"
#include "components/variations/pref_names.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -155,7 +156,7 @@ TEST_F(MetricsStateManagerTest, ResetMetricsIDs) {
}
// Set the reset pref to cause the IDs to be reset.
- prefs_.SetBoolean(::prefs::kMetricsResetIds, true);
+ prefs_.SetBoolean(prefs::kMetricsResetIds, true);
// Cause the actual reset to happen.
{
@@ -165,7 +166,7 @@ TEST_F(MetricsStateManagerTest, ResetMetricsIDs) {
state_manager->GetLowEntropySource();
- EXPECT_FALSE(prefs_.GetBoolean(::prefs::kMetricsResetIds));
+ EXPECT_FALSE(prefs_.GetBoolean(prefs::kMetricsResetIds));
}
EXPECT_NE(kInitialClientId, prefs_.GetString(::prefs::kMetricsClientID));
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 9dd45a7..2ccbb4a 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1185,8 +1185,6 @@
'browser/memory_details_win.cc',
'browser/metrics/chrome_browser_main_extra_parts_metrics.cc',
'browser/metrics/chrome_browser_main_extra_parts_metrics.h',
- 'browser/metrics/cloned_install_detector.cc',
- 'browser/metrics/cloned_install_detector.h',
'browser/metrics/chrome_metrics_service_client.cc',
'browser/metrics/chrome_metrics_service_client.h',
'browser/metrics/compression_utils.cc',
@@ -1197,9 +1195,6 @@
'browser/metrics/field_trial_synchronizer.h',
'browser/metrics/google_update_metrics_provider_win.cc',
'browser/metrics/google_update_metrics_provider_win.h',
- 'browser/metrics/machine_id_provider.h',
- 'browser/metrics/machine_id_provider_stub.cc',
- 'browser/metrics/machine_id_provider_win.cc',
'browser/metrics/metric_event_duration_details.h',
'browser/metrics/metrics_log.cc',
'browser/metrics/metrics_log.h',
@@ -3363,7 +3358,6 @@
'browser/first_run/first_run_dialog.h',
'browser/jankometer_stub.cc',
'browser/lifetime/application_lifetime_stub.cc',
- 'browser/metrics/machine_id_provider_stub.cc',
'browser/prefs/tracked/pref_hash_calculator_helper_stub.cc',
'browser/profiles/profile_shortcut_manager_stub.cc',
],
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 0bc8e12..55fa841 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1081,7 +1081,6 @@
'browser/metrics/cloned_install_detector_unittest.cc',
'browser/metrics/compression_utils_unittest.cc',
'browser/metrics/extension_metrics_unittest.cc',
- 'browser/metrics/machine_id_provider_win_unittest.cc',
'browser/metrics/metrics_log_unittest.cc',
'browser/metrics/metrics_service_unittest.cc',
'browser/metrics/metrics_state_manager_unittest.cc',
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 352f8c5..79e1fd0 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1367,15 +1367,6 @@ const char kMetricsReportingEnabled[] =
const char kMetricsReportingEnabledTimestamp[] =
"user_experience_metrics.client_id_timestamp";
-// A machine ID used to detect when underlying hardware changes. It is only
-// stored locally and never transmitted in metrics reports.
-const char kMetricsMachineId[] = "user_experience_metrics.machine_id";
-
-// Boolean that indicates a cloned install has been detected and the metrics
-// client id and low entropy source should be reset.
-const char kMetricsResetIds[] =
- "user_experience_metrics.reset_metrics_ids";
-
// Boolean that specifies whether or not crash reports are sent
// over the network for analysis.
#if defined(OS_ANDROID)
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 8380903..1915431 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -432,8 +432,6 @@ extern const char kMetricsOldClientID[];
extern const char kMetricsOldLowEntropySource[];
extern const char kMetricsReportingEnabled[];
extern const char kMetricsReportingEnabledTimestamp[];
-extern const char kMetricsMachineId[];
-extern const char kMetricsResetIds[];
// Android has it's own metric / crash reporting implemented in Android
// Java code so kMetricsReportingEnabled doesn't make sense. We use this
// to inform crashes_ui that we have enabled crash reporting.
diff --git a/components/components_tests.gyp b/components/components_tests.gyp
index 64cf12b..c6928eb 100644
--- a/components/components_tests.gyp
+++ b/components/components_tests.gyp
@@ -104,6 +104,7 @@
'keyed_service/content/browser_context_dependency_manager_unittest.cc',
'keyed_service/core/dependency_graph_unittest.cc',
'language_usage_metrics/language_usage_metrics_unittest.cc',
+ 'metrics/machine_id_provider_win_unittest.cc',
'metrics/metrics_hashes_unittest.cc',
'metrics/metrics_log_base_unittest.cc',
'metrics/metrics_log_manager_unittest.cc',
diff --git a/components/metrics.gypi b/components/metrics.gypi
index 850ecd09..fd79d50 100644
--- a/components/metrics.gypi
+++ b/components/metrics.gypi
@@ -16,6 +16,11 @@
],
'sources': [
'metrics/metrics_provider.h',
+ 'metrics/cloned_install_detector.cc',
+ 'metrics/cloned_install_detector.h',
+ 'metrics/machine_id_provider.h',
+ 'metrics/machine_id_provider_stub.cc',
+ 'metrics/machine_id_provider_win.cc',
'metrics/metrics_hashes.cc',
'metrics/metrics_hashes.h',
'metrics/metrics_log_base.cc',
@@ -38,6 +43,11 @@
'metrics_chromeos',
],
}],
+ ['OS=="win"', {
+ 'sources!': [
+ 'metrics/machine_id_provider_stub.cc',
+ ],
+ }],
],
},
{
diff --git a/chrome/browser/metrics/cloned_install_detector.cc b/components/metrics/cloned_install_detector.cc
index b87c539..b93e6e6 100644
--- a/chrome/browser/metrics/cloned_install_detector.cc
+++ b/components/metrics/cloned_install_detector.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/metrics/cloned_install_detector.h"
+#include "components/metrics/cloned_install_detector.h"
#include "base/bind.h"
#include "base/location.h"
@@ -11,10 +11,10 @@
#include "base/prefs/pref_service.h"
#include "base/single_thread_task_runner.h"
#include "base/task_runner_util.h"
-#include "chrome/browser/metrics/cloned_install_detector.h"
-#include "chrome/browser/metrics/machine_id_provider.h"
-#include "chrome/common/pref_names.h"
+#include "components/metrics/cloned_install_detector.h"
+#include "components/metrics/machine_id_provider.h"
#include "components/metrics/metrics_hashes.h"
+#include "components/metrics/metrics_pref_names.h"
namespace metrics {
@@ -45,10 +45,11 @@ void LogMachineIdState(MachineIdState state) {
} // namespace
ClonedInstallDetector::ClonedInstallDetector(MachineIdProvider* raw_id_provider)
- : raw_id_provider_(raw_id_provider),
- weak_ptr_factory_(this) {}
+ : raw_id_provider_(raw_id_provider), weak_ptr_factory_(this) {
+}
-ClonedInstallDetector::~ClonedInstallDetector() {}
+ClonedInstallDetector::~ClonedInstallDetector() {
+}
void ClonedInstallDetector::CheckForClonedInstall(
PrefService* local_state,
@@ -62,9 +63,8 @@ void ClonedInstallDetector::CheckForClonedInstall(
local_state));
}
-void ClonedInstallDetector::SaveMachineId(
- PrefService* local_state,
- std::string raw_id) {
+void ClonedInstallDetector::SaveMachineId(PrefService* local_state,
+ std::string raw_id) {
if (raw_id.empty()) {
LogMachineIdState(ID_GENERATION_FAILED);
local_state->ClearPref(prefs::kMetricsMachineId);
diff --git a/chrome/browser/metrics/cloned_install_detector.h b/components/metrics/cloned_install_detector.h
index 4eae3b0..065cb49 100644
--- a/chrome/browser/metrics/cloned_install_detector.h
+++ b/components/metrics/cloned_install_detector.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_METRICS_CLONED_INSTALL_DETECTOR_H_
-#define CHROME_BROWSER_METRICS_CLONED_INSTALL_DETECTOR_H_
+#ifndef COMPONENTS_METRICS_CLONED_INSTALL_DETECTOR_H_
+#define COMPONENTS_METRICS_CLONED_INSTALL_DETECTOR_H_
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
@@ -56,4 +56,4 @@ class ClonedInstallDetector {
} // namespace metrics
-#endif // CHROME_BROWSER_METRICS_CLONED_INSTALL_DETECTOR_H_
+#endif // COMPONENTS_METRICS_CLONED_INSTALL_DETECTOR_H_
diff --git a/chrome/browser/metrics/machine_id_provider.h b/components/metrics/machine_id_provider.h
index a154dad..d7fcc44 100644
--- a/chrome/browser/metrics/machine_id_provider.h
+++ b/components/metrics/machine_id_provider.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_METRICS_MACHINE_ID_PROVIDER_H_
-#define CHROME_BROWSER_METRICS_MACHINE_ID_PROVIDER_H_
+#ifndef COMPONENTS_METRICS_MACHINE_ID_PROVIDER_H_
+#define COMPONENTS_METRICS_MACHINE_ID_PROVIDER_H_
#include <string>
@@ -21,7 +21,6 @@ namespace metrics {
// RefCountedThreadSafe (crbug.com/354882).
class MachineIdProvider : public base::RefCountedThreadSafe<MachineIdProvider> {
public:
-
// Get a string containing machine characteristics, to be used as a machine
// id. The implementation is platform specific, with a default implementation
// returning an empty string.
@@ -42,6 +41,6 @@ class MachineIdProvider : public base::RefCountedThreadSafe<MachineIdProvider> {
DISALLOW_COPY_AND_ASSIGN(MachineIdProvider);
};
-} // namespace metrics
+} // namespace metrics
-#endif // CHROME_BROWSER_METRICS_MACHINE_ID_PROVIDER_H_
+#endif // COMPONENTS_METRICS_MACHINE_ID_PROVIDER_H_
diff --git a/chrome/browser/metrics/machine_id_provider_stub.cc b/components/metrics/machine_id_provider_stub.cc
index f9a188b..626f2b7 100644
--- a/chrome/browser/metrics/machine_id_provider_stub.cc
+++ b/components/metrics/machine_id_provider_stub.cc
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/metrics/machine_id_provider.h"
+#include "components/metrics/machine_id_provider.h"
namespace metrics {
-MachineIdProvider::MachineIdProvider() {}
-MachineIdProvider::~MachineIdProvider() {}
+MachineIdProvider::MachineIdProvider() {
+}
+
+MachineIdProvider::~MachineIdProvider() {
+}
// static
MachineIdProvider* MachineIdProvider::CreateInstance() {
@@ -18,4 +21,4 @@ std::string MachineIdProvider::GetMachineId() {
return std::string();
}
-} // namespace metrics
+} // namespace metrics
diff --git a/chrome/browser/metrics/machine_id_provider_win.cc b/components/metrics/machine_id_provider_win.cc
index c5c6c72..777151a 100644
--- a/chrome/browser/metrics/machine_id_provider_win.cc
+++ b/components/metrics/machine_id_provider_win.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/metrics/machine_id_provider.h"
+#include "components/metrics/machine_id_provider.h"
#include <windows.h>
#include <winioctl.h>
@@ -15,8 +15,11 @@
namespace metrics {
-MachineIdProvider::MachineIdProvider() {}
-MachineIdProvider::~MachineIdProvider() {}
+MachineIdProvider::MachineIdProvider() {
+}
+
+MachineIdProvider::~MachineIdProvider() {
+}
// On windows, the machine id is based on the serial number of the drive Chrome
// is running from.
@@ -41,14 +44,14 @@ std::string MachineIdProvider::GetMachineId() {
}
base::FilePath::StringType drive_name = L"\\\\.\\" + path_components[0];
- base::win::ScopedHandle drive_handle(CreateFile(
- drive_name.c_str(),
- 0,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- 0,
- NULL));
+ base::win::ScopedHandle drive_handle(
+ CreateFile(drive_name.c_str(),
+ 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL));
STORAGE_PROPERTY_QUERY query = {};
query.PropertyId = StorageDeviceProperty;
@@ -57,20 +60,28 @@ std::string MachineIdProvider::GetMachineId() {
// Perform an initial query to get the number of bytes being returned.
DWORD bytes_returned;
STORAGE_DESCRIPTOR_HEADER header = {};
- BOOL status = DeviceIoControl(drive_handle, IOCTL_STORAGE_QUERY_PROPERTY,
- &query, sizeof(STORAGE_PROPERTY_QUERY),
- &header, sizeof(STORAGE_DESCRIPTOR_HEADER),
- &bytes_returned, NULL);
+ BOOL status = DeviceIoControl(drive_handle,
+ IOCTL_STORAGE_QUERY_PROPERTY,
+ &query,
+ sizeof(STORAGE_PROPERTY_QUERY),
+ &header,
+ sizeof(STORAGE_DESCRIPTOR_HEADER),
+ &bytes_returned,
+ NULL);
if (!status)
return std::string();
// Query for the actual serial number.
std::vector<int8> output_buf(header.Size);
- status = DeviceIoControl(drive_handle, IOCTL_STORAGE_QUERY_PROPERTY,
- &query, sizeof(STORAGE_PROPERTY_QUERY),
- &output_buf[0], output_buf.size(),
- &bytes_returned, NULL);
+ status = DeviceIoControl(drive_handle,
+ IOCTL_STORAGE_QUERY_PROPERTY,
+ &query,
+ sizeof(STORAGE_PROPERTY_QUERY),
+ &output_buf[0],
+ output_buf.size(),
+ &bytes_returned,
+ NULL);
if (!status)
return std::string();
@@ -103,4 +114,4 @@ MachineIdProvider* MachineIdProvider::CreateInstance() {
return new MachineIdProvider();
}
-} // namespace metrics
+} // namespace metrics
diff --git a/chrome/browser/metrics/machine_id_provider_win_unittest.cc b/components/metrics/machine_id_provider_win_unittest.cc
index 61be2a4..44917d0 100644
--- a/chrome/browser/metrics/machine_id_provider_win_unittest.cc
+++ b/components/metrics/machine_id_provider_win_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/metrics/machine_id_provider.h"
+#include "components/metrics/machine_id_provider.h"
#include "base/memory/ref_counted.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/metrics/metrics_pref_names.cc b/components/metrics/metrics_pref_names.cc
index 92a1890..e0b358a1 100644
--- a/components/metrics/metrics_pref_names.cc
+++ b/components/metrics/metrics_pref_names.cc
@@ -13,6 +13,10 @@ namespace prefs {
const char kMetricsInitialLogs[] =
"user_experience_metrics.initial_logs_as_protobufs";
+// A machine ID used to detect when underlying hardware changes. It is only
+// stored locally and never transmitted in metrics reports.
+const char kMetricsMachineId[] = "user_experience_metrics.machine_id";
+
// Array of strings that are each UMA logs that were not sent because the
// browser terminated before these accumulated metrics could be sent. These
// logs typically include histograms and memory reports, as well as ongoing
@@ -20,5 +24,9 @@ const char kMetricsInitialLogs[] =
const char kMetricsOngoingLogs[] =
"user_experience_metrics.ongoing_logs_as_protobufs";
+// Boolean that indicates a cloned install has been detected and the metrics
+// client id and low entropy source should be reset.
+const char kMetricsResetIds[] = "user_experience_metrics.reset_metrics_ids";
+
} // namespace prefs
} // namespace metrics
diff --git a/components/metrics/metrics_pref_names.h b/components/metrics/metrics_pref_names.h
index 750d58d..4c799c7 100644
--- a/components/metrics/metrics_pref_names.h
+++ b/components/metrics/metrics_pref_names.h
@@ -11,7 +11,9 @@ namespace prefs {
// Alphabetical list of preference names specific to the metrics
// component. Keep alphabetized, and document each in the .cc file.
extern const char kMetricsInitialLogs[];
+extern const char kMetricsMachineId[];
extern const char kMetricsOngoingLogs[];
+extern const char kMetricsResetIds[];
} // namespace prefs
} // namespace metrics