diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-26 08:55:22 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-26 08:55:22 +0000 |
commit | 6dde9d7f2a99851b0f84671832f072799dd3f8d5 (patch) | |
tree | 133dc5f7a37c0c1bf0e65f3ab32ef081a3c3f293 /chrome/common/child_process_logging_linux.cc | |
parent | 31de519d7a62e532c2bdded403a451c9f3f972da (diff) | |
download | chromium_src-6dde9d7f2a99851b0f84671832f072799dd3f8d5.zip chromium_src-6dde9d7f2a99851b0f84671832f072799dd3f8d5.tar.gz chromium_src-6dde9d7f2a99851b0f84671832f072799dd3f8d5.tar.bz2 |
Make crash reporting client_id accessible through child_process_logging.
On Mac and Linux, keep the client id in a global variable kept by the
child_process_logging implementations. This allows to read it in a
thread safe fashion when starting a child process.
Also replace std::string with statically allocated buffers for the
various items we add to the crash reports. This allows to properly
handle crashes upon shutdown (std::string would run its destructor,
invalidating the memory).
BUG=53231
TEST=Crash reporting should still work
Review URL: http://codereview.chromium.org/3186028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57497 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/child_process_logging_linux.cc')
-rw-r--r-- | chrome/common/child_process_logging_linux.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/chrome/common/child_process_logging_linux.cc b/chrome/common/child_process_logging_linux.cc index 40ad90c..d8f216e 100644 --- a/chrome/common/child_process_logging_linux.cc +++ b/chrome/common/child_process_logging_linux.cc @@ -13,12 +13,20 @@ namespace child_process_logging { -// We use a static string to hold the most recent active url. If we crash, the -// crash handler code will send the contents of this string to the browser. -std::string active_url; +// Account for the terminating null character. +static const size_t kMaxActiveURLSize = 1024 + 1; +static const size_t kClientIdSize = 32 + 1; + +// We use static strings to hold the most recent active url and the client +// identifier. If we crash, the crash handler code will send the contents of +// these strings to the browser. +char g_active_url[kMaxActiveURLSize]; +char g_client_id[kClientIdSize]; void SetActiveURL(const GURL& url) { - active_url = url.possibly_invalid_spec(); + base::strlcpy(g_active_url, + url.possibly_invalid_spec().c_str(), + kMaxActiveURLSize); } void SetClientId(const std::string& client_id) { @@ -28,10 +36,15 @@ void SetClientId(const std::string& client_id) { if (str.empty()) return; + base::strlcpy(g_client_id, str.c_str(), kClientIdSize); std::wstring wstr = ASCIIToWide(str); GoogleUpdateSettings::SetMetricsId(wstr); } +std::string GetClientId() { + return std::string(g_client_id); +} + void SetActiveExtensions(const std::set<std::string>& extension_ids) { // TODO(port) } |