diff options
author | earthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-01 12:28:58 +0000 |
---|---|---|
committer | earthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-01 12:28:58 +0000 |
commit | 035213a6e5c49f37dcc7966b02efc2b6f14d2c84 (patch) | |
tree | 4899c02810b77c33ec9794d3cf5533a861bdc6ec /chrome/browser/notifications | |
parent | 9fe3063fc361cb46b2b7cd4329e08022d921da27 (diff) | |
download | chromium_src-035213a6e5c49f37dcc7966b02efc2b6f14d2c84.zip chromium_src-035213a6e5c49f37dcc7966b02efc2b6f14d2c84.tar.gz chromium_src-035213a6e5c49f37dcc7966b02efc2b6f14d2c84.tar.bz2 |
Fix memory leaks in ChromeNotifierDelegateBrowserTest.*.
BUG=314040
R=dewittj@chromium.org
Review URL: https://codereview.chromium.org/55763003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232340 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications')
-rw-r--r-- | chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_browsertest.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_browsertest.cc b/chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_browsertest.cc index 50e7ebd..0dd6e60 100644 --- a/chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_browsertest.cc +++ b/chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_browsertest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/memory/scoped_vector.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/notifications/sync_notifier/chrome_notifier_delegate.h" #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" @@ -47,7 +48,11 @@ class StubChromeNotifierService : public notifier::ChromeNotifierService { read_state); // Set enough fields in sync_data, including specifics, for our tests // to pass. - return new notifier::SyncedNotification(sync_data); + notifier::SyncedNotification* notification = + new notifier::SyncedNotification(sync_data); + // Retain ownership to avoid memory leaks in tests. + owned_notifications_.push_back(notification); + return notification; } // For testing, just return our test notification no matter what key the @@ -62,6 +67,7 @@ class StubChromeNotifierService : public notifier::ChromeNotifierService { private: std::string read_id_; + ScopedVector<notifier::SyncedNotification> owned_notifications_; }; class ChromeNotifierDelegateBrowserTest : public InProcessBrowserTest {}; @@ -78,8 +84,8 @@ class ChromeNotifierDelegateBrowserTest : public InProcessBrowserTest {}; IN_PROC_BROWSER_TEST_F(ChromeNotifierDelegateBrowserTest, MAYBE_ClickTest) { std::string id(kTestNotificationId); StubChromeNotifierService notifier; - notifier::ChromeNotifierDelegate* delegate = - new notifier::ChromeNotifierDelegate(id, ¬ifier); + scoped_refptr<notifier::ChromeNotifierDelegate> delegate( + new notifier::ChromeNotifierDelegate(id, ¬ifier)); // Set up an observer to wait for the navigation content::WindowedNotificationObserver observer( @@ -111,8 +117,8 @@ IN_PROC_BROWSER_TEST_F(ChromeNotifierDelegateBrowserTest, MAYBE_ButtonClickTest) { std::string id(kTestNotificationId); StubChromeNotifierService notifier; - notifier::ChromeNotifierDelegate* delegate = - new notifier::ChromeNotifierDelegate(id, ¬ifier); + scoped_refptr<notifier::ChromeNotifierDelegate> delegate( + new notifier::ChromeNotifierDelegate(id, ¬ifier)); // Set up an observer to wait for the navigation content::WindowedNotificationObserver observer( @@ -145,8 +151,8 @@ IN_PROC_BROWSER_TEST_F(ChromeNotifierDelegateBrowserTest, IN_PROC_BROWSER_TEST_F(ChromeNotifierDelegateBrowserTest, CloseTest) { std::string id(kTestNotificationId); StubChromeNotifierService notifier; - notifier::ChromeNotifierDelegate* delegate = - new notifier::ChromeNotifierDelegate(id, ¬ifier); + scoped_refptr<notifier::ChromeNotifierDelegate> delegate( + new notifier::ChromeNotifierDelegate(id, ¬ifier)); delegate->Close(false); ASSERT_EQ("", notifier.read_id()); |