Chromium Code Reviews| Index: components/feedback/feedback_common.h |
| diff --git a/components/feedback/feedback_common.h b/components/feedback/feedback_common.h |
| index 7c6d56da19e5063843cf083f32fc029443c1a1bb..2f4016e956852b020f4843deb8319c1c69a717b0 100644 |
| --- a/components/feedback/feedback_common.h |
| +++ b/components/feedback/feedback_common.h |
| @@ -12,27 +12,21 @@ |
| #include <memory> |
| #include <string> |
| #include <utility> |
| +#include <vector> |
| #include "base/files/file_util.h" |
| #include "base/memory/ref_counted.h" |
| -#include "base/memory/scoped_vector.h" |
| #include "base/synchronization/lock.h" |
| namespace userfeedback { |
| class ExtensionSubmit; |
| } |
| -namespace feedback_util { |
| -bool ZipString(const base::FilePath& filename, |
| - const std::string& data, |
| - std::string* compressed_data); |
| -} |
| - |
| // This is the base class for FeedbackData. It primarily knows about |
| // data common to all feedback reports and how to zip things. |
| class FeedbackCommon : public base::RefCountedThreadSafe<FeedbackCommon> { |
| public: |
| - typedef std::map<std::string, std::string> SystemLogsMap; |
| + using SystemLogsMap = std::map<std::string, std::string>; |
| struct AttachedFile { |
| explicit AttachedFile(const std::string& filename, |
| @@ -43,23 +37,12 @@ class FeedbackCommon : public base::RefCountedThreadSafe<FeedbackCommon> { |
| std::unique_ptr<std::string> data; |
| }; |
| - // Determine if the given feedback value is small enough to not need to |
| - // be compressed. |
| - static bool BelowCompressionThreshold(const std::string& content); |
|
afakhry
2016/08/05 22:50:52
Moved to anonymous namespace.
|
| - |
| FeedbackCommon(); |
| - void CompressFile(const base::FilePath& filename, |
|
afakhry
2016/08/05 22:50:53
Moved to protected.
|
| - const std::string& zipname, |
| - std::unique_ptr<std::string> data); |
| void AddFile(const std::string& filename, std::unique_ptr<std::string> data); |
| void AddLog(const std::string& name, const std::string& value); |
| void AddLogs(std::unique_ptr<SystemLogsMap> logs); |
| - void CompressLogs(); |
|
afakhry
2016/08/05 22:50:52
Moved to protected.
|
| - |
| - void AddFilesAndLogsToReport( |
| - userfeedback::ExtensionSubmit* feedback_data) const; |
|
afakhry
2016/08/05 22:50:52
Moved to private.
|
| // Fill in |feedback_data| with all the data that we have collected. |
| // CompressLogs() must have already been called. |
| @@ -76,7 +59,9 @@ class FeedbackCommon : public base::RefCountedThreadSafe<FeedbackCommon> { |
| std::string user_agent() const { return user_agent_; } |
| std::string locale() const { return locale_; } |
| - const AttachedFile* attachment(size_t i) const { return attachments_[i]; } |
| + const AttachedFile* attachment(size_t i) const { |
| + return attachments_[i].get(); |
| + } |
| size_t attachments() const { return attachments_.size(); } |
| // Setters |
| @@ -102,10 +87,22 @@ class FeedbackCommon : public base::RefCountedThreadSafe<FeedbackCommon> { |
| protected: |
| virtual ~FeedbackCommon(); |
| + // Compresses the |data_to_be_compressed| to an attachment file to this |
| + // feedback data with name |zipname|. If |zipname| is empty, the |filename| |
| + // 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); |
| + |
| + void CompressLogs(); |
| + |
| private: |
| friend class base::RefCountedThreadSafe<FeedbackCommon>; |
| friend class FeedbackCommonTest; |
| + void AddFilesAndLogsToReport( |
| + userfeedback::ExtensionSubmit* feedback_data) const; |
| + |
| // Returns true if a product ID was set in the feedback report. |
| bool HasProductId() const { return product_id_ != -1; } |
| @@ -122,7 +119,7 @@ class FeedbackCommon : public base::RefCountedThreadSafe<FeedbackCommon> { |
| // It is possible that multiple attachment add calls are running in |
| // parallel, so synchronize access. |
| base::Lock attachments_lock_; |
| - ScopedVector<AttachedFile> attachments_; |
| + std::vector<std::unique_ptr<AttachedFile>> attachments_; |
| std::unique_ptr<SystemLogsMap> logs_; |
| }; |