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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 void MetricsService::Stop() { | 531 void MetricsService::Stop() { |
532 HandleIdleSinceLastTransmission(false); | 532 HandleIdleSinceLastTransmission(false); |
533 SetReporting(false); | 533 SetReporting(false); |
534 SetRecording(false); | 534 SetRecording(false); |
535 } | 535 } |
536 | 536 |
537 std::string MetricsService::GetClientId() { | 537 std::string MetricsService::GetClientId() { |
538 return client_id_; | 538 return client_id_; |
539 } | 539 } |
540 | 540 |
541 std::string MetricsService::GetEntropySource() { | 541 std::string MetricsService::GetEntropySource(bool reporting_will_be_enabled) { |
Ilya Sherman
2012/08/09 16:47:29
Optional nit: Perhaps add a comment mentioning why
SteveT
2012/08/09 17:18:30
Good call. I did this in the header.
| |
542 // For metrics reporting-enabled users, we combine the client ID and low | 542 // For metrics reporting-enabled users, we combine the client ID and low |
543 // entropy source to get the final entropy source. Otherwise, only use the low | 543 // entropy source to get the final entropy source. Otherwise, only use the low |
544 // entropy source. | 544 // entropy source. |
545 // This has two useful properties: | 545 // This has two useful properties: |
546 // 1) It makes the entropy source less identifiable for parties that do not | 546 // 1) It makes the entropy source less identifiable for parties that do not |
547 // know the low entropy source. | 547 // know the low entropy source. |
548 // 2) It makes the final entropy source resettable. | 548 // 2) It makes the final entropy source resettable. |
549 std::string low_entropy_source = base::IntToString(GetLowEntropySource()); | 549 std::string low_entropy_source = base::IntToString(GetLowEntropySource()); |
550 if (reporting_active()) | 550 if (reporting_will_be_enabled) |
551 return client_id_ + low_entropy_source; | 551 return client_id_ + low_entropy_source; |
552 return low_entropy_source; | 552 return low_entropy_source; |
553 } | 553 } |
554 | 554 |
555 void MetricsService::ForceClientIdCreation() { | 555 void MetricsService::ForceClientIdCreation() { |
556 if (!client_id_.empty()) | 556 if (!client_id_.empty()) |
557 return; | 557 return; |
558 PrefService* pref = g_browser_process->local_state(); | 558 PrefService* pref = g_browser_process->local_state(); |
559 client_id_ = pref->GetString(prefs::kMetricsClientID); | 559 client_id_ = pref->GetString(prefs::kMetricsClientID); |
560 if (!client_id_.empty()) | 560 if (!client_id_.empty()) |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1905 if (local_state) { | 1905 if (local_state) { |
1906 const PrefService::Preference* uma_pref = | 1906 const PrefService::Preference* uma_pref = |
1907 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1907 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1908 if (uma_pref) { | 1908 if (uma_pref) { |
1909 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1909 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1910 DCHECK(success); | 1910 DCHECK(success); |
1911 } | 1911 } |
1912 } | 1912 } |
1913 return result; | 1913 return result; |
1914 } | 1914 } |
OLD | NEW |