Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #include "handler/handler_main.h" | 15 #include "handler/handler_main.h" |
| 16 | 16 |
| 17 #include <getopt.h> | 17 #include <getopt.h> |
| 18 #include <stdint.h> | 18 #include <stdint.h> |
| 19 #include <stdlib.h> | 19 #include <stdlib.h> |
| 20 | 20 |
| 21 #include <map> | 21 #include <map> |
| 22 #include <memory> | 22 #include <memory> |
| 23 #include <string> | 23 #include <string> |
| 24 #include <utility> | 24 #include <utility> |
| 25 | 25 |
| 26 #include "base/auto_reset.h" | 26 #include "base/auto_reset.h" |
| 27 #include "base/files/file_path.h" | 27 #include "base/files/file_path.h" |
| 28 #include "base/files/scoped_file.h" | 28 #include "base/files/scoped_file.h" |
| 29 #include "base/logging.h" | 29 #include "base/logging.h" |
| 30 #include "base/metrics/persistent_metrics_file_util.h" | |
| 30 #include "base/scoped_generic.h" | 31 #include "base/scoped_generic.h" |
| 31 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
| 32 #include "build/build_config.h" | 33 #include "build/build_config.h" |
| 33 #include "client/crash_report_database.h" | 34 #include "client/crash_report_database.h" |
| 34 #include "client/crashpad_client.h" | 35 #include "client/crashpad_client.h" |
| 35 #include "client/prune_crash_reports.h" | 36 #include "client/prune_crash_reports.h" |
| 36 #include "handler/crash_report_upload_thread.h" | 37 #include "handler/crash_report_upload_thread.h" |
| 37 #include "handler/prune_crash_reports_thread.h" | 38 #include "handler/prune_crash_reports_thread.h" |
| 38 #include "tools/tool_support.h" | 39 #include "tools/tool_support.h" |
| 39 #include "util/file/file_io.h" | 40 #include "util/file/file_io.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 if (!options.database) { | 307 if (!options.database) { |
| 307 ToolSupport::UsageHint(me, "--database is required"); | 308 ToolSupport::UsageHint(me, "--database is required"); |
| 308 return EXIT_FAILURE; | 309 return EXIT_FAILURE; |
| 309 } | 310 } |
| 310 | 311 |
| 311 if (argc) { | 312 if (argc) { |
| 312 ToolSupport::UsageHint(me, nullptr); | 313 ToolSupport::UsageHint(me, nullptr); |
| 313 return EXIT_FAILURE; | 314 return EXIT_FAILURE; |
| 314 } | 315 } |
| 315 | 316 |
| 317 std::unique_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize( | |
| 318 base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType( | |
| 319 options.database)))); | |
| 320 if (!database) { | |
| 321 return EXIT_FAILURE; | |
| 322 } | |
| 323 | |
| 324 const base::FilePath metrics_dir( | |
| 325 ToolSupport::CommandLineArgumentToFilePathStringType(options.database)); | |
|
Mark Mentovai
2016/09/13 21:35:56
Hmm, this will delay the handshake with the browse
scottmg
2016/09/13 21:46:24
It will. :( It "only" creates the directory if it
Mark Mentovai
2016/09/13 21:52:01
Well, crashpad_handler won’t run at all unless the
| |
| 326 const char kMetricsName[] = "CrashpadMetrics"; | |
| 327 base::InitializeGlobalPersistentMetricsStorage( | |
| 328 metrics_dir, kMetricsName, 1 << 20); | |
| 329 | |
| 316 #if defined(OS_MACOSX) | 330 #if defined(OS_MACOSX) |
| 317 if (options.mach_service.empty()) { | 331 if (options.mach_service.empty()) { |
| 318 // Don’t do this when being run by launchd. See launchd.plist(5). | 332 // Don’t do this when being run by launchd. See launchd.plist(5). |
| 319 CloseStdinAndStdout(); | 333 CloseStdinAndStdout(); |
| 320 } | 334 } |
| 321 | 335 |
| 322 if (options.reset_own_crash_exception_port_to_system_default) { | 336 if (options.reset_own_crash_exception_port_to_system_default) { |
| 323 CrashpadClient::UseSystemDefaultHandler(); | 337 CrashpadClient::UseSystemDefaultHandler(); |
| 324 } | 338 } |
| 325 | 339 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 return EXIT_FAILURE; | 393 return EXIT_FAILURE; |
| 380 } | 394 } |
| 381 if (!LoggingWriteFile(options.handshake_handle, | 395 if (!LoggingWriteFile(options.handshake_handle, |
| 382 pipe_name.c_str(), | 396 pipe_name.c_str(), |
| 383 pipe_name.size() * sizeof(pipe_name[0]))) { | 397 pipe_name.size() * sizeof(pipe_name[0]))) { |
| 384 return EXIT_FAILURE; | 398 return EXIT_FAILURE; |
| 385 } | 399 } |
| 386 } | 400 } |
| 387 #endif // OS_MACOSX | 401 #endif // OS_MACOSX |
| 388 | 402 |
| 389 std::unique_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize( | |
| 390 base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType( | |
| 391 options.database)))); | |
| 392 if (!database) { | |
| 393 return EXIT_FAILURE; | |
| 394 } | |
| 395 | |
| 396 // TODO(scottmg): options.rate_limit should be removed when we have a | 403 // TODO(scottmg): options.rate_limit should be removed when we have a |
| 397 // configurable database setting to control upload limiting. | 404 // configurable database setting to control upload limiting. |
| 398 // See https://crashpad.chromium.org/bug/23. | 405 // See https://crashpad.chromium.org/bug/23. |
| 399 CrashReportUploadThread upload_thread( | 406 CrashReportUploadThread upload_thread( |
| 400 database.get(), options.url, options.rate_limit); | 407 database.get(), options.url, options.rate_limit); |
| 401 upload_thread.Start(); | 408 upload_thread.Start(); |
| 402 | 409 |
| 403 PruneCrashReportThread prune_thread(database.get(), | 410 PruneCrashReportThread prune_thread(database.get(), |
| 404 PruneCondition::GetDefault()); | 411 PruneCondition::GetDefault()); |
| 405 prune_thread.Start(); | 412 prune_thread.Start(); |
| 406 | 413 |
| 407 CrashReportExceptionHandler exception_handler( | 414 CrashReportExceptionHandler exception_handler( |
| 408 database.get(), &upload_thread, &options.annotations); | 415 database.get(), &upload_thread, &options.annotations); |
| 409 | 416 |
| 410 exception_handler_server.Run(&exception_handler); | 417 exception_handler_server.Run(&exception_handler); |
| 411 | 418 |
| 412 upload_thread.Stop(); | 419 upload_thread.Stop(); |
| 413 prune_thread.Stop(); | 420 prune_thread.Stop(); |
| 414 | 421 |
| 422 base::CleanUpGlobalPersistentHistogramStorage(); | |
| 423 | |
| 415 return EXIT_SUCCESS; | 424 return EXIT_SUCCESS; |
| 416 } | 425 } |
| 417 | 426 |
| 418 } // namespace crashpad | 427 } // namespace crashpad |
| OLD | NEW |