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

Unified Diff: chrome/chrome_watcher/chrome_watcher_main.cc

Issue 796963002: Instrument some of the exit paths likely to suffer hangs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@end_session_instrument
Patch Set: Add instrumentation for browser exit, plus now actually compiles Created 6 years 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
Index: chrome/chrome_watcher/chrome_watcher_main.cc
diff --git a/chrome/chrome_watcher/chrome_watcher_main.cc b/chrome/chrome_watcher/chrome_watcher_main.cc
index 84706a0ee5f73c995a39a4073ba5091997241743..ea6756b9e6ed6df33ada705fd9cd5ba356b87fa5 100644
--- a/chrome/chrome_watcher/chrome_watcher_main.cc
+++ b/chrome/chrome_watcher/chrome_watcher_main.cc
@@ -7,8 +7,10 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/logging_win.h"
+#include "base/process/process_handle.h"
#include "base/template_util.h"
#include "components/browser_watcher/exit_code_watcher_win.h"
+#include "components/browser_watcher/exit_funnel_win.h"
#include "components/browser_watcher/watcher_main_api_win.h"
namespace {
@@ -42,8 +44,30 @@ extern "C" int WatcherMain(const base::char16* registry_path) {
// Attempt to wait on our parent process, and record its exit status.
if (exit_code_watcher.ParseArguments(
*base::CommandLine::ForCurrentProcess())) {
+ base::ProcessHandle dupe = base::kNullProcessHandle;
rvargas (doing something else) 2014/12/13 01:32:53 It would be nice to use base::Process here... but
+ // Duplicate the process handle for the exit funnel due to the wonky
+ // process handle lifetime management in base.
+ if (!::DuplicateHandle(base::GetCurrentProcessHandle(),
+ exit_code_watcher.process(),
+ base::GetCurrentProcessHandle(),
+ &dupe,
+ 0,
+ FALSE,
+ DUPLICATE_SAME_ACCESS)) {
+ dupe = base::kNullProcessHandle;
+ }
+
// Wait on the process.
exit_code_watcher.WaitForExit();
+
+ if (dupe != base::kNullProcessHandle) {
+ browser_watcher::ExitFunnel funnel;
+ funnel.Init(registry_path, dupe);
+ funnel.RecordEvent(L"BrowserExit");
+
+ base::CloseProcessHandle(dupe);
+ }
+
ret = 0;
}

Powered by Google App Engine
This is Rietveld 408576698