Coverage for /Syzygy/kasko/reporter.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
0.0%0047.C++source

Line-by-line coverage:

   1    :  // Copyright 2014 Google Inc. All Rights Reserved.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  
  15    :  #ifndef SYZYGY_KASKO_REPORTER_H_
  16    :  #define SYZYGY_KASKO_REPORTER_H_
  17    :  
  18    :  #include <map>
  19    :  #include <memory>
  20    :  
  21    :  #include "base/callback_forward.h"
  22    :  #include "base/macros.h"
  23    :  #include "base/files/file_path.h"
  24    :  #include "base/process/process_handle.h"
  25    :  #include "base/strings/string16.h"
  26    :  #include "base/threading/platform_thread.h"
  27    :  #include "syzygy/kasko/report_repository.h"
  28    :  #include "syzygy/kasko/service_bridge.h"
  29    :  
  30  m :  namespace base {
  31  m :  class TimeDelta;
  32  m :  }  // namespace base
  33    :  
  34  m :  namespace kasko {
  35    :  
  36  m :  struct MinidumpRequest;
  37  m :  class UploadThread;
  38    :  
  39    :  // Implements the reporter process lifetime. Maintains state, operates a
  40    :  // reporter RPC service, and configures background uploading of reports.
  41    :  //
  42    :  // Reports that exceed upload retry limits will be moved to a permanent failure
  43    :  // destination. The reports consist of two files: a minidump file (extension
  44    :  // kPermanentFailureMinidumpExtension, which is '.dmp') and a crash keys file
  45    :  // (extension kPermanentFailureCrashKeysExtension, which is '.kys'). The two
  46    :  // file names will be identical apart from the extension. The crash keys file
  47    :  // will contain a JSON dictionary mapping crash key names to string values.
  48  m :  class Reporter {
  49  m :   public:
  50    :    // The extension given to crash keys files in the permanent failure directory.
  51  m :    static const base::char16* const kPermanentFailureCrashKeysExtension;
  52    :    // The extension given to minidump files in the permanent failure directory.
  53  m :    static const base::char16* const kPermanentFailureMinidumpExtension;
  54    :    // The parameter name assigned to the uploaded minidump file.
  55  m :    static const base::char16* const kMinidumpUploadFilePart;
  56    :    // An crash key added to all reports, indicating the version of Kasko that
  57    :    // generated the report.
  58  m :    static const base::char16* const kKaskoGeneratedByVersion;
  59    :    // An crash key added to all reports, indicating the version of Kasko that
  60    :    // uploaded the report.
  61  m :    static const base::char16* const kKaskoUploadedByVersion;
  62    :  
  63    :    // Receives notification when a report has been uploaded.
  64    :    // @param report_id The server-assigned report ID.
  65    :    // @param minidump_path The local path to the report file. This path is no
  66    :    //     longer valid after the callback returns.
  67    :    // @param crash_keys The crash keys included with the report.
  68  m :    using OnUploadCallback = base::Callback<void(
  69  m :        const base::string16& report_id,
  70  m :        const base::FilePath& minidump_path,
  71  m :        const std::map<base::string16, base::string16>& crash_keys)>;
  72    :  
  73    :    // Creates a Reporter process. The process is already running in the
  74    :    // background when this method returns.
  75    :    // @param endpoint_name The RPC endpoint name to listen on.
  76    :    // @param url The URL that crash reports should be uploaded to.
  77    :    // @param data_directory The directory where crash reports will be generated
  78    :    //     and stored for uploading.
  79    :    // @param permanent_failure_directory The directory where crash reports that
  80    :    //     have exceeded retry limits will be moved to.
  81    :    // @param upload_interval The minimum interval between two upload operations.
  82    :    // @param retry_interval The minimum interval between upload attempts for a
  83    :    //     single crash report.
  84    :    // @param on_upload_callback The callback to notify when an upload completes.
  85    :    // @returns a Reporter instance if successful.
  86  m :    static std::unique_ptr<Reporter> Create(
  87  m :        const base::string16& endpoint_name,
  88  m :        const base::string16& url,
  89  m :        const base::FilePath& data_directory,
  90  m :        const base::FilePath& permanent_failure_directory,
  91  m :        const base::TimeDelta& upload_interval,
  92  m :        const base::TimeDelta& retry_interval,
  93  m :        const OnUploadCallback& on_upload_callback);
  94    :  
  95  m :    ~Reporter();
  96    :  
  97    :    // Sends a diagnostic report for a specified process with the specified crash
  98    :    // keys.
  99    :    // @param process_handle A handle to the process to report on.
 100    :    // @param thread_id The crashing thread to report on. Ignored if
 101    :    //     request.exception_info_address is null.
 102    :    // @param request The report parameters.
 103  m :    void SendReportForProcess(base::ProcessHandle process_handle,
 104  m :                              base::PlatformThreadId thread_id,
 105  m :                              MinidumpRequest request);
 106    :  
 107    :    // Shuts down and destroys a Reporter process. Blocks until all background
 108    :    // tasks have terminated.
 109    :    // @param instance The Reporter process instance to shut down.
 110  m :    static void Shutdown(std::unique_ptr<Reporter> instance);
 111    :  
 112    :    // Uploads a crash report containing the minidump at @p minidump_path and
 113    :    // @p crash_keys to @p upload_url. Returns true if successful.
 114    :    // @param on_upload_callback The callback to invoke on successful upload.
 115    :    // @param upload_url The URL where the minidump will be uploaded.
 116    :    // @param minidump_path The path to the minidump to upload.
 117    :    // @param crash_keys The crash-keys associated with the minidump.
 118    :    // @returns true on success, false otherwise.
 119  m :    static bool UploadCrashReport(
 120  m :        const Reporter::OnUploadCallback& on_upload_callback,
 121  m :        const base::string16& upload_url,
 122  m :        const base::FilePath& minidump_path,
 123  m :        const std::map<base::string16, base::string16>& crash_keys);
 124    :  
 125  m :   private:
 126    :    // Instantiates a Reporter process instance. Does not start any background
 127    :    // processes.
 128    :    // @param report_repository The report repository to store reports in.
 129    :    // @param upload_thread An upload thread that is configured to upload reports
 130    :    //     from |report_repository|.
 131    :    // @param endpoint_name The RPC endpoint name to listen on.
 132    :    // @param temporary_minidump_directory A directory where minidumps may be
 133    :    //     temporarily stored before uploading.
 134  m :    Reporter(std::unique_ptr<ReportRepository> report_repository,
 135  m :             std::unique_ptr<UploadThread> upload_thread,
 136  m :             const base::string16& endpoint_name,
 137  m :             const base::FilePath& temporary_minidump_directory);
 138    :  
 139    :    // A repository for generated reports.
 140  m :    std::unique_ptr<ReportRepository> report_repository_;
 141    :  
 142    :    // A background upload scheduler.
 143  m :    std::unique_ptr<UploadThread> upload_thread_;
 144    :  
 145    :    // The directory where minidumps will be initially created.
 146  m :    base::FilePath temporary_minidump_directory_;
 147    :  
 148    :    // An RPC service endpoint.
 149  m :    ServiceBridge service_bridge_;
 150    :  
 151  m :    DISALLOW_COPY_AND_ASSIGN(Reporter);
 152  m :  };
 153    :  
 154  m :  }  // namespace kasko
 155    :  
 156    :  #endif  // SYZYGY_KASKO_REPORTER_H_

Coverage information generated Fri Jul 29 11:00:21 2016.