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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; | 251 base::FilePath temp_path; |
252 base::FilePath zip_file; | 252 base::FilePath zip_file; |
253 | 253 |
254 // Create a temporary directory, put the logs into a file in it. Create | 254 // Create a temporary directory, put the logs into a file in it. Create |
255 // another temporary file to receive the zip file in. | 255 // another temporary file to receive the zip file in. |
256 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &temp_path)) | 256 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &temp_path)) |
257 return false; | 257 return false; |
258 if (file_util::WriteFile(temp_path.Append(filename), | 258 if (base::WriteFile(temp_path.Append(filename), data.c_str(), data.size()) == |
259 data.c_str(), data.size()) == -1) | 259 -1) |
260 return false; | 260 return false; |
261 | 261 |
262 bool succeed = base::CreateTemporaryFile(&zip_file) && | 262 bool succeed = base::CreateTemporaryFile(&zip_file) && |
263 zip::Zip(temp_path, zip_file, false) && | 263 zip::Zip(temp_path, zip_file, false) && |
264 base::ReadFileToString(zip_file, compressed_logs); | 264 base::ReadFileToString(zip_file, compressed_logs); |
265 | 265 |
266 base::DeleteFile(temp_path, true); | 266 base::DeleteFile(temp_path, true); |
267 base::DeleteFile(zip_file, false); | 267 base::DeleteFile(zip_file, false); |
268 | 268 |
269 return succeed; | 269 return succeed; |
270 } | 270 } |
271 | 271 |
272 } // namespace feedback_util | 272 } // namespace feedback_util |
OLD | NEW |