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 #include "chrome/browser/feedback/feedback_util.h" | 5 #include "chrome/browser/feedback/feedback_util.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 scoped_ptr<std::string> post_body(new std::string); | 241 scoped_ptr<std::string> post_body(new std::string); |
242 feedback_data.SerializeToString(post_body.get()); | 242 feedback_data.SerializeToString(post_body.get()); |
243 | 243 |
244 feedback::FeedbackUploader *uploader = | 244 feedback::FeedbackUploader *uploader = |
245 feedback::FeedbackUploaderFactory::GetForBrowserContext(data->profile()); | 245 feedback::FeedbackUploaderFactory::GetForBrowserContext(data->profile()); |
246 uploader->QueueReport(post_body.Pass()); | 246 uploader->QueueReport(post_body.Pass()); |
247 } | 247 } |
248 | 248 |
249 bool ZipString(const base::FilePath& filename, | 249 bool ZipString(const base::FilePath& filename, |
250 const std::string& data, std::string* compressed_logs) { | 250 const std::string& data, std::string* compressed_logs) { |
251 base::FilePath temp_path; | |
252 base::FilePath zip_file; | 251 base::FilePath zip_file; |
253 | 252 |
254 // Create a temporary directory, put the logs into a file in it. Create | 253 zip::ZipContents contents_to_zip; |
255 // another temporary file to receive the zip file in. | 254 contents_to_zip[filename] = |
256 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &temp_path)) | 255 new base::RefCountedStaticMemory(data.data(), data.size()); |
257 return false; | |
258 if (file_util::WriteFile(temp_path.Append(filename), | |
259 data.c_str(), data.size()) == -1) | |
260 return false; | |
261 | 256 |
262 bool succeed = base::CreateTemporaryFile(&zip_file) && | 257 bool succeed = base::CreateTemporaryFile(&zip_file) && |
263 zip::Zip(temp_path, zip_file, false) && | 258 zip::ZipFromMemory(zip_file, contents_to_zip, false) && |
264 base::ReadFileToString(zip_file, compressed_logs); | 259 base::ReadFileToString(zip_file, compressed_logs); |
265 | 260 |
266 base::DeleteFile(temp_path, true); | |
267 base::DeleteFile(zip_file, false); | 261 base::DeleteFile(zip_file, false); |
268 | 262 |
269 return succeed; | 263 return succeed; |
270 } | 264 } |
271 | 265 |
272 } // namespace feedback_util | 266 } // namespace feedback_util |
OLD | NEW |