Chromium Code Reviews| Index: chrome/browser/feedback/feedback_data.h |
| diff --git a/chrome/browser/feedback/feedback_data.h b/chrome/browser/feedback/feedback_data.h |
| index ef54fffabe307206e9465502f17cb89712e8b89e..f8a91745e4f6c4bf8b604807bcb98677548e0955 100644 |
| --- a/chrome/browser/feedback/feedback_data.h |
| +++ b/chrome/browser/feedback/feedback_data.h |
| @@ -8,57 +8,49 @@ |
| #include <string> |
| #include <vector> |
| -#include "base/utf_string_conversions.h" |
| +#include "base/memory/ref_counted.h" |
| #include "chrome/browser/ui/webui/screenshot_source.h" |
| #if defined(OS_CHROMEOS) |
| -#include "chrome/browser/chromeos/system/syslogs_provider.h" |
| +#include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h" |
| #endif |
| class Profile; |
| -class FeedbackData { |
| +class FeedbackData : public base::RefCountedThreadSafe<FeedbackData> { |
| public: |
| FeedbackData(); |
| - FeedbackData(Profile* profile, |
| - const std::string& category_tag, |
| - const std::string& page_url, |
| - const std::string& description, |
| - const std::string& user_email, |
| - ScreenshotDataPtr image |
| -#if defined(OS_CHROMEOS) |
| - , chromeos::system::LogDictionaryType* sys_info |
| - , std::string* zip_content |
| - , const std::string& timestamp |
| - , const std::string& attached_filename |
| - , std::string* attached_filedata |
| -#endif |
| - ); |
| - |
| ~FeedbackData(); |
| - void SendReport(); |
| + // Called once we've update all the data from the feedback page. |
| + void FeedbackPageDataComplete(); |
| - void UpdateData(Profile* profile, |
| - const std::string& category_tag, |
| - const std::string& page_url, |
| - const std::string& description, |
| - const std::string& user_email, |
| - ScreenshotDataPtr image |
| #if defined(OS_CHROMEOS) |
| - , const bool send_sys_info |
| - , const bool sent_report |
| - , const std::string& timestamp |
| - , const std::string& attached_filename |
| - , std::string* attached_filedata |
| -#endif |
| - ); |
| + // Called once we have read our system logs. |
| + void SyslogsComplete(scoped_ptr<chromeos::SystemLogsResponse> sys_info); |
| -#if defined(OS_CHROMEOS) |
| - void SyslogsComplete(chromeos::system::LogDictionaryType* logs, |
| - std::string* zip_content); |
| + // Called once we have read our attached file. |
| + void ReadFileComplete(); |
| + |
| + // Starts the collection of our system logs. SyslogsComplete is called once |
| + // the collection is done. |
| + void StartSyslogsCollection(); |
| #endif |
| + // Returns true if we've complete collection of data from all our |
| + // data sources. At this time this involves the system logs, the attached |
| + // file (if needed to be read of the disk) and the rest of the data from |
| + // the feedback page. |
| + bool DataCollectionComplete(); |
| + |
| + // Sends the feedback report if we have all our data complete. |
| + void SendReport(); |
| + |
| + // Starts reading the file to attach to this report into the string |
| + // file_data. ReadFileComplete is called once this is done. |
| + void StartReadFile(const std::string filename, const std::string* file_data); |
| + |
| + // Getters |
| Profile* profile() const { return profile_; } |
| const std::string& category_tag() const { return category_tag_; } |
| const std::string& page_url() const { return page_url_; } |
| @@ -66,16 +58,50 @@ class FeedbackData { |
| const std::string& user_email() const { return user_email_; } |
| ScreenshotDataPtr image() const { return image_; } |
| #if defined(OS_CHROMEOS) |
| - chromeos::system::LogDictionaryType* sys_info() const { |
| - return send_sys_info_ ? sys_info_ : NULL; } |
| - std::string* zip_content() const { return zip_content_; } |
| + chromeos::SystemLogsResponse* sys_info() const { |
| + return send_sys_info_ ? sys_info_.get() : NULL; |
| + } |
| const std::string timestamp() const { return timestamp_; } |
| const std::string attached_filename() const { return attached_filename_; } |
| std::string* attached_filedata() const { return attached_filedata_; } |
| #endif |
| + // Setters |
| + void set_profile(Profile* profile) { profile_ = profile; } |
| + void set_category_tag(const std::string& category_tag) { |
| + category_tag_ = category_tag; |
| + } |
| + void set_page_url(const std::string& page_url) { page_url_ = page_url; } |
| + void set_description(const std::string& description) { |
| + description_ = description; |
| + } |
| + void set_user_email(const std::string& user_email) { |
| + user_email_ = user_email; |
| + } |
| + void set_image(ScreenshotDataPtr image) { image_ = image; } |
| +#if defined(OS_CHROMEOS) |
| + void set_send_sys_info(bool send_sys_info) { send_sys_info_ = send_sys_info; } |
| +/* void set_sys_info(chromeos::SystemLogsResponse* sys_info) { |
| + sys_info_ = sys_info; |
| + }*/ |
|
xiyuan
2013/03/18 23:55:52
Clean this up?
rkc
2013/03/19 00:09:02
Done.
|
| + void set_timestamp(const std::string& timestamp) { |
| + timestamp_ = timestamp; |
| + } |
| + void set_attached_filename(const std::string& attached_filename) { |
| + attached_filename_ = attached_filename; |
| + } |
| + void set_attached_filedata(std::string* attached_filedata) { |
| + attached_filedata_ = attached_filedata; |
| + } |
| +#endif |
| private: |
| + friend class base::RefCountedThreadSafe<FeedbackData>; |
| + |
| +#if defined(OS_CHROMEOS) |
| + void ReadAttachedFile(const base::FilePath& from); |
| +#endif |
| + |
| Profile* profile_; |
| std::string category_tag_; |
| @@ -88,23 +114,25 @@ class FeedbackData { |
| // Chromeos specific values for SendReport. Will be deleted in |
| // feedback_util::SendReport once consumed or in SyslogsComplete if |
| // we don't send the logs with the report. |
| - chromeos::system::LogDictionaryType* sys_info_; |
| + scoped_ptr<chromeos::SystemLogsResponse> sys_info_; |
| - // Content of the compressed system logs. Will be deleted in |
| - // feedback_util::SendReport once consumed or in SyslogsComplete if |
| - // we don't send the logs with the report. |
| - std::string* zip_content_; |
| std::string timestamp_; |
| std::string attached_filename_; |
| // Will be deleted in feedback_util::SendReport once consumed. |
| std::string* attached_filedata_; |
| - // NOTE: Extra boolean sent_report_ is required because callback may |
| - // occur before or after we call SendReport(). |
| - bool sent_report_; |
| - // Flag to indicate to SyslogsComplete that it should send the report |
| + // Flag to indicate whether or not we should send the system information |
| + // gathered with the report or not. |
| bool send_sys_info_; |
| + |
| + // Flags to indicate if various pieces of data needed for the report have |
| + // been collected yet or are still pending collection. |
| + bool syslogs_collection_complete_; |
| + bool read_attached_file_complete_; |
| #endif |
| + bool feedback_page_data_complete_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FeedbackData); |
| }; |
| #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_ |