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

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

Issue 26646003: MetricsService: Send a hash of the UMA log in a header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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 is 10 // A MetricsService instance is typically created at application startup. It is
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 1456
1457 std::string log_text = log_manager_.staged_log_text(); 1457 std::string log_text = log_manager_.staged_log_text();
1458 std::string compressed_log_text; 1458 std::string compressed_log_text;
1459 bool compression_successful = chrome::GzipCompress(log_text, 1459 bool compression_successful = chrome::GzipCompress(log_text,
1460 &compressed_log_text); 1460 &compressed_log_text);
1461 DCHECK(compression_successful); 1461 DCHECK(compression_successful);
1462 if (compression_successful) { 1462 if (compression_successful) {
1463 current_fetch_->SetUploadData(kMimeType, compressed_log_text); 1463 current_fetch_->SetUploadData(kMimeType, compressed_log_text);
1464 // Tell the server that we're uploading gzipped protobufs. 1464 // Tell the server that we're uploading gzipped protobufs.
1465 current_fetch_->SetExtraRequestHeaders("content-encoding: gzip"); 1465 current_fetch_->SetExtraRequestHeaders("content-encoding: gzip");
1466 const std::string hash =
1467 base::HexEncode(log_manager_.staged_log_hash().data(),
1468 log_manager_.staged_log_hash().size());
1469 DCHECK(!hash.empty());
1470 current_fetch_->AddExtraRequestHeader("X-Chrome-UMA-Log-SHA1: " + hash);
1466 UMA_HISTOGRAM_PERCENTAGE( 1471 UMA_HISTOGRAM_PERCENTAGE(
1467 "UMA.ProtoCompressionRatio", 1472 "UMA.ProtoCompressionRatio",
1468 100 * compressed_log_text.size() / log_text.size()); 1473 100 * compressed_log_text.size() / log_text.size());
1469 UMA_HISTOGRAM_CUSTOM_COUNTS( 1474 UMA_HISTOGRAM_CUSTOM_COUNTS(
1470 "UMA.ProtoGzippedKBSaved", 1475 "UMA.ProtoGzippedKBSaved",
1471 (log_text.size() - compressed_log_text.size()) / 1024, 1476 (log_text.size() - compressed_log_text.size()) / 1024,
1472 1, 2000, 50); 1477 1, 2000, 50);
1473 } 1478 }
1474 1479
1475 // We already drop cookies server-side, but we might as well strip them out 1480 // We already drop cookies server-side, but we might as well strip them out
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 if (local_state) { 1818 if (local_state) {
1814 const PrefService::Preference* uma_pref = 1819 const PrefService::Preference* uma_pref =
1815 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1820 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1816 if (uma_pref) { 1821 if (uma_pref) {
1817 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1822 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1818 DCHECK(success); 1823 DCHECK(success);
1819 } 1824 }
1820 } 1825 }
1821 return result; 1826 return result;
1822 } 1827 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698