Commit 36089802 authored by Olivier Robin's avatar Olivier Robin Committed by Commit Bot

Restore reverse order when parsing UploadList.

Before crrev/c/1460065, TextLogUploadList::ParseLogEntries returned a
list of entries in reverse order.
After this cl it is in the normal order.

Because new crash upload are appended to the log file, the order in the
source is oldest report first.
The result is that crash reports were displayed in older first order,
at least on iOS and Android.

This CL restores the correct order of chrome://crashes which is
showing newer crash uploaded first.

Bug: 825994, 951449
Change-Id: Ib00d1f491773fbb3675e3a1927d36b75588c9401
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1571406
Commit-Queue: Bret Sepulveda <bsep@chromium.org>
Auto-Submit: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652227}
parent 2ab5fe79
...@@ -97,7 +97,9 @@ void TextLogUploadList::ClearUploadList(const base::Time& begin, ...@@ -97,7 +97,9 @@ void TextLogUploadList::ClearUploadList(const base::Time& begin,
void TextLogUploadList::ParseLogEntries( void TextLogUploadList::ParseLogEntries(
const std::vector<std::string>& log_entries, const std::vector<std::string>& log_entries,
std::vector<UploadInfo>* uploads) { std::vector<UploadInfo>* uploads) {
for (const std::string& line : log_entries) { std::vector<std::string>::const_reverse_iterator i;
for (i = log_entries.rbegin(); i != log_entries.rend(); ++i) {
const std::string& line = *i;
std::vector<std::string> components = SplitIntoComponents(line); std::vector<std::string> components = SplitIntoComponents(line);
// Skip any blank (or corrupted) lines. // Skip any blank (or corrupted) lines.
if (components.size() < 2 || components.size() > 5) if (components.size() < 2 || components.size() > 5)
......
...@@ -35,6 +35,8 @@ class TextLogUploadList : public UploadList { ...@@ -35,6 +35,8 @@ class TextLogUploadList : public UploadList {
void ClearUploadList(const base::Time& begin, const base::Time& end) override; void ClearUploadList(const base::Time& begin, const base::Time& end) override;
// Parses upload log lines, converting them to UploadInfo entries. // Parses upload log lines, converting them to UploadInfo entries.
// The method also reverse the order of the entries (the first entry in
// |uploads| is the last in |log_entries|).
void ParseLogEntries(const std::vector<std::string>& log_entries, void ParseLogEntries(const std::vector<std::string>& log_entries,
std::vector<UploadInfo>* uploads); std::vector<UploadInfo>* uploads);
......
...@@ -209,7 +209,7 @@ TEST_F(TextLogUploadListTest, ParseMultipleEntries) { ...@@ -209,7 +209,7 @@ TEST_F(TextLogUploadListTest, ParseMultipleEntries) {
test_entry += ","; test_entry += ",";
test_entry.append(kTestUploadId); test_entry.append(kTestUploadId);
test_entry += ","; test_entry += ",";
test_entry.append(kTestLocalID); test_entry.append(base::NumberToString(i));
test_entry += ","; test_entry += ",";
test_entry.append(kTestCaptureTime); test_entry.append(kTestCaptureTime);
test_entry += "\n"; test_entry += "\n";
...@@ -227,11 +227,12 @@ TEST_F(TextLogUploadListTest, ParseMultipleEntries) { ...@@ -227,11 +227,12 @@ TEST_F(TextLogUploadListTest, ParseMultipleEntries) {
upload_list->GetUploads(999, &uploads); upload_list->GetUploads(999, &uploads);
EXPECT_EQ(4u, uploads.size()); EXPECT_EQ(4u, uploads.size());
// The entries order should be reversed during the parsing.
for (size_t i = 0; i < uploads.size(); ++i) { for (size_t i = 0; i < uploads.size(); ++i) {
double time_double = uploads[i].upload_time.ToDoubleT(); double time_double = uploads[i].upload_time.ToDoubleT();
EXPECT_STREQ(kTestUploadTime, base::NumberToString(time_double).c_str()); EXPECT_STREQ(kTestUploadTime, base::NumberToString(time_double).c_str());
EXPECT_STREQ(kTestUploadId, uploads[i].upload_id.c_str()); EXPECT_STREQ(kTestUploadId, uploads[i].upload_id.c_str());
EXPECT_STREQ(kTestLocalID, uploads[i].local_id.c_str()); EXPECT_EQ(base::NumberToString(uploads.size() - i), uploads[i].local_id);
time_double = uploads[i].capture_time.ToDoubleT(); time_double = uploads[i].capture_time.ToDoubleT();
EXPECT_STREQ(kTestCaptureTime, base::NumberToString(time_double).c_str()); EXPECT_STREQ(kTestCaptureTime, base::NumberToString(time_double).c_str());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment