Chromium Code Reviews| 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 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 Loading... | |
| 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()); | |
|
Ilya Sherman
2013/10/16 18:26:14
nit: Why does the hash need to be hex-encoded? If
Ilya Sherman
2013/10/16 18:26:14
Please consider adding a DCHECK to verify that the
Alexei Svitkine (slow)
2013/10/16 19:31:46
Done.
Alexei Svitkine (slow)
2013/10/16 19:31:46
The SHA1 hash returned by the API we're using the
| |
| 1469 current_fetch_->AddExtraRequestHeader("X-Chrome-UMA-Log-SHA1: " + hash); | |
| 1466 UMA_HISTOGRAM_PERCENTAGE( | 1470 UMA_HISTOGRAM_PERCENTAGE( |
| 1467 "UMA.ProtoCompressionRatio", | 1471 "UMA.ProtoCompressionRatio", |
| 1468 100 * compressed_log_text.size() / log_text.size()); | 1472 100 * compressed_log_text.size() / log_text.size()); |
| 1469 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1473 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 1470 "UMA.ProtoGzippedKBSaved", | 1474 "UMA.ProtoGzippedKBSaved", |
| 1471 (log_text.size() - compressed_log_text.size()) / 1024, | 1475 (log_text.size() - compressed_log_text.size()) / 1024, |
| 1472 1, 2000, 50); | 1476 1, 2000, 50); |
| 1473 } | 1477 } |
| 1474 | 1478 |
| 1475 // We already drop cookies server-side, but we might as well strip them out | 1479 // 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 Loading... | |
| 1813 if (local_state) { | 1817 if (local_state) { |
| 1814 const PrefService::Preference* uma_pref = | 1818 const PrefService::Preference* uma_pref = |
| 1815 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1819 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
| 1816 if (uma_pref) { | 1820 if (uma_pref) { |
| 1817 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1821 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
| 1818 DCHECK(success); | 1822 DCHECK(success); |
| 1819 } | 1823 } |
| 1820 } | 1824 } |
| 1821 return result; | 1825 return result; |
| 1822 } | 1826 } |
| OLD | NEW |