Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(849)

Side by Side Diff: chrome/browser/feedback/feedback_data.h

Issue 12529024: Fix feedback log collection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_
6 #define CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_ 6 #define CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/utf_string_conversions.h" 11 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/ui/webui/screenshot_source.h" 12 #include "chrome/browser/ui/webui/screenshot_source.h"
13 13
14 #if defined(OS_CHROMEOS) 14 #if defined(OS_CHROMEOS)
15 #include "chrome/browser/chromeos/system/syslogs_provider.h" 15 #include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h"
16 #endif 16 #endif
17 17
18 class Profile; 18 class Profile;
19 19
20 class FeedbackData { 20 class FeedbackData : public base::RefCountedThreadSafe<FeedbackData> {
21 public: 21 public:
22 FeedbackData(); 22 FeedbackData();
23 FeedbackData(Profile* profile,
24 const std::string& category_tag,
25 const std::string& page_url,
26 const std::string& description,
27 const std::string& user_email,
28 ScreenshotDataPtr image
29 #if defined(OS_CHROMEOS)
30 , chromeos::system::LogDictionaryType* sys_info
31 , std::string* zip_content
32 , const std::string& timestamp
33 , const std::string& attached_filename
34 , std::string* attached_filedata
35 #endif
36 );
37
38 ~FeedbackData(); 23 ~FeedbackData();
39 24
25 // Called once we've update all the data from the feedback page.
26 void FeedbackPageDataComplete();
27
28 #if defined(OS_CHROMEOS)
29 // Called once we have read our system logs.
30 void SyslogsComplete(scoped_ptr<chromeos::SystemLogsResponse> sys_info);
31
32 // Called once we have read our attached file.
33 void ReadFileComplete();
34
35 // Starts the collection of our system logs. SyslogsComplete is called once
36 // the collection is done.
37 void StartSyslogsCollection();
38 #endif
39
40 // Returns true if we've complete collection of data from all our
41 // data sources. At this time this involves the system logs, the attached
42 // file (if needed to be read of the disk) and the rest of the data from
43 // the feedback page.
44 bool DataCollectionComplete();
45
46 // Sends the feedback report if we have all our data complete.
40 void SendReport(); 47 void SendReport();
41 48
42 void UpdateData(Profile* profile, 49 // Starts reading the file to attach to this report into the string
43 const std::string& category_tag, 50 // file_data. ReadFileComplete is called once this is done.
44 const std::string& page_url, 51 void StartReadFile(const std::string filename, const std::string* file_data);
45 const std::string& description,
46 const std::string& user_email,
47 ScreenshotDataPtr image
48 #if defined(OS_CHROMEOS)
49 , const bool send_sys_info
50 , const bool sent_report
51 , const std::string& timestamp
52 , const std::string& attached_filename
53 , std::string* attached_filedata
54 #endif
55 );
56 52
57 #if defined(OS_CHROMEOS) 53 // Getters
58 void SyslogsComplete(chromeos::system::LogDictionaryType* logs,
59 std::string* zip_content);
60 #endif
61
62 Profile* profile() const { return profile_; } 54 Profile* profile() const { return profile_; }
63 const std::string& category_tag() const { return category_tag_; } 55 const std::string& category_tag() const { return category_tag_; }
64 const std::string& page_url() const { return page_url_; } 56 const std::string& page_url() const { return page_url_; }
65 const std::string& description() const { return description_; } 57 const std::string& description() const { return description_; }
66 const std::string& user_email() const { return user_email_; } 58 const std::string& user_email() const { return user_email_; }
67 ScreenshotDataPtr image() const { return image_; } 59 ScreenshotDataPtr image() const { return image_; }
68 #if defined(OS_CHROMEOS) 60 #if defined(OS_CHROMEOS)
69 chromeos::system::LogDictionaryType* sys_info() const { 61 chromeos::SystemLogsResponse* sys_info() const {
70 return send_sys_info_ ? sys_info_ : NULL; } 62 return send_sys_info_ ? sys_info_.get() : NULL;
71 std::string* zip_content() const { return zip_content_; } 63 }
72 const std::string timestamp() const { return timestamp_; } 64 const std::string timestamp() const { return timestamp_; }
73 const std::string attached_filename() const { return attached_filename_; } 65 const std::string attached_filename() const { return attached_filename_; }
74 std::string* attached_filedata() const { return attached_filedata_; } 66 std::string* attached_filedata() const { return attached_filedata_; }
75 #endif 67 #endif
76 68
69 // Setters
70 void set_profile(Profile* profile) { profile_ = profile; }
71 void set_category_tag(const std::string& category_tag) {
72 category_tag_ = category_tag;
73 }
74 void set_page_url(const std::string& page_url) { page_url_ = page_url; }
75 void set_description(const std::string& description) {
76 description_ = description;
77 }
78 void set_user_email(const std::string& user_email) {
79 user_email_ = user_email;
80 }
81 void set_image(ScreenshotDataPtr image) { image_ = image; }
82 #if defined(OS_CHROMEOS)
83 void set_send_sys_info(bool send_sys_info) { send_sys_info_ = send_sys_info; }
84 /* void set_sys_info(chromeos::SystemLogsResponse* sys_info) {
85 sys_info_ = sys_info;
86 }*/
xiyuan 2013/03/18 23:55:52 Clean this up?
rkc 2013/03/19 00:09:02 Done.
87 void set_timestamp(const std::string& timestamp) {
88 timestamp_ = timestamp;
89 }
90 void set_attached_filename(const std::string& attached_filename) {
91 attached_filename_ = attached_filename;
92 }
93 void set_attached_filedata(std::string* attached_filedata) {
94 attached_filedata_ = attached_filedata;
95 }
96 #endif
77 97
78 private: 98 private:
99 friend class base::RefCountedThreadSafe<FeedbackData>;
100
101 #if defined(OS_CHROMEOS)
102 void ReadAttachedFile(const base::FilePath& from);
103 #endif
104
79 Profile* profile_; 105 Profile* profile_;
80 106
81 std::string category_tag_; 107 std::string category_tag_;
82 std::string page_url_; 108 std::string page_url_;
83 std::string description_; 109 std::string description_;
84 std::string user_email_; 110 std::string user_email_;
85 ScreenshotDataPtr image_; 111 ScreenshotDataPtr image_;
86 112
87 #if defined(OS_CHROMEOS) 113 #if defined(OS_CHROMEOS)
88 // Chromeos specific values for SendReport. Will be deleted in 114 // Chromeos specific values for SendReport. Will be deleted in
89 // feedback_util::SendReport once consumed or in SyslogsComplete if 115 // feedback_util::SendReport once consumed or in SyslogsComplete if
90 // we don't send the logs with the report. 116 // we don't send the logs with the report.
91 chromeos::system::LogDictionaryType* sys_info_; 117 scoped_ptr<chromeos::SystemLogsResponse> sys_info_;
92 118
93 // Content of the compressed system logs. Will be deleted in
94 // feedback_util::SendReport once consumed or in SyslogsComplete if
95 // we don't send the logs with the report.
96 std::string* zip_content_;
97 std::string timestamp_; 119 std::string timestamp_;
98 std::string attached_filename_; 120 std::string attached_filename_;
99 // Will be deleted in feedback_util::SendReport once consumed. 121 // Will be deleted in feedback_util::SendReport once consumed.
100 std::string* attached_filedata_; 122 std::string* attached_filedata_;
101 123
102 // NOTE: Extra boolean sent_report_ is required because callback may 124 // Flag to indicate whether or not we should send the system information
103 // occur before or after we call SendReport(). 125 // gathered with the report or not.
104 bool sent_report_;
105 // Flag to indicate to SyslogsComplete that it should send the report
106 bool send_sys_info_; 126 bool send_sys_info_;
127
128 // Flags to indicate if various pieces of data needed for the report have
129 // been collected yet or are still pending collection.
130 bool syslogs_collection_complete_;
131 bool read_attached_file_complete_;
107 #endif 132 #endif
133 bool feedback_page_data_complete_;
134
135 DISALLOW_COPY_AND_ASSIGN(FeedbackData);
108 }; 136 };
109 137
110 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_ 138 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698