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

Side by Side Diff: chrome/browser/feedback/feedback_util.cc

Issue 141433011: Cache feedback reports to disk in case of send failure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 #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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 chrome_browser_data.set_category( 232 chrome_browser_data.set_category(
233 userfeedback::ChromeBrowserData_ChromeBrowserCategory_OTHER); 233 userfeedback::ChromeBrowserData_ChromeBrowserCategory_OTHER);
234 *(chrome_data.mutable_chrome_browser_data()) = chrome_browser_data; 234 *(chrome_data.mutable_chrome_browser_data()) = chrome_browser_data;
235 feedback_data.set_product_id(kChromeBrowserProductId); 235 feedback_data.set_product_id(kChromeBrowserProductId);
236 #endif 236 #endif
237 237
238 *(feedback_data.mutable_chrome_data()) = chrome_data; 238 *(feedback_data.mutable_chrome_data()) = chrome_data;
239 239
240 // This pointer will eventually get deleted by the PostCleanup class, after 240 // This pointer will eventually get deleted by the PostCleanup class, after
241 // we've either managed to successfully upload the report or died trying. 241 // we've either managed to successfully upload the report or died trying.
242 scoped_ptr<std::string> post_body(new std::string); 242 std::string post_body;
243 feedback_data.SerializeToString(post_body.get()); 243 feedback_data.SerializeToString(&post_body);
244 244
245 feedback::FeedbackUploader *uploader = 245 feedback::FeedbackUploader *uploader =
246 feedback::FeedbackUploaderFactory::GetForBrowserContext(data->profile()); 246 feedback::FeedbackUploaderFactory::GetForBrowserContext(data->profile());
247 uploader->QueueReport(post_body.Pass()); 247 uploader->QueueReport(post_body);
248 } 248 }
249 249
250 bool ZipString(const base::FilePath& filename, 250 bool ZipString(const base::FilePath& filename,
251 const std::string& data, std::string* compressed_logs) { 251 const std::string& data, std::string* compressed_logs) {
252 base::FilePath temp_path; 252 base::FilePath temp_path;
253 base::FilePath zip_file; 253 base::FilePath zip_file;
254 254
255 // Create a temporary directory, put the logs into a file in it. Create 255 // Create a temporary directory, put the logs into a file in it. Create
256 // another temporary file to receive the zip file in. 256 // another temporary file to receive the zip file in.
257 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &temp_path)) 257 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &temp_path))
258 return false; 258 return false;
259 if (file_util::WriteFile(temp_path.Append(filename), 259 if (file_util::WriteFile(temp_path.Append(filename),
260 data.c_str(), data.size()) == -1) 260 data.c_str(), data.size()) == -1)
261 return false; 261 return false;
262 262
263 bool succeed = base::CreateTemporaryFile(&zip_file) && 263 bool succeed = base::CreateTemporaryFile(&zip_file) &&
264 zip::Zip(temp_path, zip_file, false) && 264 zip::Zip(temp_path, zip_file, false) &&
265 base::ReadFileToString(zip_file, compressed_logs); 265 base::ReadFileToString(zip_file, compressed_logs);
266 266
267 base::DeleteFile(temp_path, true); 267 base::DeleteFile(temp_path, true);
268 base::DeleteFile(zip_file, false); 268 base::DeleteFile(zip_file, false);
269 269
270 return succeed; 270 return succeed;
271 } 271 }
272 272
273 } // namespace feedback_util 273 } // namespace feedback_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698