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

Unified Diff: chrome/common/metrics/metrics_log_manager.cc

Issue 12529024: Fix feedback log collection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/metrics/metrics_log_manager.cc
diff --git a/chrome/common/metrics/metrics_log_manager.cc b/chrome/common/metrics/metrics_log_manager.cc
index e958074cc8a7e50940a7f69aa797f9137ba68332..bef30a3722ee558160961cb250ed20b2d231ee55 100644
--- a/chrome/common/metrics/metrics_log_manager.cc
+++ b/chrome/common/metrics/metrics_log_manager.cc
@@ -4,16 +4,11 @@
#include "chrome/common/metrics/metrics_log_manager.h"
-#if defined(USE_SYSTEM_LIBBZ2)
-#include <bzlib.h>
-#else
-#include "third_party/bzip2/bzlib.h"
-#endif
-
#include <algorithm>
#include "base/metrics/histogram.h"
#include "base/string_util.h"
+#include "base/strings/string_compress.h"
#include "chrome/common/metrics/metrics_log_base.h"
namespace {
@@ -233,7 +228,7 @@ void MetricsLogManager::CompressCurrentLog(SerializedLog* compressed_log) {
current_log_->GetEncodedLogXml(WriteInto(&log_text, text_size + 1),
text_size);
- bool success = Bzip2Compress(log_text, &(compressed_log->xml));
+ bool success = base::Bzip2Compress(log_text, &(compressed_log->xml));
if (success) {
// Allow security-conscious users to see all metrics logs that we send.
DVLOG(1) << "METRICS LOG: " << log_text;
@@ -245,46 +240,3 @@ void MetricsLogManager::CompressCurrentLog(SerializedLog* compressed_log) {
NOTREACHED() << "Failed to compress log for transmission.";
}
}
-
-// static
-// This implementation is based on the Firefox MetricsService implementation.
-bool MetricsLogManager::Bzip2Compress(const std::string& input,
- std::string* output) {
- bz_stream stream = {0};
- // As long as our input is smaller than the bzip2 block size, we should get
- // the best compression. For example, if your input was 250k, using a block
- // size of 300k or 500k should result in the same compression ratio. Since
- // our data should be under 100k, using the minimum block size of 100k should
- // allocate less temporary memory, but result in the same compression ratio.
- int result = BZ2_bzCompressInit(&stream,
- 1, // 100k (min) block size
- 0, // quiet
- 0); // default "work factor"
- if (result != BZ_OK) { // out of memory?
- return false;
- }
-
- output->clear();
-
- stream.next_in = const_cast<char*>(input.data());
- stream.avail_in = static_cast<int>(input.size());
- // NOTE: we don't need a BZ_RUN phase since our input buffer contains
- // the entire input
- do {
- output->resize(output->size() + 1024);
- stream.next_out = &((*output)[stream.total_out_lo32]);
- stream.avail_out = static_cast<int>(output->size()) - stream.total_out_lo32;
- result = BZ2_bzCompress(&stream, BZ_FINISH);
- } while (result == BZ_FINISH_OK);
- if (result != BZ_STREAM_END) { // unknown failure?
- output->clear();
- // TODO(jar): See if it would be better to do a CHECK() here.
- return false;
- }
- result = BZ2_bzCompressEnd(&stream);
- DCHECK(result == BZ_OK);
-
- output->resize(stream.total_out_lo32);
-
- return true;
-}
« chrome/browser/feedback/feedback_data.h ('K') | « chrome/common/metrics/metrics_log_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698