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

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

Issue 99923002: Move temp file functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 feedback_data.SerializeToString(post_body); 369 feedback_data.SerializeToString(post_body);
370 370
371 DispatchFeedback(data->profile(), post_body, 0); 371 DispatchFeedback(data->profile(), post_body, 0);
372 } 372 }
373 373
374 bool ZipString(const base::FilePath& filename, 374 bool ZipString(const base::FilePath& filename,
375 const std::string& data, std::string* compressed_logs) { 375 const std::string& data, std::string* compressed_logs) {
376 base::FilePath temp_path; 376 base::FilePath temp_path;
377 377
378 // Create a temporary directory, put the logs into a file in it. 378 // Create a temporary directory, put the logs into a file in it.
379 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""), &temp_path)) 379 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &temp_path))
380 return false; 380 return false;
381 381
382 base::FilePath temp_file = temp_path.Append(filename); 382 base::FilePath temp_file = temp_path.Append(filename);
383 if (file_util::WriteFile(temp_file, data.c_str(), data.size()) == -1) 383 if (file_util::WriteFile(temp_file, data.c_str(), data.size()) == -1)
384 return false; 384 return false;
385 385
386 return ZipFile(temp_file, compressed_logs); 386 return ZipFile(temp_file, compressed_logs);
387 } 387 }
388 388
389 bool ZipFile(const base::FilePath& filename, std::string* compressed_logs) { 389 bool ZipFile(const base::FilePath& filename, std::string* compressed_logs) {
390 base::FilePath zip_file; 390 base::FilePath zip_file;
391 391
392 // Create a temporary file to receive the zip file in it. 392 // Create a temporary file to receive the zip file in it.
393 if (!file_util::CreateTemporaryFile(&zip_file)) 393 if (!base::CreateTemporaryFile(&zip_file))
394 return false; 394 return false;
395 395
396 if (!zip::Zip(filename, zip_file, false)) 396 if (!zip::Zip(filename, zip_file, false))
397 return false; 397 return false;
398 398
399 if (!base::ReadFileToString(zip_file, compressed_logs)) 399 if (!base::ReadFileToString(zip_file, compressed_logs))
400 return false; 400 return false;
401 401
402 base::DeleteFile(zip_file, false); 402 base::DeleteFile(zip_file, false);
403 403
404 return true; 404 return true;
405 } 405 }
406 406
407 } // namespace feedback_util 407 } // namespace feedback_util
OLDNEW
« no previous file with comments | « chrome/browser/extensions/sandboxed_unpacker.cc ('k') | chrome/browser/first_run/first_run_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698