OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 //------------------------------------------------------------------------------ | 5 //------------------------------------------------------------------------------ |
6 // Description of the life cycle of a instance of MetricsService. | 6 // Description of the life cycle of a instance of MetricsService. |
7 // | 7 // |
8 // OVERVIEW | 8 // OVERVIEW |
9 // | 9 // |
10 // A MetricsService instance is typically created at application startup. It | 10 // A MetricsService instance is typically created at application startup. It |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 std::string MetricsService::GetEntropySource(bool reporting_will_be_enabled) { | 542 std::string MetricsService::GetEntropySource(bool reporting_will_be_enabled) { |
543 // For metrics reporting-enabled users, we combine the client ID and low | 543 // For metrics reporting-enabled users, we combine the client ID and low |
544 // entropy source to get the final entropy source. Otherwise, only use the low | 544 // entropy source to get the final entropy source. Otherwise, only use the low |
545 // entropy source. | 545 // entropy source. |
546 // This has two useful properties: | 546 // This has two useful properties: |
547 // 1) It makes the entropy source less identifiable for parties that do not | 547 // 1) It makes the entropy source less identifiable for parties that do not |
548 // know the low entropy source. | 548 // know the low entropy source. |
549 // 2) It makes the final entropy source resettable. | 549 // 2) It makes the final entropy source resettable. |
550 std::string low_entropy_source = base::IntToString(GetLowEntropySource()); | 550 std::string low_entropy_source = base::IntToString(GetLowEntropySource()); |
551 if (reporting_will_be_enabled) { | 551 if (reporting_will_be_enabled) { |
552 entropy_source_returned_ = LAST_ENTROPY_HIGH; | 552 if (entropy_source_returned_ == LAST_ENTROPY_NONE) |
| 553 entropy_source_returned_ = LAST_ENTROPY_HIGH; |
| 554 DCHECK_EQ(LAST_ENTROPY_HIGH, entropy_source_returned_); |
553 return client_id_ + low_entropy_source; | 555 return client_id_ + low_entropy_source; |
554 } | 556 } |
555 entropy_source_returned_ = LAST_ENTROPY_LOW; | 557 if (entropy_source_returned_ == LAST_ENTROPY_NONE) |
| 558 entropy_source_returned_ = LAST_ENTROPY_LOW; |
| 559 DCHECK_EQ(LAST_ENTROPY_LOW, entropy_source_returned_); |
556 return low_entropy_source; | 560 return low_entropy_source; |
557 } | 561 } |
558 | 562 |
559 void MetricsService::ForceClientIdCreation() { | 563 void MetricsService::ForceClientIdCreation() { |
560 if (!client_id_.empty()) | 564 if (!client_id_.empty()) |
561 return; | 565 return; |
562 PrefService* pref = g_browser_process->local_state(); | 566 PrefService* pref = g_browser_process->local_state(); |
563 client_id_ = pref->GetString(prefs::kMetricsClientID); | 567 client_id_ = pref->GetString(prefs::kMetricsClientID); |
564 if (!client_id_.empty()) | 568 if (!client_id_.empty()) |
565 return; | 569 return; |
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 if (local_state) { | 1913 if (local_state) { |
1910 const PrefService::Preference* uma_pref = | 1914 const PrefService::Preference* uma_pref = |
1911 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1915 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1912 if (uma_pref) { | 1916 if (uma_pref) { |
1913 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1917 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1914 DCHECK(success); | 1918 DCHECK(success); |
1915 } | 1919 } |
1916 } | 1920 } |
1917 return result; | 1921 return result; |
1918 } | 1922 } |
OLD | NEW |