/ src / common / linux / google_crashdump_uploader.h
google_crashdump_uploader.h
  1  // Copyright 2009 Google LLC
  2  //
  3  // Redistribution and use in source and binary forms, with or without
  4  // modification, are permitted provided that the following conditions are
  5  // met:
  6  //
  7  //     * Redistributions of source code must retain the above copyright
  8  // notice, this list of conditions and the following disclaimer.
  9  //     * Redistributions in binary form must reproduce the above
 10  // copyright notice, this list of conditions and the following disclaimer
 11  // in the documentation and/or other materials provided with the
 12  // distribution.
 13  //     * Neither the name of Google LLC nor the names of its
 14  // contributors may be used to endorse or promote products derived from
 15  // this software without specific prior written permission.
 16  //
 17  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18  // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 19  // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 20  // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 21  // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 22  // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 23  // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 24  // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 25  // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 26  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 27  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28  
 29  
 30  #ifndef COMMON_LINUX_GOOGLE_CRASHDUMP_UPLOADER_H_
 31  #define COMMON_LINUX_GOOGLE_CRASHDUMP_UPLOADER_H_
 32  
 33  #include <map>
 34  #include <memory>
 35  #include <string>
 36  
 37  #include "common/linux/libcurl_wrapper.h"
 38  #include "common/using_std_string.h"
 39  
 40  namespace google_breakpad {
 41  
 42  class GoogleCrashdumpUploader {
 43   public:
 44    GoogleCrashdumpUploader(const string& product,
 45                            const string& version,
 46                            const string& guid,
 47                            const string& ptime,
 48                            const string& ctime,
 49                            const string& email,
 50                            const string& comments,
 51                            const string& minidump_pathname,
 52                            const string& crash_server,
 53                            const string& proxy_host,
 54                            const string& proxy_userpassword);
 55  
 56    GoogleCrashdumpUploader(const string& product,
 57                            const string& version,
 58                            const string& guid,
 59                            const string& ptime,
 60                            const string& ctime,
 61                            const string& email,
 62                            const string& comments,
 63                            const string& minidump_pathname,
 64                            const string& crash_server,
 65                            const string& proxy_host,
 66                            const string& proxy_userpassword,
 67                            std::unique_ptr<LibcurlWrapper> http_layer);
 68  
 69    void Init(const string& product,
 70              const string& version,
 71              const string& guid,
 72              const string& ptime,
 73              const string& ctime,
 74              const string& email,
 75              const string& comments,
 76              const string& minidump_pathname,
 77              const string& crash_server,
 78              const string& proxy_host,
 79              const string& proxy_userpassword,
 80              std::unique_ptr<LibcurlWrapper> http_layer);
 81    bool Upload(int* http_status_code,
 82                string* http_response_header,
 83                string* http_response_body);
 84  
 85   private:
 86    bool CheckRequiredParametersArePresent();
 87  
 88    std::unique_ptr<LibcurlWrapper> http_layer_;
 89    string product_;
 90    string version_;
 91    string guid_;
 92    string ptime_;
 93    string ctime_;
 94    string email_;
 95    string comments_;
 96    string minidump_pathname_;
 97  
 98    string crash_server_;
 99    string proxy_host_;
100    string proxy_userpassword_;
101  
102    std::map<string, string> parameters_;
103  };
104  }
105  
106  #endif  // COMMON_LINUX_GOOGLE_CRASHDUMP_UPLOADER_H_