Chromium Code Reviews| Index: third_party/crashpad/crashpad/handler/handler_main.cc |
| diff --git a/third_party/crashpad/crashpad/handler/handler_main.cc b/third_party/crashpad/crashpad/handler/handler_main.cc |
| index 3240cd38b37d79d6c915560aa41f325702cf00cd..0bec0d09eda4a107f5c2d64a3b692f05b15fbe0a 100644 |
| --- a/third_party/crashpad/crashpad/handler/handler_main.cc |
| +++ b/third_party/crashpad/crashpad/handler/handler_main.cc |
| @@ -27,6 +27,7 @@ |
| #include "base/files/file_path.h" |
| #include "base/files/scoped_file.h" |
| #include "base/logging.h" |
| +#include "base/metrics/persistent_histogram_allocator.h" |
| #include "base/scoped_generic.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "build/build_config.h" |
| @@ -78,6 +79,7 @@ void Usage(const base::FilePath& me) { |
| " --handshake-handle=HANDLE\n" |
| " create a new pipe and send its name via HANDLE\n" |
| #endif // OS_MACOSX |
| +" --metrics-dir=DIR store metrics files in DIR (only in Chromium)\n" |
| " --no-rate-limit don't rate limit crash uploads\n" |
| #if defined(OS_MACOSX) |
| " --reset-own-crash-exception-port-to-system-default\n" |
| @@ -136,6 +138,7 @@ int HandlerMain(int argc, char* argv[]) { |
| #elif defined(OS_WIN) |
| kOptionHandshakeHandle, |
| #endif // OS_MACOSX |
| + kOptionMetrics, |
| kOptionNoRateLimit, |
| #if defined(OS_MACOSX) |
| kOptionResetOwnCrashExceptionPortToSystemDefault, |
| @@ -153,6 +156,7 @@ int HandlerMain(int argc, char* argv[]) { |
| std::map<std::string, std::string> annotations; |
| std::string url; |
| const char* database; |
| + const char* metrics; |
| #if defined(OS_MACOSX) |
| int handshake_fd; |
| std::string mach_service; |
| @@ -179,6 +183,7 @@ int HandlerMain(int argc, char* argv[]) { |
| #elif defined(OS_WIN) |
| {"handshake-handle", required_argument, nullptr, kOptionHandshakeHandle}, |
| #endif // OS_MACOSX |
| + {"metrics-dir", required_argument, nullptr, kOptionMetrics}, |
| {"no-rate-limit", no_argument, nullptr, kOptionNoRateLimit}, |
| #if defined(OS_MACOSX) |
| {"reset-own-crash-exception-port-to-system-default", |
| @@ -243,6 +248,10 @@ int HandlerMain(int argc, char* argv[]) { |
| break; |
| } |
| #endif // OS_MACOSX |
| + case kOptionMetrics: { |
| + options.metrics = optarg; |
| + break; |
| + } |
| case kOptionNoRateLimit: { |
| options.rate_limit = false; |
| break; |
| @@ -386,6 +395,18 @@ int HandlerMain(int argc, char* argv[]) { |
| } |
| #endif // OS_MACOSX |
| + base::GlobalHistogramAllocator* histogram_allocator = nullptr; |
| + if (options.metrics) { |
| + const base::FilePath metrics_dir( |
| + ToolSupport::CommandLineArgumentToFilePathStringType(options.metrics)); |
| + const char kMetricsName[] = "CrashpadMetrics"; |
|
Alexei Svitkine (slow)
2016/09/15 16:49:44
Nit: static const for - as otherwise this results
Mark Mentovai
2016/09/15 17:22:28
Alexei Svitkine (very slow) wrote:
Alexei Svitkine (slow)
2016/09/15 17:31:51
I am referring to this discussion:
https://groups
scottmg
2016/09/15 17:41:13
Done.
scottmg
2016/09/15 19:29:09
I missed this conversation before I made the chang
|
| + if (base::GlobalHistogramAllocator::CreateWithActiveFileInDir( |
| + metrics_dir, 1 << 20, 0, kMetricsName)) { |
|
Alexei Svitkine (slow)
2016/09/15 16:49:44
I'd move 1 << 20 into a constant above this call w
scottmg
2016/09/15 17:41:13
Done.
|
| + histogram_allocator = base::GlobalHistogramAllocator::Get(); |
| + histogram_allocator->CreateTrackingHistograms(kMetricsName); |
| + } |
| + } |
| + |
| std::unique_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize( |
| base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType( |
| options.database)))); |
| @@ -412,6 +433,9 @@ int HandlerMain(int argc, char* argv[]) { |
| upload_thread.Stop(); |
| prune_thread.Stop(); |
| + if (histogram_allocator) |
| + histogram_allocator->DeletePersistentLocation(); |
| + |
| return EXIT_SUCCESS; |
| } |