Commit dd159d95 authored by zork@chromium.org's avatar zork@chromium.org

Modify ZipString to allow the filename to be passed as an argument

R=rkc@chromium.org
BUG=299015

Review URL: https://codereview.chromium.org/24998007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226520 0039d316-1c4b-4281-b951-d872f2087c98
parent b8255e7a
...@@ -31,9 +31,12 @@ const char kMultilineEndString[] = "---------- END ----------\n\n"; ...@@ -31,9 +31,12 @@ const char kMultilineEndString[] = "---------- END ----------\n\n";
const size_t kFeedbackMaxLength = 4 * 1024; const size_t kFeedbackMaxLength = 4 * 1024;
const size_t kFeedbackMaxLineCount = 40; const size_t kFeedbackMaxLineCount = 40;
const char kTraceFilename[] = "tracing.log\n"; const char kTraceFilename[] = "tracing.zip\n";
const char kPerformanceCategoryTag[] = "Performance"; const char kPerformanceCategoryTag[] = "Performance";
const base::FilePath::CharType kLogsFilename[] =
FILE_PATH_LITERAL("system_logs.txt");
// Converts the system logs into a string that we can compress and send // Converts the system logs into a string that we can compress and send
// with the report. This method only converts those logs that we want in // with the report. This method only converts those logs that we want in
// the compressed zip file sent with the report, hence it ignores any logs // the compressed zip file sent with the report, hence it ignores any logs
...@@ -69,7 +72,7 @@ void ZipLogs(FeedbackData::SystemLogsMap* sys_info, ...@@ -69,7 +72,7 @@ void ZipLogs(FeedbackData::SystemLogsMap* sys_info,
DCHECK(compressed_logs); DCHECK(compressed_logs);
std::string logs_string = LogsToString(sys_info); std::string logs_string = LogsToString(sys_info);
if (logs_string.empty() || if (logs_string.empty() ||
!feedback_util::ZipString(logs_string, compressed_logs)) { !feedback_util::ZipString(kLogsFilename, logs_string, compressed_logs)) {
compressed_logs->clear(); compressed_logs->clear();
} }
} }
......
...@@ -57,9 +57,6 @@ ...@@ -57,9 +57,6 @@
namespace { namespace {
const base::FilePath::CharType kLogsFilename[] =
FILE_PATH_LITERAL("system_logs.txt");
void DispatchFeedback(Profile* profile, std::string* post_body, int64 delay); void DispatchFeedback(Profile* profile, std::string* post_body, int64 delay);
GURL GetTargetTabUrl(int session_id, int index) { GURL GetTargetTabUrl(int session_id, int index) {
...@@ -365,7 +362,8 @@ void SendReport(scoped_refptr<FeedbackData> data) { ...@@ -365,7 +362,8 @@ void SendReport(scoped_refptr<FeedbackData> data) {
DispatchFeedback(data->profile(), post_body, 0); DispatchFeedback(data->profile(), post_body, 0);
} }
bool ZipString(const std::string& logs, std::string* compressed_logs) { bool ZipString(const base::FilePath::CharType filename[],
const std::string& logs, std::string* compressed_logs) {
base::FilePath temp_path; base::FilePath temp_path;
base::FilePath zip_file; base::FilePath zip_file;
...@@ -373,7 +371,7 @@ bool ZipString(const std::string& logs, std::string* compressed_logs) { ...@@ -373,7 +371,7 @@ bool ZipString(const std::string& logs, std::string* compressed_logs) {
// another temporary file to receive the zip file in. // another temporary file to receive the zip file in.
if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""), &temp_path)) if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""), &temp_path))
return false; return false;
if (file_util::WriteFile(temp_path.Append(kLogsFilename), if (file_util::WriteFile(temp_path.Append(filename),
logs.c_str(), logs.size()) == -1) logs.c_str(), logs.size()) == -1)
return false; return false;
if (!file_util::CreateTemporaryFile(&zip_file)) if (!file_util::CreateTemporaryFile(&zip_file))
......
...@@ -36,7 +36,8 @@ extern const char kAppLauncherCategoryTag[]; ...@@ -36,7 +36,8 @@ extern const char kAppLauncherCategoryTag[];
namespace feedback_util { namespace feedback_util {
void SendReport(scoped_refptr<FeedbackData> data); void SendReport(scoped_refptr<FeedbackData> data);
bool ZipString(const std::string& logs, std::string* compressed_logs); bool ZipString(const base::FilePath::CharType filename[],
const std::string& logs, std::string* compressed_logs);
} // namespace feedback_util } // namespace feedback_util
......
...@@ -16,6 +16,9 @@ namespace { ...@@ -16,6 +16,9 @@ namespace {
TracingManager* g_tracing_manager = NULL; TracingManager* g_tracing_manager = NULL;
// Trace IDs start at 1 and increase. // Trace IDs start at 1 and increase.
int g_next_trace_id = 1; int g_next_trace_id = 1;
// Name of the file to store the tracing data as.
const base::FilePath::CharType kTracingFilename[] =
FILE_PATH_LITERAL("tracing.json");
} }
TracingManager::TracingManager() TracingManager::TracingManager()
...@@ -96,7 +99,7 @@ void TracingManager::OnEndTracingComplete() { ...@@ -96,7 +99,7 @@ void TracingManager::OnEndTracingComplete() {
data_ = std::string("[") + data_ + "]"; data_ = std::string("[") + data_ + "]";
std::string output_val; std::string output_val;
feedback_util::ZipString(data_, &output_val); feedback_util::ZipString(kTracingFilename, data_, &output_val);
scoped_refptr<base::RefCountedString> output( scoped_refptr<base::RefCountedString> output(
base::RefCountedString::TakeString(&output_val)); base::RefCountedString::TakeString(&output_val));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment