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

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

Issue 24998007: Modify ZipString to allow the filename to be passed as an argument (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 2 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
« no previous file with comments | « chrome/browser/feedback/feedback_util.h ('k') | chrome/browser/feedback/tracing_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "url/gurl.h" 50 #include "url/gurl.h"
51 51
52 #if defined(OS_CHROMEOS) 52 #if defined(OS_CHROMEOS)
53 #include "ash/shell.h" 53 #include "ash/shell.h"
54 #include "ui/aura/root_window.h" 54 #include "ui/aura/root_window.h"
55 #include "ui/aura/window.h" 55 #include "ui/aura/window.h"
56 #endif 56 #endif
57 57
58 namespace { 58 namespace {
59 59
60 const base::FilePath::CharType kLogsFilename[] =
61 FILE_PATH_LITERAL("system_logs.txt");
62
63 void DispatchFeedback(Profile* profile, std::string* post_body, int64 delay); 60 void DispatchFeedback(Profile* profile, std::string* post_body, int64 delay);
64 61
65 GURL GetTargetTabUrl(int session_id, int index) { 62 GURL GetTargetTabUrl(int session_id, int index) {
66 Browser* browser = chrome::FindBrowserWithID(session_id); 63 Browser* browser = chrome::FindBrowserWithID(session_id);
67 // Sanity checks. 64 // Sanity checks.
68 if (!browser || index >= browser->tab_strip_model()->count()) 65 if (!browser || index >= browser->tab_strip_model()->count())
69 return GURL(); 66 return GURL();
70 67
71 if (index >= 0) { 68 if (index >= 0) {
72 content::WebContents* target_tab = 69 content::WebContents* target_tab =
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 *(feedback_data.mutable_chrome_data()) = chrome_data; 355 *(feedback_data.mutable_chrome_data()) = chrome_data;
359 356
360 // This pointer will eventually get deleted by the PostCleanup class, after 357 // This pointer will eventually get deleted by the PostCleanup class, after
361 // we've either managed to successfully upload the report or died trying. 358 // we've either managed to successfully upload the report or died trying.
362 std::string* post_body = new std::string; 359 std::string* post_body = new std::string;
363 feedback_data.SerializeToString(post_body); 360 feedback_data.SerializeToString(post_body);
364 361
365 DispatchFeedback(data->profile(), post_body, 0); 362 DispatchFeedback(data->profile(), post_body, 0);
366 } 363 }
367 364
368 bool ZipString(const std::string& logs, std::string* compressed_logs) { 365 bool ZipString(const base::FilePath::CharType filename[],
366 const std::string& logs, std::string* compressed_logs) {
369 base::FilePath temp_path; 367 base::FilePath temp_path;
370 base::FilePath zip_file; 368 base::FilePath zip_file;
371 369
372 // Create a temporary directory, put the logs into a file in it. Create 370 // Create a temporary directory, put the logs into a file in it. Create
373 // another temporary file to receive the zip file in. 371 // another temporary file to receive the zip file in.
374 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""), &temp_path)) 372 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""), &temp_path))
375 return false; 373 return false;
376 if (file_util::WriteFile(temp_path.Append(kLogsFilename), 374 if (file_util::WriteFile(temp_path.Append(filename),
377 logs.c_str(), logs.size()) == -1) 375 logs.c_str(), logs.size()) == -1)
378 return false; 376 return false;
379 if (!file_util::CreateTemporaryFile(&zip_file)) 377 if (!file_util::CreateTemporaryFile(&zip_file))
380 return false; 378 return false;
381 379
382 if (!zip::Zip(temp_path, zip_file, false)) 380 if (!zip::Zip(temp_path, zip_file, false))
383 return false; 381 return false;
384 382
385 if (!base::ReadFileToString(zip_file, compressed_logs)) 383 if (!base::ReadFileToString(zip_file, compressed_logs))
386 return false; 384 return false;
387 385
388 return true; 386 return true;
389 } 387 }
390 388
391 } // namespace feedback_util 389 } // namespace feedback_util
OLDNEW
« no previous file with comments | « chrome/browser/feedback/feedback_util.h ('k') | chrome/browser/feedback/tracing_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698