bug 589955 - Submit empty crash reports on Windows. r=mento, a=blocking2.0
authorTed Mielczarek <ted.mielczarek@gmail.com>
Wed, 15 Dec 2010 11:34:55 -0500
changeset 59193 68529f865a6e
parent 59192 4aa24a68d717
child 59194 d0234003e042
push id17575
push usertmielczarek@mozilla.com
push date2010-12-15 16:44 +0000
treeherdermozilla-central@68529f865a6e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmento, blocking2
bugs589955
milestone2.0b9pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 589955 - Submit empty crash reports on Windows. r=mento, a=blocking2.0
toolkit/crashreporter/google-breakpad/src/common/windows/http_upload.cc
toolkit/crashreporter/google-breakpad/src/common/windows/http_upload.h
--- a/toolkit/crashreporter/google-breakpad/src/common/windows/http_upload.cc
+++ b/toolkit/crashreporter/google-breakpad/src/common/windows/http_upload.cc
@@ -269,18 +269,17 @@ wstring HTTPUpload::GenerateRequestHeade
 
 // static
 bool HTTPUpload::GenerateRequestBody(const map<wstring, wstring> &parameters,
                                      const wstring &upload_file,
                                      const wstring &file_part_name,
                                      const wstring &boundary,
                                      string *request_body) {
   vector<char> contents;
-  GetFileContents(upload_file, &contents);
-  if (contents.empty()) {
+  if (!GetFileContents(upload_file, &contents)) {
     return false;
   }
 
   string boundary_str = WideToUTF8(boundary);
   if (boundary_str.empty()) {
     return false;
   }
 
@@ -317,40 +316,40 @@ bool HTTPUpload::GenerateRequestBody(con
       request_body->append(&(contents[0]), contents.size());
   }
   request_body->append("\r\n");
   request_body->append("--" + boundary_str + "--\r\n");
   return true;
 }
 
 // static
-void HTTPUpload::GetFileContents(const wstring &filename,
+bool HTTPUpload::GetFileContents(const wstring &filename,
                                  vector<char> *contents) {
   // The "open" method on pre-MSVC8 ifstream implementations doesn't accept a
   // wchar_t* filename, so use _wfopen directly in that case.  For VC8 and
   // later, _wfopen has been deprecated in favor of _wfopen_s, which does
   // not exist in earlier versions, so let the ifstream open the file itself.
 #if _MSC_VER >= 1400  // MSVC 2005/8
   ifstream file;
   file.open(filename.c_str(), ios::binary);
 #else  // _MSC_VER >= 1400
   ifstream file(_wfopen(filename.c_str(), L"rb"));
 #endif  // _MSC_VER >= 1400
   if (file.is_open()) {
     file.seekg(0, ios::end);
     std::streamoff length = file.tellg();
     contents->resize(length);
     if (length != 0) {
-        file.seekg(0, ios::beg);
-        file.read(&((*contents)[0]), length);
+      file.seekg(0, ios::beg);
+      file.read(&((*contents)[0]), length);
     }
     file.close();
-  } else {
-    contents->clear();
+    return true;
   }
+  return false;
 }
 
 // static
 wstring HTTPUpload::UTF8ToWide(const string &utf8) {
   if (utf8.length() == 0) {
     return wstring();
   }
 
--- a/toolkit/crashreporter/google-breakpad/src/common/windows/http_upload.h
+++ b/toolkit/crashreporter/google-breakpad/src/common/windows/http_upload.h
@@ -93,17 +93,17 @@ class HTTPUpload {
   // and minidump contents.  Returns true on success.
   static bool GenerateRequestBody(const map<wstring, wstring> &parameters,
                                   const wstring &upload_file,
                                   const wstring &file_part_name,
                                   const wstring &boundary,
                                   string *request_body);
 
   // Fills the supplied vector with the contents of filename.
-  static void GetFileContents(const wstring &filename, vector<char> *contents);
+  static bool GetFileContents(const wstring &filename, vector<char> *contents);
 
   // Converts a UTF8 string to UTF16.
   static wstring UTF8ToWide(const string &utf8);
 
   // Converts a UTF16 string to UTF8.
   static string WideToUTF8(const wstring &wide);
 
   // Checks that the given list of parameters has only printable