blob: 111721ba7a7f5f73e679bd798d990c74f4999c8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_
#define CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_
#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
#include "chrome/browser/ui/webui/screenshot_source.h"
#include "url/gurl.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h"
#endif
class Profile;
class FeedbackData : public base::RefCountedThreadSafe<FeedbackData> {
public:
FeedbackData();
// Called once we've update all the data from the feedback page.
void FeedbackPageDataComplete();
#if defined(OS_CHROMEOS)
// Called once we have read our system logs.
void CompressSyslogs(scoped_ptr<chromeos::SystemLogsResponse> sys_info);
// Called once we have read and compressed our system logs.
void SyslogsComplete(scoped_ptr<chromeos::SystemLogsResponse> sys_info,
scoped_ptr<std::string> compressed_logs);
// 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_; }
const std::string& description() const { return description_; }
const std::string& user_email() const { return user_email_; }
ScreenshotDataPtr image() const { return image_; }
const std::string attached_filename() const { return attached_filename_; }
const GURL attached_file_url() const { return attached_file_url_; }
std::string* attached_filedata() const { return attached_filedata_.get(); }
const GURL screenshot_url() const { return screenshot_url_; }
#if defined(OS_CHROMEOS)
chromeos::SystemLogsResponse* sys_info() const {
return send_sys_info_ ? sys_info_.get() : NULL;
}
const std::string timestamp() const { return timestamp_; }
std::string* compressed_logs() const { return compressed_logs_.get(); }
#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; }
void set_attached_filename(const std::string& attached_filename) {
attached_filename_ = attached_filename;
}
void set_attached_filedata(scoped_ptr<std::string> attached_filedata) {
attached_filedata_ = attached_filedata.Pass();
}
void set_attached_file_url(const GURL& url) { attached_file_url_ = url; }
void set_screenshot_url(const GURL& url) { screenshot_url_ = url; }
#if defined(OS_CHROMEOS)
void set_sys_info(scoped_ptr<chromeos::SystemLogsResponse> sys_info);
void set_send_sys_info(bool send_sys_info) { send_sys_info_ = send_sys_info; }
void set_timestamp(const std::string& timestamp) {
timestamp_ = timestamp;
}
#endif
private:
friend class base::RefCountedThreadSafe<FeedbackData>;
virtual ~FeedbackData();
#if defined(OS_CHROMEOS)
void ReadAttachedFile(const base::FilePath& from);
#endif
Profile* profile_;
std::string category_tag_;
std::string page_url_;
std::string description_;
std::string user_email_;
ScreenshotDataPtr image_;
std::string attached_filename_;
scoped_ptr<std::string> attached_filedata_;
GURL attached_file_url_;
GURL screenshot_url_;
#if defined(OS_CHROMEOS)
// 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.
scoped_ptr<chromeos::SystemLogsResponse> sys_info_;
std::string timestamp_;
scoped_ptr<std::string> compressed_logs_;
// 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 read_attached_file_complete_;
bool syslogs_collection_complete_;
#endif
bool feedback_page_data_complete_;
DISALLOW_COPY_AND_ASSIGN(FeedbackData);
};
#endif // CHROME_BROWSER_FEEDBACK_FEEDBACK_DATA_H_
|