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

Side by Side Diff: chrome/browser/bug_report_util.cc

Issue 7562001: Add memory usage info to SyslogsProvider, and clean up bug report screenshot data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/bug_report_util.h" 5 #include "chrome/browser/bug_report_util.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 "http://www.google.com/safebrowsing/report_phish/"; 42 "http://www.google.com/safebrowsing/report_phish/";
43 43
44 // URL to post bug reports to. 44 // URL to post bug reports to.
45 static char const kBugReportPostUrl[] = 45 static char const kBugReportPostUrl[] =
46 "https://www.google.com/tools/feedback/chrome/__submit"; 46 "https://www.google.com/tools/feedback/chrome/__submit";
47 47
48 static char const kProtBufMimeType[] = "application/x-protobuf"; 48 static char const kProtBufMimeType[] = "application/x-protobuf";
49 static char const kPngMimeType[] = "image/png"; 49 static char const kPngMimeType[] = "image/png";
50 50
51 // Tags we use in product specific data 51 // Tags we use in product specific data
52 static char const kPageTitleTag[] = "PAGE TITLE";
53 static char const kProblemTypeIdTag[] = "PROBLEM TYPE ID";
54 static char const kProblemTypeTag[] = "PROBLEM TYPE";
stevenjb 2011/08/03 01:55:20 Unused.
55 static char const kChromeVersionTag[] = "CHROME VERSION"; 52 static char const kChromeVersionTag[] = "CHROME VERSION";
56 static char const kOsVersionTag[] = "OS VERSION"; 53 static char const kOsVersionTag[] = "OS VERSION";
57 54
58 static char const kNotificationId[] = "feedback.chromeos"; 55 static char const kNotificationId[] = "feedback.chromeos";
59 56
60 static int const kHttpPostSuccessNoContent = 204; 57 static int const kHttpPostSuccessNoContent = 204;
61 static int const kHttpPostFailNoConnection = -1; 58 static int const kHttpPostFailNoConnection = -1;
62 static int const kHttpPostFailClientError = 400; 59 static int const kHttpPostFailClientError = 400;
63 static int const kHttpPostFailServerError = 500; 60 static int const kHttpPostFailServerError = 500;
64 61
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 line_count++; 238 line_count++;
242 if (line_count > kMaxLineCount) 239 if (line_count > kMaxLineCount)
243 return false; 240 return false;
244 } 241 }
245 } 242 }
246 return true; 243 return true;
247 } 244 }
248 #endif 245 #endif
249 246
250 // static 247 // static
251 void BugReportUtil::SendReport(Profile* profile, 248 void BugReportUtil::SendReport(
252 int problem_type, 249 Profile* profile
253 const std::string& page_url_text, 250 , int problem_type
254 const std::string& description, 251 , const std::string& page_url_text
255 const char* png_data, 252 , const std::string& description
256 int png_data_length, 253 , const char* png_data
257 int png_width, 254 , int png_data_length
255 , int png_width
256 , int png_height
James Cook 2011/08/03 17:06:49 Missing end ) for non-ChromeOS builds.
258 #if defined(OS_CHROMEOS) 257 #if defined(OS_CHROMEOS)
259 int png_height, 258 , const std::string& user_email_text
260 const std::string& user_email_text, 259 , const char* zipped_logs_data
261 const char* zipped_logs_data, 260 , int zipped_logs_length
262 int zipped_logs_length, 261 , const chromeos::system::LogDictionaryType* const sys_info)
263 const chromeos::system::LogDictionaryType* const sys_info) {
264 #else
265 int png_height) {
266 #endif 262 #endif
263 {
267 // Create google feedback protocol buffer objects 264 // Create google feedback protocol buffer objects
268 userfeedback::ExternalExtensionSubmit feedback_data; 265 userfeedback::ExternalExtensionSubmit feedback_data;
269 // type id set to 0, unused field but needs to be initialized to 0 266 // type id set to 0, unused field but needs to be initialized to 0
270 feedback_data.set_type_id(0); 267 feedback_data.set_type_id(0);
271 268
272 userfeedback::CommonData* common_data = feedback_data.mutable_common_data(); 269 userfeedback::CommonData* common_data = feedback_data.mutable_common_data();
273 userfeedback::WebData* web_data = feedback_data.mutable_web_data(); 270 userfeedback::WebData* web_data = feedback_data.mutable_web_data();
274 271
275 // Set GAIA id to 0. We're not using gaia id's for recording 272 // Set GAIA id to 0. We're not using gaia id's for recording
276 // use feedback - we're using the e-mail field, allows users to 273 // use feedback - we're using the e-mail field, allows users to
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 screenshot.set_binary_content(std::string(png_data, png_data_length)); 317 screenshot.set_binary_content(std::string(png_data, png_data_length));
321 318
322 // Set the screenshot object in feedback 319 // Set the screenshot object in feedback
323 *(feedback_data.mutable_screenshot()) = screenshot; 320 *(feedback_data.mutable_screenshot()) = screenshot;
324 } 321 }
325 322
326 #if defined(OS_CHROMEOS) 323 #if defined(OS_CHROMEOS)
327 if (sys_info) { 324 if (sys_info) {
328 // Add the product specific data 325 // Add the product specific data
329 for (chromeos::system::LogDictionaryType::const_iterator i = 326 for (chromeos::system::LogDictionaryType::const_iterator i =
330 sys_info->begin(); i != sys_info->end(); ++i) 327 sys_info->begin(); i != sys_info->end(); ++i) {
James Cook 2011/08/03 17:06:49 Ah, this is much clearer with an explicit block.
331 if (!CommandLine::ForCurrentProcess()->HasSwitch( 328 if (!CommandLine::ForCurrentProcess()->HasSwitch(
332 switches::kCompressSystemFeedback) || ValidFeedbackSize(i->second)) { 329 switches::kCompressSystemFeedback) || ValidFeedbackSize(i->second)) {
333 AddFeedbackData(&feedback_data, i->first, i->second); 330 AddFeedbackData(&feedback_data, i->first, i->second);
334 } 331 }
332 }
335 333
336 // If we have zipped logs, add them here 334 // If we have zipped logs, add them here
337 if (zipped_logs_data && CommandLine::ForCurrentProcess()->HasSwitch( 335 if (zipped_logs_data && CommandLine::ForCurrentProcess()->HasSwitch(
338 switches::kCompressSystemFeedback)) { 336 switches::kCompressSystemFeedback)) {
339 userfeedback::ProductSpecificBinaryData attachment; 337 userfeedback::ProductSpecificBinaryData attachment;
340 attachment.set_mime_type(kBZip2MimeType); 338 attachment.set_mime_type(kBZip2MimeType);
341 attachment.set_name(kLogsAttachmentName); 339 attachment.set_name(kLogsAttachmentName);
342 attachment.set_data(std::string(zipped_logs_data, zipped_logs_length)); 340 attachment.set_data(std::string(zipped_logs_data, zipped_logs_length));
343 *(feedback_data.add_product_specific_binary_data()) = attachment; 341 *(feedback_data.add_product_specific_binary_data()) = attachment;
344 } 342 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 void BugReportUtil::ReportPhishing(TabContents* currentTab, 376 void BugReportUtil::ReportPhishing(TabContents* currentTab,
379 const std::string& phishing_url) { 377 const std::string& phishing_url) {
380 currentTab->controller().LoadURL( 378 currentTab->controller().LoadURL(
381 safe_browsing_util::GeneratePhishingReportUrl( 379 safe_browsing_util::GeneratePhishingReportUrl(
382 kReportPhishingUrl, phishing_url, 380 kReportPhishingUrl, phishing_url,
383 false /* not client-side detection */), 381 false /* not client-side detection */),
384 GURL(), 382 GURL(),
385 PageTransition::LINK); 383 PageTransition::LINK);
386 } 384 }
387 #endif 385 #endif
386
387 // static
388 std::vector<unsigned char>* BugReportUtil::GetScreenshotPng() {
389 static std::vector<unsigned char>* last_screenshot_png = NULL;
James Cook 2011/08/03 17:06:49 Do we every free the memory occupied by the screen
stevenjb 2011/08/03 19:11:39 Yes, we call GetScreenshotPng()->clear() in BugRep
390 if (last_screenshot_png == NULL)
391 last_screenshot_png = new std::vector<unsigned char>;
392 return last_screenshot_png;
393 }
394
395 // static
396 gfx::Rect& BugReportUtil::GetScreenshotSize() {
397 static gfx::Rect* screen_size = NULL;
398 if (screen_size == NULL)
399 screen_size = new gfx::Rect();
400 return *screen_size;
401 }
402
403 // static
404 void BugReportUtil::SetScreenshotSize(const gfx::Rect& rect) {
405 gfx::Rect& screen_size = GetScreenshotSize();
406 screen_size = rect;
407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698