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

Side by Side Diff: chrome/common/metrics/metrics_log_manager.h

Issue 10546044: [Metrics] Re-try failed protocol buffer uploads as well as failed XML uploads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 #ifndef CHROME_COMMON_METRICS_METRICS_LOG_MANAGER_H_ 5 #ifndef CHROME_COMMON_METRICS_METRICS_LOG_MANAGER_H_
6 #define CHROME_COMMON_METRICS_METRICS_LOG_MANAGER_H_ 6 #define CHROME_COMMON_METRICS_METRICS_LOG_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // Populates staged_log_text() with the next stored log to send. 64 // Populates staged_log_text() with the next stored log to send.
65 // Should only be called if has_unsent_logs() is true. 65 // Should only be called if has_unsent_logs() is true.
66 void StageNextLogForUpload(); 66 void StageNextLogForUpload();
67 67
68 // Returns true if there is a log that needs to be, or is being, uploaded. 68 // Returns true if there is a log that needs to be, or is being, uploaded.
69 bool has_staged_log() const; 69 bool has_staged_log() const;
70 70
71 // Returns true if there is a protobuf log that needs to be uploaded. 71 // Returns true if there is a protobuf log that needs to be uploaded.
72 // In the case that an XML upload needs to be re-issued due to a previous 72 // In the case that an XML upload needs to be re-issued due to a previous
73 // failure, has_staged_log() will return true while this returns false. 73 // failure, has_staged_log() can return true while this returns false.
74 bool has_staged_log_proto() const; 74 bool has_staged_log_proto() const;
75 75
76 // Returns true if there is an xml log that needs to be uploaded.
77 // In the case that a protobuf upload needs to be re-issued due to a previous
78 // failure, has_staged_log() can return true while this returns false.
79 bool has_staged_log_xml() const;
80
76 // The text of the staged log, in compressed XML or protobuf format. Empty if 81 // The text of the staged log, in compressed XML or protobuf format. Empty if
77 // there is no staged log, or if compression of the staged log failed. 82 // there is no staged log, or if compression of the staged log failed.
78 const SerializedLog& staged_log_text() const { 83 const SerializedLog& staged_log_text() const {
79 return staged_log_text_; 84 return staged_log_text_;
80 } 85 }
81 86
82 // Discards the staged log (both the XML and the protobuf data).
83 void DiscardStagedLog();
84
85 // Discards the protobuf data in the staged log. 87 // Discards the protobuf data in the staged log.
86 // This is useful to prevent needlessly re-issuing successful protobuf uploads 88 // This is useful to prevent needlessly re-issuing successful protobuf uploads
87 // due to XML upload failures. 89 // due to XML upload failures.
88 void DiscardStagedLogProto(); 90 void DiscardStagedLogProto();
89 91
92 // Discards the XML data in the staged log.
93 // This is useful to prevent needlessly re-issuing successful XML uploads
94 // due to protobuf upload failures.
95 void DiscardStagedLogXml();
96
90 // Closes and discards |current_log|. 97 // Closes and discards |current_log|.
91 void DiscardCurrentLog(); 98 void DiscardCurrentLog();
92 99
93 // Sets current_log to NULL, but saves the current log for future use with 100 // Sets current_log to NULL, but saves the current log for future use with
94 // ResumePausedLog(). Only one log may be paused at a time. 101 // ResumePausedLog(). Only one log may be paused at a time.
95 // TODO(stuartmorgan): Pause/resume support is really a workaround for a 102 // TODO(stuartmorgan): Pause/resume support is really a workaround for a
96 // design issue in initial log writing; that should be fixed, and pause/resume 103 // design issue in initial log writing; that should be fixed, and pause/resume
97 // removed. 104 // removed.
98 void PauseCurrentLog(); 105 void PauseCurrentLog();
99 106
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // |max_ongoing_log_store_size_|). 165 // |max_ongoing_log_store_size_|).
159 // NOTE: This clears the contents of |log_text| (to avoid an expensive 166 // NOTE: This clears the contents of |log_text| (to avoid an expensive
160 // string copy), so the log should be discarded after this call. 167 // string copy), so the log should be discarded after this call.
161 void StoreLog(SerializedLog* log_text, 168 void StoreLog(SerializedLog* log_text,
162 LogType log_type, 169 LogType log_type,
163 StoreType store_type); 170 StoreType store_type);
164 171
165 // Compresses current_log_ into compressed_log. 172 // Compresses current_log_ into compressed_log.
166 void CompressCurrentLog(SerializedLog* compressed_log); 173 void CompressCurrentLog(SerializedLog* compressed_log);
167 174
175 // Discards the staged log (both the XML and the protobuf data).
176 void DiscardStagedLog();
177
168 // Compresses the text in |input| using bzip2, store the result in |output|. 178 // Compresses the text in |input| using bzip2, store the result in |output|.
169 static bool Bzip2Compress(const std::string& input, std::string* output); 179 static bool Bzip2Compress(const std::string& input, std::string* output);
170 180
171 // The log that we are still appending to. 181 // The log that we are still appending to.
172 scoped_ptr<MetricsLogBase> current_log_; 182 scoped_ptr<MetricsLogBase> current_log_;
173 LogType current_log_type_; 183 LogType current_log_type_;
174 184
175 // A paused, previously-current log. 185 // A paused, previously-current log.
176 scoped_ptr<MetricsLogBase> paused_log_; 186 scoped_ptr<MetricsLogBase> paused_log_;
177 LogType paused_log_type_; 187 LogType paused_log_type_;
(...skipping 24 matching lines...) Expand all
202 // This is necessary because during an upload there are two logs (staged 212 // This is necessary because during an upload there are two logs (staged
203 // and current) and a client might store them in either order, so it's 213 // and current) and a client might store them in either order, so it's
204 // not necessarily the case that the provisional store is the last store. 214 // not necessarily the case that the provisional store is the last store.
205 int last_provisional_store_index_; 215 int last_provisional_store_index_;
206 LogType last_provisional_store_type_; 216 LogType last_provisional_store_type_;
207 217
208 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager); 218 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager);
209 }; 219 };
210 220
211 #endif // CHROME_COMMON_METRICS_METRICS_LOG_MANAGER_H_ 221 #endif // CHROME_COMMON_METRICS_METRICS_LOG_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698