Explicitly check reporting state when returning the entropy source.

We used to CHECK if the client ID was set but we were not reporting metrics, but this is not technically guaranteed since the user can enable or disable UMA without changing the locally stored client ID.

BUG=none
TEST=Ensure that enabling and disabling UMA in an official build does not crash Chrome.


Review URL: https://chromiumcodereview.appspot.com/10452027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138999 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 56bf7e5..a89c1f1d 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -465,14 +465,17 @@
 }
 
 std::string MetricsService::GetEntropySource() {
-  // Note that client_id_ is empty if metrics reporting is not enabled. For
-  // metrics reporting-enabled users, we combine the client ID and low entropy
-  // source to get the final entropy source. This has two useful properties:
+  // For metrics reporting-enabled users, we combine the client ID and low
+  // entropy source to get the final entropy source. Otherwise, only use the low
+  // entropy source.
+  // This has two useful properties:
   //  1) It makes the entropy source less identifiable for parties that do not
   //     know the low entropy source.
   //  2) It makes the final entropy source resettable.
-  CHECK(reporting_active() || client_id_.empty());
-  return client_id_ + base::IntToString(GetLowEntropySource());
+  std::string low_entropy_source = base::IntToString(GetLowEntropySource());
+  if (reporting_active())
+    return client_id_ + low_entropy_source;
+  return low_entropy_source;
 }
 
 void MetricsService::ForceClientIdCreation() {