diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-28 05:43:37 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-28 05:43:37 +0000 |
commit | e324f6b9b93237c1488694b2a94cff0f8ec85460 (patch) | |
tree | 6b7ec91ccdf30bc794d8f837fcaac335f8a43afa /chrome/common/metrics/metrics_log_manager.cc | |
parent | cce1cd0b2c227ab0c94276fbd1cc5155fc7b9943 (diff) | |
download | chromium_src-e324f6b9b93237c1488694b2a94cff0f8ec85460.zip chromium_src-e324f6b9b93237c1488694b2a94cff0f8ec85460.tar.gz chromium_src-e324f6b9b93237c1488694b2a94cff0f8ec85460.tar.bz2 |
Revert 123901 - Upload UMA data using protocol buffers.
For now, we will also preserve the existing XML upload system, so that there is no risk of data loss.
BUG=109817
TEST=unit tested
Review URL: http://codereview.chromium.org/9232071
TBR=isherman@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9478031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/metrics/metrics_log_manager.cc')
-rw-r--r-- | chrome/common/metrics/metrics_log_manager.cc | 63 |
1 files changed, 15 insertions, 48 deletions
diff --git a/chrome/common/metrics/metrics_log_manager.cc b/chrome/common/metrics/metrics_log_manager.cc index a917bcf..32fe51c 100644 --- a/chrome/common/metrics/metrics_log_manager.cc +++ b/chrome/common/metrics/metrics_log_manager.cc @@ -14,23 +14,10 @@ #include "base/string_util.h" #include "chrome/common/metrics/metrics_log_base.h" -namespace { - -// Used to keep track of discarded protobuf logs without having to track xml and -// protobuf logs in separate lists. -const char kDiscardedLog[] = "Log discarded"; - -} // anonymous namespace - MetricsLogManager::MetricsLogManager() : max_ongoing_log_store_size_(0) {} MetricsLogManager::~MetricsLogManager() {} -bool MetricsLogManager::SerializedLog::empty() const { - DCHECK_EQ(xml.empty(), proto.empty()); - return xml.empty(); -} - void MetricsLogManager::BeginLoggingWithLog(MetricsLogBase* log) { DCHECK(!current_log_.get()); current_log_.reset(log); @@ -44,21 +31,12 @@ void MetricsLogManager::StageCurrentLogForUpload() { } bool MetricsLogManager::has_staged_log() const { - return staged_log_.get() || !staged_log_text().empty(); -} - -bool MetricsLogManager::has_staged_log_proto() const { - return has_staged_log() && staged_log_text().proto != kDiscardedLog; + return staged_log_.get() || !compressed_staged_log_text_.empty(); } void MetricsLogManager::DiscardStagedLog() { staged_log_.reset(); - staged_log_text_.xml.clear(); - staged_log_text_.proto.clear(); -} - -void MetricsLogManager::DiscardStagedLogProto() { - staged_log_text_.proto = kDiscardedLog; + compressed_staged_log_text_.clear(); } void MetricsLogManager::DiscardCurrentLog() { @@ -78,26 +56,21 @@ void MetricsLogManager::ResumePausedLog() { void MetricsLogManager::StoreStagedLogAsUnsent(LogType log_type) { DCHECK(has_staged_log()); - // If compressing the log failed, there's nothing to store. - if (staged_log_text().empty()) + if (compressed_staged_log_text_.empty()) return; if (log_type == INITIAL_LOG) { - unsent_initial_logs_.push_back(staged_log_text_); + unsent_initial_logs_.push_back(compressed_staged_log_text_); } else { // If it's too large, just note that and discard it. if (max_ongoing_log_store_size_ && - staged_log_text().xml.length() > max_ongoing_log_store_size_) { - // TODO(isherman): We probably want a similar check for protobufs, but we - // don't want to prevent XML upload just because the protobuf version is - // too long. In practice, I'm pretty sure the XML version should always - // be longer, or at least on the same order of magnitude in length. + compressed_staged_log_text_.length() > max_ongoing_log_store_size_) { UMA_HISTOGRAM_COUNTS( "UMA.Large Accumulated Log Not Persisted", - static_cast<int>(staged_log_text().xml.length())); + static_cast<int>(compressed_staged_log_text_.length())); } else { - unsent_ongoing_logs_.push_back(staged_log_text_); + unsent_ongoing_logs_.push_back(compressed_staged_log_text_); } } DiscardStagedLog(); @@ -105,13 +78,11 @@ void MetricsLogManager::StoreStagedLogAsUnsent(LogType log_type) { void MetricsLogManager::StageNextStoredLogForUpload() { // Prioritize initial logs for uploading. - std::vector<SerializedLog>* source_list = - unsent_initial_logs_.empty() ? - &unsent_ongoing_logs_ : - &unsent_initial_logs_; + std::vector<std::string>* source_list = unsent_initial_logs_.empty() ? + &unsent_ongoing_logs_ : &unsent_initial_logs_; DCHECK(!source_list->empty()); - DCHECK(staged_log_text().empty()); - staged_log_text_ = source_list->back(); + DCHECK(compressed_staged_log_text_.empty()); + compressed_staged_log_text_ = source_list->back(); source_list->pop_back(); } @@ -132,20 +103,16 @@ void MetricsLogManager::LoadPersistedUnsentLogs() { } void MetricsLogManager::CompressStagedLog() { - int text_size = staged_log_->GetEncodedLogSizeXml(); + int text_size = staged_log_->GetEncodedLogSize(); std::string staged_log_text; DCHECK_GT(text_size, 0); - staged_log_->GetEncodedLogXml(WriteInto(&staged_log_text, text_size + 1), - text_size); + staged_log_->GetEncodedLog(WriteInto(&staged_log_text, text_size + 1), + text_size); - bool success = Bzip2Compress(staged_log_text, &staged_log_text_.xml); + bool success = Bzip2Compress(staged_log_text, &compressed_staged_log_text_); if (success) { // Allow security-conscious users to see all metrics logs that we send. DVLOG(1) << "METRICS LOG: " << staged_log_text; - - // Note that we only save the protobuf version if we succeeded in - // compressing the XML, so that the two data streams are the same. - staged_log_->GetEncodedLogProto(&staged_log_text_.proto); } else { NOTREACHED() << "Failed to compress log for transmission."; } |