feedback: get rid of needless use of unique_ptr
unique_ptr was being used in a lot of places where it's not needed.
BUG=None
TEST=Ensure feedback reporting still works
Change-Id: Ic6e0007cf3d3c3e4aad6ebd265dd441e6772a573
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1550018
Reviewed-by: Ahmed Fakhry <[email protected]>
Commit-Queue: Chris Morin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#647423}
diff --git a/components/feedback/feedback_common.h b/components/feedback/feedback_common.h
index 2f4016e..f7e382a8 100644
--- a/components/feedback/feedback_common.h
+++ b/components/feedback/feedback_common.h
@@ -29,20 +29,19 @@
using SystemLogsMap = std::map<std::string, std::string>;
struct AttachedFile {
- explicit AttachedFile(const std::string& filename,
- std::unique_ptr<std::string> data);
+ explicit AttachedFile(const std::string& filename, std::string data);
~AttachedFile();
std::string name;
- std::unique_ptr<std::string> data;
+ std::string data;
};
FeedbackCommon();
- void AddFile(const std::string& filename, std::unique_ptr<std::string> data);
+ void AddFile(const std::string& filename, std::string data);
void AddLog(const std::string& name, const std::string& value);
- void AddLogs(std::unique_ptr<SystemLogsMap> logs);
+ void AddLogs(SystemLogsMap logs);
// Fill in |feedback_data| with all the data that we have collected.
// CompressLogs() must have already been called.
@@ -53,15 +52,13 @@
const std::string& page_url() const { return page_url_; }
const std::string& description() const { return description_; }
const std::string& user_email() const { return user_email_; }
- const std::string* image() const { return image_.get(); }
- const SystemLogsMap* sys_info() const { return logs_.get(); }
+ const std::string& image() const { return image_; }
+ const SystemLogsMap* sys_info() const { return &logs_; }
int32_t product_id() const { return product_id_; }
std::string user_agent() const { return user_agent_; }
std::string locale() const { return locale_; }
- const AttachedFile* attachment(size_t i) const {
- return attachments_[i].get();
- }
+ const AttachedFile* attachment(size_t i) const { return &attachments_[i]; }
size_t attachments() const { return attachments_.size(); }
// Setters
@@ -75,9 +72,7 @@
void set_user_email(const std::string& user_email) {
user_email_ = user_email;
}
- void set_image(std::unique_ptr<std::string> image) {
- image_ = std::move(image);
- }
+ void set_image(std::string image) { image_ = std::move(image); }
void set_product_id(int32_t product_id) { product_id_ = product_id; }
void set_user_agent(const std::string& user_agent) {
user_agent_ = user_agent;
@@ -92,7 +87,7 @@
// will be used and appended a ".zip" extension.
void CompressFile(const base::FilePath& filename,
const std::string& zipname,
- std::unique_ptr<std::string> data_to_be_compressed);
+ std::string data_to_be_compressed);
void CompressLogs();
@@ -114,14 +109,14 @@
std::string user_agent_;
std::string locale_;
- std::unique_ptr<std::string> image_;
+ std::string image_;
// It is possible that multiple attachment add calls are running in
// parallel, so synchronize access.
base::Lock attachments_lock_;
- std::vector<std::unique_ptr<AttachedFile>> attachments_;
+ std::vector<AttachedFile> attachments_;
- std::unique_ptr<SystemLogsMap> logs_;
+ SystemLogsMap logs_;
};
#endif // COMPONENTS_FEEDBACK_FEEDBACK_COMMON_H_