Index: chrome/browser/feedback/feedback_util.cc |
diff --git a/chrome/browser/feedback/feedback_util.cc b/chrome/browser/feedback/feedback_util.cc |
index 43b13df8aa0a012813983ca35130da884549b965..0953c8d5807aba93577177db08d784b7c8340c2e 100644 |
--- a/chrome/browser/feedback/feedback_util.cc |
+++ b/chrome/browser/feedback/feedback_util.cc |
@@ -92,6 +92,7 @@ const int64 kRetryDelayIncreaseFactor = 2; |
const int64 kRetryDelayLimit = 14400000; // 4 hours |
const char kArbitraryMimeType[] = "application/octet-stream"; |
+const char kHistogramsAttachmentName[] = "histograms.zip"; |
const char kLogsAttachmentName[] = "system_logs.zip"; |
#if defined(OS_CHROMEOS) |
@@ -217,6 +218,20 @@ void AddFeedbackData(userfeedback::ExtensionSubmit* feedback_data, |
*(web_data->add_product_specific_data()) = log_value; |
} |
+// Adds data as an attachment to feedback_data if the data is non-empty. |
+void AddAttachment(userfeedback::ExtensionSubmit* feedback_data, |
+ const char* name, |
+ std::string* data) { |
+ if (data == NULL || data->empty()) |
+ return; |
+ |
+ userfeedback::ProductSpecificBinaryData attachment; |
+ attachment.set_mime_type(kArbitraryMimeType); |
+ attachment.set_name(name); |
+ attachment.set_data(*data); |
+ *(feedback_data->add_product_specific_binary_data()) = attachment; |
+} |
+ |
} // namespace |
namespace chrome { |
@@ -288,27 +303,21 @@ void SendReport(scoped_refptr<FeedbackData> data) { |
AddFeedbackData(&feedback_data, i->first, i->second); |
} |
- if (data->compressed_logs() && data->compressed_logs()->size()) { |
- userfeedback::ProductSpecificBinaryData attachment; |
- attachment.set_mime_type(kArbitraryMimeType); |
- attachment.set_name(kLogsAttachmentName); |
- attachment.set_data(*(data->compressed_logs())); |
- *(feedback_data.add_product_specific_binary_data()) = attachment; |
- } |
+ AddAttachment(&feedback_data, kLogsAttachmentName, data->compressed_logs()); |
+ } |
+ |
+ if (!data->histograms().empty()) { |
+ AddAttachment(&feedback_data, |
+ kHistogramsAttachmentName, |
+ data->compressed_histograms()); |
} |
- if (!data->attached_filename().empty() && |
- data->attached_filedata() && |
- !data->attached_filedata()->empty()) { |
- userfeedback::ProductSpecificBinaryData attached_file; |
- attached_file.set_mime_type(kArbitraryMimeType); |
+ if (!data->attached_filename().empty()) { |
// We need to use the UTF8Unsafe methods here to accomodate Windows, which |
// uses wide strings to store filepaths. |
std::string name = base::FilePath::FromUTF8Unsafe( |
data->attached_filename()).BaseName().AsUTF8Unsafe(); |
- attached_file.set_name(name); |
- attached_file.set_data(*data->attached_filedata()); |
- *(feedback_data.add_product_specific_binary_data()) = attached_file; |
+ AddAttachment(&feedback_data, name.c_str(), data->attached_filedata()); |
} |
// NOTE: Screenshot needs to be processed after system info since we'll get |