Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: chrome/browser/metrics/metrics_service.cc

Issue 10830241: Inform GetEntropySource of whether or not metrics reporting will be enabled. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added browsertest Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 495
496 MetricsService::MetricsService() 496 MetricsService::MetricsService()
497 : recording_active_(false), 497 : recording_active_(false),
498 reporting_active_(false), 498 reporting_active_(false),
499 state_(INITIALIZED), 499 state_(INITIALIZED),
500 low_entropy_source_(0), 500 low_entropy_source_(0),
501 idle_since_last_transmission_(false), 501 idle_since_last_transmission_(false),
502 next_window_id_(0), 502 next_window_id_(0),
503 ALLOW_THIS_IN_INITIALIZER_LIST(self_ptr_factory_(this)), 503 ALLOW_THIS_IN_INITIALIZER_LIST(self_ptr_factory_(this)),
504 ALLOW_THIS_IN_INITIALIZER_LIST(state_saver_factory_(this)), 504 ALLOW_THIS_IN_INITIALIZER_LIST(state_saver_factory_(this)),
505 waiting_for_asynchronous_reporting_step_(false) { 505 waiting_for_asynchronous_reporting_step_(false),
506 entropy_source_returned_(LAST_ENTROPY_NONE) {
506 DCHECK(IsSingleThreaded()); 507 DCHECK(IsSingleThreaded());
507 InitializeMetricsState(); 508 InitializeMetricsState();
508 509
509 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, 510 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload,
510 self_ptr_factory_.GetWeakPtr()); 511 self_ptr_factory_.GetWeakPtr());
511 scheduler_.reset(new MetricsReportingScheduler(callback)); 512 scheduler_.reset(new MetricsReportingScheduler(callback));
512 log_manager_.set_log_serializer(new MetricsLogSerializer()); 513 log_manager_.set_log_serializer(new MetricsLogSerializer());
513 log_manager_.set_max_ongoing_log_store_size(kUploadLogAvoidRetransmitSize); 514 log_manager_.set_max_ongoing_log_store_size(kUploadLogAvoidRetransmitSize);
514 } 515 }
515 516
(...skipping 15 matching lines...) Expand all
531 void MetricsService::Stop() { 532 void MetricsService::Stop() {
532 HandleIdleSinceLastTransmission(false); 533 HandleIdleSinceLastTransmission(false);
533 SetReporting(false); 534 SetReporting(false);
534 SetRecording(false); 535 SetRecording(false);
535 } 536 }
536 537
537 std::string MetricsService::GetClientId() { 538 std::string MetricsService::GetClientId() {
538 return client_id_; 539 return client_id_;
539 } 540 }
540 541
541 std::string MetricsService::GetEntropySource() { 542 std::string MetricsService::GetEntropySource(bool reporting_will_be_enabled) {
542 // 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
543 // 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
544 // entropy source. 545 // entropy source.
545 // This has two useful properties: 546 // This has two useful properties:
546 // 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
547 // know the low entropy source. 548 // know the low entropy source.
548 // 2) It makes the final entropy source resettable. 549 // 2) It makes the final entropy source resettable.
549 std::string low_entropy_source = base::IntToString(GetLowEntropySource()); 550 std::string low_entropy_source = base::IntToString(GetLowEntropySource());
550 if (reporting_active()) 551 if (reporting_will_be_enabled) {
552 entropy_source_returned_ = LAST_ENTROPY_HIGH;
551 return client_id_ + low_entropy_source; 553 return client_id_ + low_entropy_source;
554 }
555 entropy_source_returned_ = LAST_ENTROPY_LOW;
552 return low_entropy_source; 556 return low_entropy_source;
553 } 557 }
554 558
555 void MetricsService::ForceClientIdCreation() { 559 void MetricsService::ForceClientIdCreation() {
556 if (!client_id_.empty()) 560 if (!client_id_.empty())
557 return; 561 return;
558 PrefService* pref = g_browser_process->local_state(); 562 PrefService* pref = g_browser_process->local_state();
559 client_id_ = pref->GetString(prefs::kMetricsClientID); 563 client_id_ = pref->GetString(prefs::kMetricsClientID);
560 if (!client_id_.empty()) 564 if (!client_id_.empty())
561 return; 565 return;
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 if (local_state) { 1909 if (local_state) {
1906 const PrefService::Preference* uma_pref = 1910 const PrefService::Preference* uma_pref =
1907 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1911 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1908 if (uma_pref) { 1912 if (uma_pref) {
1909 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1913 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1910 DCHECK(success); 1914 DCHECK(success);
1911 } 1915 }
1912 } 1916 }
1913 return result; 1917 return result;
1914 } 1918 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698