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

Unified Diff: tools/telemetry/telemetry/core/backends/chrome/desktop_browser_backend.py

Issue 726563003: Shut down browser processes on Windows by sending WM_CLOSE messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed tab character Created 6 years, 1 month 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/telemetry/telemetry/core/platform/__init__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/backends/chrome/desktop_browser_backend.py
diff --git a/tools/telemetry/telemetry/core/backends/chrome/desktop_browser_backend.py b/tools/telemetry/telemetry/core/backends/chrome/desktop_browser_backend.py
index e4e0ff2bbbb15c44ea74196bf128bd57f4f93e09..b7bfb5ade81539383ec75f9f9da51f08b3361b2f 100644
--- a/tools/telemetry/telemetry/core/backends/chrome/desktop_browser_backend.py
+++ b/tools/telemetry/telemetry/core/backends/chrome/desktop_browser_backend.py
@@ -326,9 +326,28 @@ class DesktopBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
def __del__(self):
self.Close()
+ def _TryCooperativeShutdown(self):
+ if self.browser.platform.IsCooperativeShutdownSupported():
+ # Ideally there would be a portable, cooperative shutdown
+ # mechanism for the browser. This seems difficult to do
+ # correctly for all embedders of the content API. The only known
+ # problem with unclean shutdown of the browser process is on
+ # Windows, where suspended child processes frequently leak. For
+ # now, just solve this particular problem. See Issue 424024.
+ if self.browser.platform.CooperativelyShutdown(self._proc, "chrome"):
+ try:
+ util.WaitFor(lambda: not self.IsBrowserRunning(), timeout=5)
+ logging.info('Successfully shut down browser cooperatively')
+ except util.TimeoutException as e:
+ logging.warning('Failed to cooperatively shutdown. ' +
+ 'Proceeding to terminate: ' + str(e))
+
def Close(self):
super(DesktopBrowserBackend, self).Close()
+ if self.IsBrowserRunning():
+ self._TryCooperativeShutdown()
+
# Shutdown politely if the profile may be used again.
if self._output_profile_path and self.IsBrowserRunning():
self._proc.terminate()
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/platform/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698