Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_ | 5 #ifndef COMPONENTS_FEEDBACK_FEEDBACK_DATA_H_ |
| 6 #define CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_ | 6 #define COMPONENTS_FEEDBACK_FEEDBACK_DATA_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class FilePath; | 17 class FilePath; |
| 18 class RefCountedString; | 18 class RefCountedString; |
| 19 } | 19 } |
| 20 class Profile; | 20 namespace content { |
| 21 class BrowserContext; | |
| 22 } | |
| 21 | 23 |
| 22 class FeedbackData : public base::RefCountedThreadSafe<FeedbackData> { | 24 class FeedbackData : public base::RefCountedThreadSafe<FeedbackData> { |
|
jochen (gone - plz use gerrit)
2014/04/23 08:21:24
please put everything within the component into it
achaulk
2014/04/23 14:51:32
Done.
| |
| 23 public: | 25 public: |
| 24 typedef std::map<std::string, std::string> SystemLogsMap; | 26 typedef std::map<std::string, std::string> SystemLogsMap; |
| 25 | 27 |
| 26 // Determine if the given feedback value is small enough to not need to | 28 // Determine if the given feedback value is small enough to not need to |
| 27 // be compressed. | 29 // be compressed. |
| 28 static bool BelowCompressionThreshold(const std::string& content); | 30 static bool BelowCompressionThreshold(const std::string& content); |
| 29 | 31 |
| 30 FeedbackData(); | 32 FeedbackData(); |
| 31 | 33 |
| 32 // Called once we've updated all the data from the feedback page. | 34 // Called once we've updated all the data from the feedback page. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 55 | 57 |
| 56 // Returns true if we've completed all the tasks needed before we can send | 58 // Returns true if we've completed all the tasks needed before we can send |
| 57 // feedback - at this time this is includes getting the feedback page data | 59 // feedback - at this time this is includes getting the feedback page data |
| 58 // and compressing the system logs. | 60 // and compressing the system logs. |
| 59 bool IsDataComplete(); | 61 bool IsDataComplete(); |
| 60 | 62 |
| 61 // Sends the feedback report if we have all our data complete. | 63 // Sends the feedback report if we have all our data complete. |
| 62 void SendReport(); | 64 void SendReport(); |
| 63 | 65 |
| 64 // Getters | 66 // Getters |
| 65 Profile* profile() const { return profile_; } | 67 content::BrowserContext* context() const { return context_; } |
| 66 const std::string& category_tag() const { return category_tag_; } | 68 const std::string& category_tag() const { return category_tag_; } |
| 67 const std::string& page_url() const { return page_url_; } | 69 const std::string& page_url() const { return page_url_; } |
| 68 const std::string& description() const { return description_; } | 70 const std::string& description() const { return description_; } |
| 69 const std::string& user_email() const { return user_email_; } | 71 const std::string& user_email() const { return user_email_; } |
| 70 std::string* image() const { return image_.get(); } | 72 std::string* image() const { return image_.get(); } |
| 71 const std::string attached_filename() const { return attached_filename_; } | 73 const std::string attached_filename() const { return attached_filename_; } |
| 72 const std::string attached_file_uuid() const { return attached_file_uuid_; } | 74 const std::string attached_file_uuid() const { return attached_file_uuid_; } |
| 73 std::string* attached_filedata() const { return attached_filedata_.get(); } | 75 std::string* attached_filedata() const { return attached_filedata_.get(); } |
| 74 const std::string screenshot_uuid() const { return screenshot_uuid_; } | 76 const std::string screenshot_uuid() const { return screenshot_uuid_; } |
| 75 int trace_id() const { return trace_id_; } | 77 int trace_id() const { return trace_id_; } |
| 76 SystemLogsMap* sys_info() const { return sys_info_.get(); } | 78 SystemLogsMap* sys_info() const { return sys_info_.get(); } |
| 77 std::string* compressed_logs() const { return compressed_logs_.get(); } | 79 std::string* compressed_logs() const { return compressed_logs_.get(); } |
| 78 std::string* histograms() const { return histograms_.get(); } | 80 std::string* histograms() const { return histograms_.get(); } |
| 79 std::string* compressed_histograms() const { | 81 std::string* compressed_histograms() const { |
| 80 return compressed_histograms_.get(); | 82 return compressed_histograms_.get(); |
| 81 } | 83 } |
| 84 std::string user_agent() const { return user_agent_; } | |
| 85 std::string locale() const { return locale_; } | |
| 82 | 86 |
| 83 // Setters | 87 // Setters |
| 84 void set_profile(Profile* profile) { profile_ = profile; } | 88 void set_context(content::BrowserContext* context) { context_ = context; } |
| 85 void set_category_tag(const std::string& category_tag) { | 89 void set_category_tag(const std::string& category_tag) { |
| 86 category_tag_ = category_tag; | 90 category_tag_ = category_tag; |
| 87 } | 91 } |
| 88 void set_page_url(const std::string& page_url) { page_url_ = page_url; } | 92 void set_page_url(const std::string& page_url) { page_url_ = page_url; } |
| 89 void set_description(const std::string& description) { | 93 void set_description(const std::string& description) { |
| 90 description_ = description; | 94 description_ = description; |
| 91 } | 95 } |
| 92 void set_user_email(const std::string& user_email) { | 96 void set_user_email(const std::string& user_email) { |
| 93 user_email_ = user_email; | 97 user_email_ = user_email; |
| 94 } | 98 } |
| 95 void set_image(scoped_ptr<std::string> image) { image_ = image.Pass(); } | 99 void set_image(scoped_ptr<std::string> image) { image_ = image.Pass(); } |
| 96 void set_attached_filename(const std::string& attached_filename) { | 100 void set_attached_filename(const std::string& attached_filename) { |
| 97 attached_filename_ = attached_filename; | 101 attached_filename_ = attached_filename; |
| 98 } | 102 } |
| 99 void set_attached_file_uuid(const std::string& uuid) { | 103 void set_attached_file_uuid(const std::string& uuid) { |
| 100 attached_file_uuid_ = uuid; | 104 attached_file_uuid_ = uuid; |
| 101 } | 105 } |
| 102 void set_screenshot_uuid(const std::string& uuid) { | 106 void set_screenshot_uuid(const std::string& uuid) { |
| 103 screenshot_uuid_ = uuid; | 107 screenshot_uuid_ = uuid; |
| 104 } | 108 } |
| 105 void set_trace_id(int trace_id) { trace_id_ = trace_id; } | 109 void set_trace_id(int trace_id) { trace_id_ = trace_id; } |
| 110 void set_user_agent(const std::string& user_agent) { | |
| 111 user_agent_ = user_agent; | |
| 112 } | |
| 113 void set_locale(const std::string& locale) { locale_ = locale; } | |
| 106 | 114 |
| 107 private: | 115 private: |
| 108 friend class base::RefCountedThreadSafe<FeedbackData>; | 116 friend class base::RefCountedThreadSafe<FeedbackData>; |
| 109 | 117 |
| 110 virtual ~FeedbackData(); | 118 virtual ~FeedbackData(); |
| 111 | 119 |
| 112 void OnGetTraceData(int trace_id, | 120 void OnGetTraceData(int trace_id, |
| 113 scoped_refptr<base::RefCountedString> trace_data); | 121 scoped_refptr<base::RefCountedString> trace_data); |
| 114 | 122 |
| 115 Profile* profile_; | 123 content::BrowserContext* context_; |
| 116 | 124 |
| 117 std::string category_tag_; | 125 std::string category_tag_; |
| 118 std::string page_url_; | 126 std::string page_url_; |
| 119 std::string description_; | 127 std::string description_; |
| 120 std::string user_email_; | 128 std::string user_email_; |
| 121 scoped_ptr<std::string> image_; | 129 scoped_ptr<std::string> image_; |
| 122 std::string attached_filename_; | 130 std::string attached_filename_; |
| 123 scoped_ptr<std::string> attached_filedata_; | 131 scoped_ptr<std::string> attached_filedata_; |
| 132 std::string user_agent_; | |
| 133 std::string locale_; | |
| 124 | 134 |
| 125 std::string attached_file_uuid_; | 135 std::string attached_file_uuid_; |
| 126 std::string screenshot_uuid_; | 136 std::string screenshot_uuid_; |
| 127 | 137 |
| 128 int trace_id_; | 138 int trace_id_; |
| 129 | 139 |
| 130 scoped_ptr<SystemLogsMap> sys_info_; | 140 scoped_ptr<SystemLogsMap> sys_info_; |
| 131 scoped_ptr<std::string> compressed_logs_; | 141 scoped_ptr<std::string> compressed_logs_; |
| 132 | 142 |
| 133 scoped_ptr<std::string> histograms_; | 143 scoped_ptr<std::string> histograms_; |
| 134 scoped_ptr<std::string> compressed_histograms_; | 144 scoped_ptr<std::string> compressed_histograms_; |
| 135 | 145 |
| 136 // TODO(rkc): Refactor compressing logic into a simpler common implementation. | 146 // TODO(rkc): Refactor compressing logic into a simpler common implementation. |
| 137 bool feedback_page_data_complete_; | 147 bool feedback_page_data_complete_; |
| 138 bool syslogs_compression_complete_; | 148 bool syslogs_compression_complete_; |
| 139 bool histograms_compression_complete_; | 149 bool histograms_compression_complete_; |
| 140 bool attached_file_compression_complete_; | 150 bool attached_file_compression_complete_; |
| 141 bool report_sent_; | 151 bool report_sent_; |
| 142 | 152 |
| 143 DISALLOW_COPY_AND_ASSIGN(FeedbackData); | 153 DISALLOW_COPY_AND_ASSIGN(FeedbackData); |
| 144 }; | 154 }; |
| 145 | 155 |
| 146 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_ | 156 #endif // COMPONENTS_FEEDBACK_FEEDBACK_DATA_H_ |
| OLD | NEW |