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

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, 23
24 const std::string& category_tag, 24 // Called once we've update all the data from the feedback page.
25 const std::string& page_url, 25 void FeedbackPageDataComplete();
26 const std::string& description, 26
27 const std::string& user_email,
28 ScreenshotDataPtr image
29 #if defined(OS_CHROMEOS) 27 #if defined(OS_CHROMEOS)
30 , chromeos::system::LogDictionaryType* sys_info 28 // Called once we have read our system logs.
31 , std::string* zip_content 29 void SyslogsComplete(scoped_ptr<chromeos::SystemLogsResponse> sys_info);
32 , const std::string& timestamp 30
33 , const std::string& attached_filename 31 // Called once we have read our attached file.
34 , std::string* attached_filedata 32 void ReadFileComplete();
33
34 // Starts the collection of our system logs. SyslogsComplete is called once
35 // the collection is done.
36 void StartSyslogsCollection();
35 #endif 37 #endif
36 );
37 38
38 ~FeedbackData(); 39 // Returns true if we've complete collection of data from all our
40 // data sources. At this time this involves the system logs, the attached
41 // file (if needed to be read of the disk) and the rest of the data from
42 // the feedback page.
43 bool DataCollectionComplete();
39 44
45 // Sends the feedback report if we have all our data complete.
40 void SendReport(); 46 void SendReport();
41 47
42 void UpdateData(Profile* profile, 48 // Starts reading the file to attach to this report into the string
43 const std::string& category_tag, 49 // file_data. ReadFileComplete is called once this is done.
44 const std::string& page_url, 50 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 51
57 #if defined(OS_CHROMEOS) 52 // Getters
58 void SyslogsComplete(chromeos::system::LogDictionaryType* logs,
59 std::string* zip_content);
60 #endif
61
62 Profile* profile() const { return profile_; } 53 Profile* profile() const { return profile_; }
63 const std::string& category_tag() const { return category_tag_; } 54 const std::string& category_tag() const { return category_tag_; }
64 const std::string& page_url() const { return page_url_; } 55 const std::string& page_url() const { return page_url_; }
65 const std::string& description() const { return description_; } 56 const std::string& description() const { return description_; }
66 const std::string& user_email() const { return user_email_; } 57 const std::string& user_email() const { return user_email_; }
67 ScreenshotDataPtr image() const { return image_; } 58 ScreenshotDataPtr image() const { return image_; }
68 #if defined(OS_CHROMEOS) 59 #if defined(OS_CHROMEOS)
69 chromeos::system::LogDictionaryType* sys_info() const { 60 chromeos::SystemLogsResponse* sys_info() const {
70 return send_sys_info_ ? sys_info_ : NULL; } 61 return send_sys_info_ ? sys_info_.get() : NULL;
71 std::string* zip_content() const { return zip_content_; } 62 }
72 const std::string timestamp() const { return timestamp_; } 63 const std::string timestamp() const { return timestamp_; }
73 const std::string attached_filename() const { return attached_filename_; } 64 const std::string attached_filename() const { return attached_filename_; }
74 std::string* attached_filedata() const { return attached_filedata_; } 65 std::string* attached_filedata() const { return attached_filedata_; }
75 #endif 66 #endif
76 67
68 // Setters
69 void set_profile(Profile* profile) { profile_ = profile; }
70 void set_category_tag(const std::string& category_tag) {
71 category_tag_ = category_tag;
72 }
73 void set_page_url(const std::string& page_url) { page_url_ = page_url; }
74 void set_description(const std::string& description) {
75 description_ = description;
76 }
77 void set_user_email(const std::string& user_email) {
78 user_email_ = user_email;
79 }
80 void set_image(ScreenshotDataPtr image) { image_ = image; }
81 #if defined(OS_CHROMEOS)
82 void set_send_sys_info(bool send_sys_info) { send_sys_info_ = send_sys_info; }
83 void set_timestamp(const std::string& timestamp) {
84 timestamp_ = timestamp;
85 }
86 void set_attached_filename(const std::string& attached_filename) {
87 attached_filename_ = attached_filename;
88 }
89 void set_attached_filedata(std::string* attached_filedata) {
90 attached_filedata_ = attached_filedata;
91 }
92 #endif
77 93
78 private: 94 private:
95 friend class base::RefCountedThreadSafe<FeedbackData>;
96
97 virtual ~FeedbackData();
98
99 #if defined(OS_CHROMEOS)
100 void ReadAttachedFile(const base::FilePath& from);
101 #endif
102
79 Profile* profile_; 103 Profile* profile_;
80 104
81 std::string category_tag_; 105 std::string category_tag_;
82 std::string page_url_; 106 std::string page_url_;
83 std::string description_; 107 std::string description_;
84 std::string user_email_; 108 std::string user_email_;
85 ScreenshotDataPtr image_; 109 ScreenshotDataPtr image_;
86 110
87 #if defined(OS_CHROMEOS) 111 #if defined(OS_CHROMEOS)
88 // Chromeos specific values for SendReport. Will be deleted in 112 // Chromeos specific values for SendReport. Will be deleted in
89 // feedback_util::SendReport once consumed or in SyslogsComplete if 113 // feedback_util::SendReport once consumed or in SyslogsComplete if
90 // we don't send the logs with the report. 114 // we don't send the logs with the report.
91 chromeos::system::LogDictionaryType* sys_info_; 115 scoped_ptr<chromeos::SystemLogsResponse> sys_info_;
92 116
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_; 117 std::string timestamp_;
98 std::string attached_filename_; 118 std::string attached_filename_;
99 // Will be deleted in feedback_util::SendReport once consumed. 119 // Will be deleted in feedback_util::SendReport once consumed.
100 std::string* attached_filedata_; 120 std::string* attached_filedata_;
101 121
102 // NOTE: Extra boolean sent_report_ is required because callback may 122 // Flag to indicate whether or not we should send the system information
103 // occur before or after we call SendReport(). 123 // 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_; 124 bool send_sys_info_;
125
126 // Flags to indicate if various pieces of data needed for the report have
127 // been collected yet or are still pending collection.
128 bool syslogs_collection_complete_;
129 bool read_attached_file_complete_;
107 #endif 130 #endif
131 bool feedback_page_data_complete_;
132
133 DISALLOW_COPY_AND_ASSIGN(FeedbackData);
108 }; 134 };
109 135
110 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_ 136 #endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system_logs/touch_log_source.cc ('k') | chrome/browser/feedback/feedback_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698