content_shell: Destroy WebContents before calling PlatformExit().
Previously PlatformExit() was called before WebContents is destroyed. On
Fuchsia PlatformExit destroys the Screen sigleton, but WebContents
was trying to use it while destroying the window. With this change
WebContents is destroyed before the Screen.
Bug: 778467
Change-Id: I3200e9339771b001c9b8b4fe0e311b1ef42d8d01
Reviewed-on: https://chromium-review.googlesource.com/c/1389026
Reviewed-by: Peter Beverloo <[email protected]>
Commit-Queue: Sergey Ulanov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#619740}
diff --git a/content/shell/browser/shell.cc b/content/shell/browser/shell.cc
index f13145a..4d889d1 100644
--- a/content/shell/browser/shell.cc
+++ b/content/shell/browser/shell.cc
@@ -122,6 +122,12 @@
}
}
+ // Always destroy WebContents before calling PlatformExit(). WebContents
+ // destruction sequence may depend on the resources destroyed in
+ // PlatformExit() (e.g. the display::Screen singleton).
+ web_contents_->SetDelegate(nullptr);
+ web_contents_.reset();
+
if (windows_.empty()) {
if (headless_)
PlatformExit();
@@ -132,8 +138,6 @@
if (*g_quit_main_message_loop)
std::move(*g_quit_main_message_loop).Run();
}
-
- web_contents_->SetDelegate(nullptr);
}
Shell* Shell::CreateShell(std::unique_ptr<WebContents> web_contents,