summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 20:08:14 +0000
committerdewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 20:08:14 +0000
commitd420737a622e4d6b2e1ebf58994ee9f043b5ff23 (patch)
treef732017fb249a26337b3723f5420c9ec60aae50f /chrome
parentf20b0b5f29e9fc41f4d64c17e1d345293f038c74 (diff)
downloadchromium_src-d420737a622e4d6b2e1ebf58994ee9f043b5ff23.zip
chromium_src-d420737a622e4d6b2e1ebf58994ee9f043b5ff23.tar.gz
chromium_src-d420737a622e4d6b2e1ebf58994ee9f043b5ff23.tar.bz2
Remove memory leaks from NotificationUIManager.
NotificationDeque contains raw pointers to QueuedNotification, but they are not deleted in some scenarios. Change to use linked_ptr within the container. BUG=NONE Review URL: https://chromiumcodereview.appspot.com/12084119 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180772 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/notifications/notification_ui_manager_impl.cc12
-rw-r--r--chrome/browser/notifications/notification_ui_manager_impl.h4
2 files changed, 7 insertions, 9 deletions
diff --git a/chrome/browser/notifications/notification_ui_manager_impl.cc b/chrome/browser/notifications/notification_ui_manager_impl.cc
index bb42554..e6563ea 100644
--- a/chrome/browser/notifications/notification_ui_manager_impl.cc
+++ b/chrome/browser/notifications/notification_ui_manager_impl.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/notifications/notification_ui_manager_impl.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/fullscreen.h"
@@ -53,7 +52,6 @@ NotificationUIManagerImpl::NotificationUIManagerImpl()
}
NotificationUIManagerImpl::~NotificationUIManagerImpl() {
- STLDeleteElements(&show_queue_);
}
void NotificationUIManagerImpl::Add(const Notification& notification,
@@ -64,8 +62,8 @@ void NotificationUIManagerImpl::Add(const Notification& notification,
VLOG(1) << "Added notification. URL: "
<< notification.content_url().spec();
- show_queue_.push_back(
- new QueuedNotification(notification, profile));
+ show_queue_.push_back(linked_ptr<QueuedNotification>(
+ new QueuedNotification(notification, profile)));
CheckAndShowNotifications();
}
@@ -120,7 +118,6 @@ bool NotificationUIManagerImpl::CancelAllByProfile(Profile* profile) {
}
void NotificationUIManagerImpl::CancelAll() {
- STLDeleteElements(&show_queue_);
}
void NotificationUIManagerImpl::CheckAndShowNotifications() {
@@ -148,14 +145,15 @@ void NotificationUIManagerImpl::CheckUserState() {
}
}
+// TODO(dewittj): Eliminate recursion.
void NotificationUIManagerImpl::ShowNotifications() {
while (!show_queue_.empty()) {
- scoped_ptr<QueuedNotification> queued_notification(show_queue_.front());
+ linked_ptr<QueuedNotification> queued_notification(show_queue_.front());
show_queue_.pop_front();
if (!ShowNotification(queued_notification->notification(),
queued_notification->profile())) {
// Subclass could not show notification, put it back in the queue.
- show_queue_.push_front(queued_notification.release());
+ show_queue_.push_front(queued_notification);
return;
}
}
diff --git a/chrome/browser/notifications/notification_ui_manager_impl.h b/chrome/browser/notifications/notification_ui_manager_impl.h
index 81aa1d5..c841552 100644
--- a/chrome/browser/notifications/notification_ui_manager_impl.h
+++ b/chrome/browser/notifications/notification_ui_manager_impl.h
@@ -10,7 +10,7 @@
#include <vector>
#include "base/id_map.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/linked_ptr.h"
#include "base/prefs/public/pref_member.h"
#include "base/timer.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
@@ -80,7 +80,7 @@ class NotificationUIManagerImpl
void CheckUserState();
// A queue of notifications which are waiting to be shown.
- typedef std::deque<QueuedNotification*> NotificationDeque;
+ typedef std::deque<linked_ptr<QueuedNotification> > NotificationDeque;
NotificationDeque show_queue_;
// Registrar for the other kind of notifications (event signaling).