mirror of
https://github.com/chromium/crashpad.git
synced 2025-01-14 09:17:57 +08:00
Make BuildHandlerArgvStrings() return its result
This is more direct than using an out-parameter. Copy elision should make it equally performant, and even in the absence of copy elision, this would now be an inexpensive move operation. Change-Id: Iaf0eb07b36c8e35ff8942fc422a22321bf5c3010 Reviewed-on: https://chromium-review.googlesource.com/1145495 Reviewed-by: Joshua Peraza <jperaza@chromium.org> Commit-Queue: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
98ebb0060b
commit
e50ea60321
@ -1 +0,0 @@
|
|||||||
This is a whitespace file used to kick off jobs.
|
|
@ -27,38 +27,38 @@ std::string FormatArgumentString(const std::string& name,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void BuildHandlerArgvStrings(
|
std::vector<std::string> BuildHandlerArgvStrings(
|
||||||
const base::FilePath& handler,
|
const base::FilePath& handler,
|
||||||
const base::FilePath& database,
|
const base::FilePath& database,
|
||||||
const base::FilePath& metrics_dir,
|
const base::FilePath& metrics_dir,
|
||||||
const std::string& url,
|
const std::string& url,
|
||||||
const std::map<std::string, std::string>& annotations,
|
const std::map<std::string, std::string>& annotations,
|
||||||
const std::vector<std::string>& arguments,
|
const std::vector<std::string>& arguments) {
|
||||||
std::vector<std::string>* argv_strings) {
|
std::vector<std::string> argv_strings(1, handler.value());
|
||||||
argv_strings->clear();
|
|
||||||
|
|
||||||
argv_strings->push_back(handler.value());
|
|
||||||
for (const auto& argument : arguments) {
|
for (const auto& argument : arguments) {
|
||||||
argv_strings->push_back(argument);
|
argv_strings.push_back(argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!database.empty()) {
|
if (!database.empty()) {
|
||||||
argv_strings->push_back(FormatArgumentString("database", database.value()));
|
argv_strings.push_back(FormatArgumentString("database", database.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!metrics_dir.empty()) {
|
if (!metrics_dir.empty()) {
|
||||||
argv_strings->push_back(
|
argv_strings.push_back(
|
||||||
FormatArgumentString("metrics-dir", metrics_dir.value()));
|
FormatArgumentString("metrics-dir", metrics_dir.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!url.empty()) {
|
if (!url.empty()) {
|
||||||
argv_strings->push_back(FormatArgumentString("url", url));
|
argv_strings.push_back(FormatArgumentString("url", url));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& kv : annotations) {
|
for (const auto& kv : annotations) {
|
||||||
argv_strings->push_back(
|
argv_strings.push_back(
|
||||||
FormatArgumentString("annotation", kv.first + '=' + kv.second));
|
FormatArgumentString("annotation", kv.first + '=' + kv.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return argv_strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertArgvStrings(const std::vector<std::string>& argv_strings,
|
void ConvertArgvStrings(const std::vector<std::string>& argv_strings,
|
||||||
|
@ -28,16 +28,14 @@ namespace crashpad {
|
|||||||
//!
|
//!
|
||||||
//! See StartHandlerAtCrash() for documentation on the input arguments.
|
//! See StartHandlerAtCrash() for documentation on the input arguments.
|
||||||
//!
|
//!
|
||||||
//! \param[out] A argv_strings vector of arguments suitable for starting the
|
//! \return A vector of arguments suitable for starting the handler with.
|
||||||
//! handler with.
|
std::vector<std::string> BuildHandlerArgvStrings(
|
||||||
void BuildHandlerArgvStrings(
|
|
||||||
const base::FilePath& handler,
|
const base::FilePath& handler,
|
||||||
const base::FilePath& database,
|
const base::FilePath& database,
|
||||||
const base::FilePath& metrics_dir,
|
const base::FilePath& metrics_dir,
|
||||||
const std::string& url,
|
const std::string& url,
|
||||||
const std::map<std::string, std::string>& annotations,
|
const std::map<std::string, std::string>& annotations,
|
||||||
const std::vector<std::string>& arguments,
|
const std::vector<std::string>& arguments);
|
||||||
std::vector<std::string>* argv_strings);
|
|
||||||
|
|
||||||
//! \brief Flattens a string vector into a const char* vector suitable for use
|
//! \brief Flattens a string vector into a const char* vector suitable for use
|
||||||
//! in an exec() call.
|
//! in an exec() call.
|
||||||
|
@ -58,14 +58,8 @@ bool CrashpadClient::StartHandler(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> argv_strings;
|
std::vector<std::string> argv_strings = BuildHandlerArgvStrings(
|
||||||
BuildHandlerArgvStrings(handler,
|
handler, database, metrics_dir, url, annotations, arguments);
|
||||||
database,
|
|
||||||
metrics_dir,
|
|
||||||
url,
|
|
||||||
annotations,
|
|
||||||
arguments,
|
|
||||||
&argv_strings);
|
|
||||||
|
|
||||||
std::vector<const char*> argv;
|
std::vector<const char*> argv;
|
||||||
ConvertArgvStrings(argv_strings, &argv);
|
ConvertArgvStrings(argv_strings, &argv);
|
||||||
|
@ -175,9 +175,8 @@ bool CrashpadClient::StartHandlerAtCrash(
|
|||||||
const std::string& url,
|
const std::string& url,
|
||||||
const std::map<std::string, std::string>& annotations,
|
const std::map<std::string, std::string>& annotations,
|
||||||
const std::vector<std::string>& arguments) {
|
const std::vector<std::string>& arguments) {
|
||||||
std::vector<std::string> argv;
|
std::vector<std::string> argv = BuildHandlerArgvStrings(
|
||||||
BuildHandlerArgvStrings(
|
handler, database, metrics_dir, url, annotations, arguments);
|
||||||
handler, database, metrics_dir, url, annotations, arguments, &argv);
|
|
||||||
|
|
||||||
auto signal_handler = LaunchAtCrashHandler::Get();
|
auto signal_handler = LaunchAtCrashHandler::Get();
|
||||||
if (signal_handler->Initialize(&argv)) {
|
if (signal_handler->Initialize(&argv)) {
|
||||||
@ -197,9 +196,8 @@ bool CrashpadClient::StartHandlerForClient(
|
|||||||
const std::map<std::string, std::string>& annotations,
|
const std::map<std::string, std::string>& annotations,
|
||||||
const std::vector<std::string>& arguments,
|
const std::vector<std::string>& arguments,
|
||||||
int socket) {
|
int socket) {
|
||||||
std::vector<std::string> argv;
|
std::vector<std::string> argv = BuildHandlerArgvStrings(
|
||||||
BuildHandlerArgvStrings(
|
handler, database, metrics_dir, url, annotations, arguments);
|
||||||
handler, database, metrics_dir, url, annotations, arguments, &argv);
|
|
||||||
|
|
||||||
argv.push_back(FormatArgumentInt("initial-client", socket));
|
argv.push_back(FormatArgumentInt("initial-client", socket));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user