diff options
author | mcgrathr@chromium.org <mcgrathr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-20 18:23:14 +0000 |
---|---|---|
committer | mcgrathr@chromium.org <mcgrathr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-20 18:23:14 +0000 |
commit | 8d5d761a7afc59fe9ab870b3c8a3aa4db3ac7bb3 (patch) | |
tree | 818a91df8b32fe639ee942312fecae4c16edf3a2 /chrome/nacl | |
parent | 94b623e2ac73138f6f863b153829d5efb7c61a3e (diff) | |
download | chromium_src-8d5d761a7afc59fe9ab870b3c8a3aa4db3ac7bb3.zip chromium_src-8d5d761a7afc59fe9ab870b3c8a3aa4db3ac7bb3.tar.gz chromium_src-8d5d761a7afc59fe9ab870b3c8a3aa4db3ac7bb3.tar.bz2 |
Add UMA reports for Linux nacl_helper startup status
This extends the Linux Zygote Fork request protocol so the Zygote process
can return a UMA histogram enumeration report to be made, along with the
PID. In the Zygote process, the ZygoteForkDelegate decides what to report.
It gets to choose an initial report to make, which happens on the first
fork request that doesn't have its own report to make (as a generic fork
for a renderer won't). It also gets to choose a report to make with each
individual fork request.
We then use this in the NaClForkDelegate to report status about the attempt
to start up the nacl_helper process. We both make an initial report, so we
can collect this information from every Chrome instance, and make a report
repeating the same information on each NaCl process fork request, so that
we can correlate the nacl_helper startup success/failure rates with
sessions that actually make use of NaCl.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2361
TEST= looked at about:histograms/NaCl
R=agl@chromium.org,bradchen@google.com,ncbray@google.com
Review URL: http://codereview.chromium.org/8342017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106529 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/nacl')
-rw-r--r-- | chrome/nacl/nacl_fork_delegate_linux.cc | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/chrome/nacl/nacl_fork_delegate_linux.cc b/chrome/nacl/nacl_fork_delegate_linux.cc index 828cb6e..0f389bd 100644 --- a/chrome/nacl/nacl_fork_delegate_linux.cc +++ b/chrome/nacl/nacl_fork_delegate_linux.cc @@ -23,7 +23,7 @@ #include "chrome/common/nacl_helper_linux.h" NaClForkDelegate::NaClForkDelegate() - : ready_(false), + : status_(kNaClHelperUnused), sandboxed_(false), fd_(-1) {} @@ -45,25 +45,31 @@ void NaClForkDelegate::Init(const bool sandboxed, base::file_handle_mapping_vector fds_to_map; fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); - ready_ = false; + + status_ = kNaClHelperUnused; FilePath helper_exe; FilePath helper_bootstrap_exe; - if (PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe) && - PathService::Get(chrome::FILE_NACL_HELPER_BOOTSTRAP, - &helper_bootstrap_exe) && - !RunningOnValgrind()) { + if (!PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe)) { + status_ = kNaClHelperMissing; + } else if (!PathService::Get(chrome::FILE_NACL_HELPER_BOOTSTRAP, + &helper_bootstrap_exe)) { + status_ = kNaClHelperBootstrapMissing; + } else if (RunningOnValgrind()) { + status_ = kNaClHelperValgrind; + } else { CommandLine cmd_line(helper_bootstrap_exe); cmd_line.AppendArgPath(helper_exe); cmd_line.AppendArgNative(kNaClHelperAtZero); base::LaunchOptions options; options.fds_to_remap = &fds_to_map; options.clone_flags = CLONE_FS | SIGCHLD; - ready_ = base::LaunchProcess(cmd_line.argv(), options, NULL); + if (!base::LaunchProcess(cmd_line.argv(), options, NULL)) + status_ = kNaClHelperLaunchFailed; // parent and error cases are handled below } if (HANDLE_EINTR(close(fds[1])) != 0) LOG(ERROR) << "close(fds[1]) failed"; - if (ready_) { + if (status_ == kNaClHelperUnused) { const ssize_t kExpectedLength = strlen(kNaClHelperStartupAck); char buf[kExpectedLength]; @@ -72,29 +78,47 @@ void NaClForkDelegate::Init(const bool sandboxed, if (nread == kExpectedLength && memcmp(buf, kNaClHelperStartupAck, nread) == 0) { // all is well + status_ = kNaClHelperSuccess; fd_ = fds[0]; return; } + + status_ = kNaClHelperAckFailed; LOG(ERROR) << "Bad NaCl helper startup ack (" << nread << " bytes)"; } // TODO(bradchen): Make this LOG(ERROR) when the NaCl helper // becomes the default. - ready_ = false; fd_ = -1; if (HANDLE_EINTR(close(fds[0])) != 0) LOG(ERROR) << "close(fds[0]) failed"; } +void NaClForkDelegate::InitialUMA(std::string* uma_name, + int* uma_sample, + int* uma_boundary_value) { + *uma_name = "NaCl.Client.Helper.InitState"; + *uma_sample = status_; + *uma_boundary_value = kNaClHelperStatusBoundary; +} + NaClForkDelegate::~NaClForkDelegate() { // side effect of close: delegate process will terminate - if (ready_) { + if (status_ == kNaClHelperSuccess) { if (HANDLE_EINTR(close(fd_)) != 0) LOG(ERROR) << "close(fd_) failed"; } } -bool NaClForkDelegate::CanHelp(const std::string& process_type) { - return (process_type == switches::kNaClLoaderProcess && ready_); +bool NaClForkDelegate::CanHelp(const std::string& process_type, + std::string* uma_name, + int* uma_sample, + int* uma_boundary_value) { + if (process_type != switches::kNaClLoaderProcess) + return false; + *uma_name = "NaCl.Client.Helper.StateOnFork"; + *uma_sample = status_; + *uma_boundary_value = kNaClHelperStatusBoundary; + return status_ == kNaClHelperSuccess; } pid_t NaClForkDelegate::Fork(const std::vector<int>& fds) { |