Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1715)

Unified Diff: chrome/browser/install_verification/win/install_verification.cc

Issue 2055613002: Report hash of Chrome's parent process name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code review changes Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/install_verification/win/install_verification.cc
diff --git a/chrome/browser/install_verification/win/install_verification.cc b/chrome/browser/install_verification/win/install_verification.cc
index 82c1d8180b301e33ea854812ed53a37ea03c234b..41c16f14670cd57339cb2fd076f20caa0e5df5b1 100644
--- a/chrome/browser/install_verification/win/install_verification.cc
+++ b/chrome/browser/install_verification/win/install_verification.cc
@@ -5,15 +5,22 @@
#include "chrome/browser/install_verification/win/install_verification.h"
#include <stddef.h>
+#include <windows.h>
#include <set>
#include <vector>
+#include "base/files/file_path.h"
#include "base/metrics/sparse_histogram.h"
+#include "base/process/process.h"
+#include "base/process/process_handle.h"
+#include "base/strings/string_util.h"
+#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/install_verification/win/loaded_module_verification.h"
#include "chrome/browser/install_verification/win/module_ids.h"
#include "chrome/browser/install_verification/win/module_info.h"
#include "chrome/browser/install_verification/win/module_verification_common.h"
+#include "components/variations/metrics_util.h"
namespace {
@@ -21,9 +28,53 @@ void ReportModuleMatch(size_t module_id) {
UMA_HISTOGRAM_SPARSE_SLOWLY("InstallVerifier.ModuleMatch", module_id);
}
+base::FilePath GetExeFilePathForProcess(const base::Process& process) {
+ wchar_t exe_name[MAX_PATH];
+ DWORD exe_name_len = arraysize(exe_name);
+ // Note: requesting the Win32 path format.
+ if (::QueryFullProcessImageName(process.Handle(), 0, exe_name,
+ &exe_name_len) == 0) {
+ DPLOG(ERROR) << "Failed to get executable name for process";
+ return base::FilePath();
+ }
+
+ // QueryFullProcessImageName's documentation does not specify behavior when
+ // the buffer is too small, but we know that GetModuleFileNameEx succeeds and
+ // truncates the returned name in such a case. Given that paths of arbitrary
+ // length may exist, the conservative approach is to reject names when
+ // the returned length is that of the buffer.
+ if (exe_name_len > 0 && exe_name_len < arraysize(exe_name))
+ return base::FilePath(exe_name);
+
+ return base::FilePath();
+}
+
+void ReportParentProcessName() {
+ base::ProcessId ppid =
+ base::GetParentProcessId(base::GetCurrentProcessHandle());
+
+ base::Process process(
+ base::Process::OpenWithAccess(ppid, PROCESS_QUERY_LIMITED_INFORMATION));
+
+ uint32_t hash = 0U;
+
+ if (process.IsValid()) {
+ base::FilePath path(GetExeFilePathForProcess(process));
+
+ if (!path.empty()) {
+ std::string ascii_path(base::SysWideToUTF8(path.BaseName().value()));
+ DCHECK(base::IsStringASCII(ascii_path));
+ hash = metrics::HashName(base::ToLowerASCII(ascii_path));
+ }
+ }
+
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Windows.ParentProcessNameHash", hash);
+}
+
} // namespace
void VerifyInstallation() {
+ ReportParentProcessName();
ModuleIDs module_ids;
LoadModuleIDs(&module_ids);
std::set<ModuleInfo> loaded_modules;
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698