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

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

Issue 9232071: Upload UMA data using protocol buffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 10 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.h
diff --git a/chrome/common/metrics/metrics_log_manager.h b/chrome/common/metrics/metrics_log_manager.h
index 3eb04f00d755047be6eff068b3e6685ec612866f..1eb92b118a6a29efb70100f75a197c742a0d6eed 100644
--- a/chrome/common/metrics/metrics_log_manager.h
+++ b/chrome/common/metrics/metrics_log_manager.h
@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include <string>
+#include <utility>
#include <vector>
class MetricsLogBase;
@@ -36,9 +37,14 @@ class MetricsLogManager {
// Note that this returns true even if compressing the log text failed.
bool has_staged_log() const;
- // The compressed text of the staged log. Empty if there is no staged log,
- // or if compression of the staged log failed.
- const std::string& staged_log_text() { return compressed_staged_log_text_; }
+ // The text of the staged log, in compressed XML or protobuf format. Empty if
+ // there is no staged log, or if compression of the staged log failed.
+ const std::string& staged_log_text_xml() const {
jar (doing other things) 2012/02/23 01:59:18 This sort of accessor helps some (and keeps us awa
+ return staged_log_text_.first;
+ }
+ const std::string& staged_log_text_proto() const {
+ return staged_log_text_.second;
+ }
// Discards the staged log.
void DiscardStagedLog();
@@ -91,13 +97,15 @@ class MetricsLogManager {
// Serializes |logs| to persistent storage, replacing any previously
// serialized logs of the same type.
- virtual void SerializeLogs(const std::vector<std::string>& logs,
- LogType log_type) = 0;
+ virtual void SerializeLogs(
+ const std::vector<std::pair<std::string, std::string> >& logs,
+ LogType log_type) = 0;
// Populates |logs| with logs of type |log_type| deserialized from
// persistent storage.
- virtual void DeserializeLogs(LogType log_type,
- std::vector<std::string>* logs) = 0;
+ virtual void DeserializeLogs(
+ LogType log_type,
+ std::vector<std::pair<std::string, std::string> >* logs) = 0;
};
// Sets the serializer to use for persisting and loading logs; takes ownership
@@ -115,8 +123,8 @@ class MetricsLogManager {
void LoadPersistedUnsentLogs();
private:
- // Compresses staged_log_ and stores the result in
- // compressed_staged_log_text_.
+ // Compresses |staged_log_| and stores the result in
+ // |compressed_staged_xml_log_text_|.
void CompressStagedLog();
// Compresses the text in |input| using bzip2, store the result in |output|.
@@ -130,21 +138,25 @@ class MetricsLogManager {
// The log that we are currently transmiting, or about to try to transmit.
// Note that when using StageNextStoredLogForUpload, this can be NULL while
- // compressed_staged_log_text_ is non-NULL.
+ // |compressed_staged_xml_log_text_| is non-NULL.
scoped_ptr<MetricsLogBase> staged_log_;
// Helper class to handle serialization/deserialization of logs for persistent
// storage. May be NULL.
scoped_ptr<LogSerializer> log_serializer_;
- // The compressed text of the staged log, ready for upload to the server.
- std::string compressed_staged_log_text_;
+ // The text representations of the staged log, ready for upload to the server.
+ // The first item in the pair is the compressed XML representation; the second
+ // is the protobuf representation.
+ std::pair<std::string, std::string> staged_log_text_;
// Logs from a previous session that have not yet been sent.
+ // The first item in each pair is the XML representation; the second item is
+ // the protobuf representation.
// Note that the vector has the oldest logs listed first (early in the
// vector), and we'll discard old logs if we have gathered too many logs.
- std::vector<std::string> unsent_initial_logs_;
- std::vector<std::string> unsent_ongoing_logs_;
+ std::vector<std::pair<std::string, std::string> > unsent_initial_logs_;
jar (doing other things) 2012/02/23 01:59:18 IMO, you should use a tiny class or struct, and no
Ilya Sherman 2012/02/24 02:10:06 Done.
+ std::vector<std::pair<std::string, std::string> > unsent_ongoing_logs_;
size_t max_ongoing_log_store_size_;

Powered by Google App Engine
This is Rietveld 408576698