From daad30be601f55bcd9570a1412389969ca9d5ae9 Mon Sep 17 00:00:00 2001 From: "tfarina@chromium.org" Date: Fri, 27 Dec 2013 05:26:25 +0000 Subject: apps: Stop leaking TestScreen instance. gfx::Screen::SetScreenInstance() does not take the ownership of the pointer passed in and thus if the caller does not own the pointer it created and is passing to Screen, we end up leaking this object. This changes makes ShellBrowserMainParts own the TestScreen, so we don't leak and make sure the object is destroyed when ShellBrowserMainParts goes away. This should fix leak that was introduced in crrev.com/241880 BUG=None TEST=app_shell still runs normally and does not crash even more than it is used to. R=jamescook@chromium.org TBR=yoz Review URL: https://codereview.chromium.org/120583002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242597 0039d316-1c4b-4281-b951-d872f2087c98 --- apps/shell/shell_browser_main_parts.cc | 4 ++-- apps/shell/shell_browser_main_parts.h | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/shell/shell_browser_main_parts.cc b/apps/shell/shell_browser_main_parts.cc index e03fdd2..ae442f7 100644 --- a/apps/shell/shell_browser_main_parts.cc +++ b/apps/shell/shell_browser_main_parts.cc @@ -131,9 +131,9 @@ void ShellBrowserMainParts::OnRootWindowHostCloseRequested( } void ShellBrowserMainParts::CreateRootWindow() { + test_screen_.reset(aura::TestScreen::Create()); // TODO(jamescook): Replace this with a real Screen implementation. - gfx::Screen::SetScreenInstance( - gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create()); + gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); // Set up basic pieces of views::corewm. wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600))); // Ensure the X window gets mapped. diff --git a/apps/shell/shell_browser_main_parts.h b/apps/shell/shell_browser_main_parts.h index c246c03..2d02cac 100644 --- a/apps/shell/shell_browser_main_parts.h +++ b/apps/shell/shell_browser_main_parts.h @@ -11,6 +11,10 @@ #include "content/public/browser/browser_main_parts.h" #include "ui/aura/root_window_observer.h" +namespace aura { +class TestScreen; +} + namespace base { class FilePath; } @@ -80,6 +84,8 @@ class ShellBrowserMainParts : public content::BrowserMainParts, // Enable a minimal set of views::corewm to be initialized. scoped_ptr wm_test_helper_; + scoped_ptr test_screen_; + // Owned by the BrowserContextKeyedService system. extensions::ShellExtensionSystem* extension_system_; -- cgit v1.1