Coverage for /Syzygy/kasko/reporter.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
0.0%0043.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    :  
  20    :  #include "base/callback_forward.h"
  21    :  #include "base/macros.h"
  22    :  #include "base/files/file_path.h"
  23    :  #include "base/memory/scoped_ptr.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 ServiceBridge;
  38  m :  class UploadThread;
  39    :  
  40    :  // Implements the reporter process lifetime. Maintains state, operates a
  41    :  // reporter RPC service, and configures background uploading of reports.
  42    :  //
  43    :  // Reports that exceed upload retry limits will be moved to a permanent failure
  44    :  // destination. The reports consist of two files: a minidump file (extension
  45    :  // kPermanentFailureMinidumpExtension, which is '.dmp') and a crash keys file
  46    :  // (extension kPermanentFailureCrashKeysExtension, which is '.kys'). The two
  47    :  // file names will be identical apart from the extension. The crash keys file
  48    :  // will contain a JSON dictionary mapping crash key names to string values.
  49  m :  class Reporter {
  50  m :   public:
  51    :    // The extension given to crash keys files in the permanent failure directory.
  52  m :    static const base::char16* const kPermanentFailureCrashKeysExtension;
  53    :    // The extension given to minidump files in the permanent failure directory.
  54  m :    static const base::char16* const kPermanentFailureMinidumpExtension;
  55    :    // The parameter name assigned to the uploaded minidump file.
  56  m :    static const base::char16* const kMinidumpUploadFilePart;
  57    :    // An crash key added to all reports, indicating the version of Kasko that
  58    :    // generated the report.
  59  m :    static const base::char16* const kKaskoGeneratedByVersion;
  60    :    // An crash key added to all reports, indicating the version of Kasko that
  61    :    // uploaded the report.
  62  m :    static const base::char16* const kKaskoUploadedByVersion;
  63    :  
  64    :    // Receives notification when a report has been uploaded.
  65    :    // @param report_id The server-assigned report ID.
  66    :    // @param minidump_path The local path to the report file. This path is no
  67    :    //     longer valid after the callback returns.
  68    :    // @param crash_keys The crash keys included with the report.
  69  m :    using OnUploadCallback = base::Callback<void(
  70  m :        const base::string16& report_id,
  71  m :        const base::FilePath& minidump_path,
  72  m :        const std::map<base::string16, base::string16>& crash_keys)>;
  73    :  
  74    :    // Creates a Reporter process. The process is already running in the
  75    :    // background when this method returns.
  76    :    // @param endpoint_name The RPC endpoint name to listen on.
  77    :    // @param url The URL that crash reports should be uploaded to.
  78    :    // @param data_directory The directory where crash reports will be generated
  79    :    //     and stored for uploading.
  80    :    // @param permanent_failure_directory The directory where crash reports that
  81    :    //     have exceeded retry limits will be moved to.
  82    :    // @param upload_interval The minimum interval between two upload operations.
  83    :    // @param retry_interval The minimum interval between upload attempts for a
  84    :    //     single crash report.
  85    :    // @param on_upload_callback The callback to notify when an upload completes.
  86    :    // @returns a Reporter instance if successful.
  87  m :    static scoped_ptr<Reporter> Create(
  88  m :        const base::string16& endpoint_name,
  89  m :        const base::string16& url,
  90  m :        const base::FilePath& data_directory,
  91  m :        const base::FilePath& permanent_failure_directory,
  92  m :        const base::TimeDelta& upload_interval,
  93  m :        const base::TimeDelta& retry_interval,
  94  m :        const OnUploadCallback& on_upload_callback);
  95    :  
  96  m :    ~Reporter();
  97    :  
  98    :    // Sends a diagnostic report for a specified process with the specified crash
  99    :    // keys.
 100    :    // @param process_handle A handle to the process to report on.
 101    :    // @param thread_id The crashing thread to report on. Ignored if
 102    :    //     request.exception_info_address is null.
 103    :    // @param request The report parameters.
 104  m :    void SendReportForProcess(base::ProcessHandle process_handle,
 105  m :                              base::PlatformThreadId thread_id,
 106  m :                              MinidumpRequest request);
 107    :  
 108    :    // Shuts down and destroys a Reporter process. Blocks until all background
 109    :    // tasks have terminated.
 110    :    // @param instance The Reporter process instance to shut down.
 111  m :    static void Shutdown(scoped_ptr<Reporter> instance);
 112    :  
 113  m :   private:
 114    :    // Instantiates a Reporter process instance. Does not start any background
 115    :    // processes.
 116    :    // @param report_repository The report repository to store reports in.
 117    :    // @param upload_thread An upload thread that is configured to upload reports
 118    :    //     from |report_repository|.
 119    :    // @param endpoint_name The RPC endpoint name to listen on.
 120    :    // @param temporary_minidump_directory A directory where minidumps may be
 121    :    //     temporarily stored before uploading.
 122  m :    Reporter(scoped_ptr<ReportRepository> report_repository,
 123  m :             scoped_ptr<UploadThread> upload_thread,
 124  m :             const base::string16& endpoint_name,
 125  m :             const base::FilePath& temporary_minidump_directory);
 126    :  
 127    :    // A repository for generated reports.
 128  m :    scoped_ptr<ReportRepository> report_repository_;
 129    :  
 130    :    // A background upload scheduler.
 131  m :    scoped_ptr<UploadThread> upload_thread_;
 132    :  
 133    :    // The directory where minidumps will be initially created.
 134  m :    base::FilePath temporary_minidump_directory_;
 135    :  
 136    :    // An RPC service endpoint.
 137  m :    ServiceBridge service_bridge_;
 138    :  
 139  m :    DISALLOW_COPY_AND_ASSIGN(Reporter);
 140  m :  };
 141    :  
 142  m :  }  // namespace kasko
 143    :  
 144    :  #endif  // SYZYGY_KASKO_REPORTER_H_

Coverage information generated Thu Jan 14 17:40:38 2016.