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

Unified Diff: base/observer_list.h

Issue 7134008: Revert 88151 (see crbug.com/85296) - Fix user-after-free error with ObserverList. The problem is... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months 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 | base/observer_list_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/observer_list.h
===================================================================
--- base/observer_list.h (revision 88283)
+++ base/observer_list.h (working copy)
@@ -12,7 +12,6 @@
#include "base/basictypes.h"
#include "base/logging.h"
-#include "base/memory/weak_ptr.h"
///////////////////////////////////////////////////////////////////////////////
//
@@ -62,8 +61,7 @@
class ObserverListThreadSafe;
template <class ObserverType>
-class ObserverListBase
- : public base::SupportsWeakPtr<ObserverListBase<ObserverType> > {
+class ObserverListBase {
public:
// Enumeration of which observers are notified.
enum NotificationType {
@@ -81,23 +79,21 @@
class Iterator {
public:
Iterator(ObserverListBase<ObserverType>& list)
- : list_(list.AsWeakPtr()),
+ : list_(list),
index_(0),
max_index_(list.type_ == NOTIFY_ALL ?
std::numeric_limits<size_t>::max() :
list.observers_.size()) {
- ++list_->notify_depth_;
+ ++list_.notify_depth_;
}
~Iterator() {
- if (list_ && --list_->notify_depth_ == 0)
- list_->Compact();
+ if (--list_.notify_depth_ == 0)
+ list_.Compact();
}
ObserverType* GetNext() {
- if (!list_)
- return NULL;
- ListType& observers = list_->observers_;
+ ListType& observers = list_.observers_;
// Advance if the current element is null
size_t max_index = std::min(max_index_, observers.size());
while (index_ < max_index && !observers[index_])
@@ -106,7 +102,7 @@
}
private:
- base::WeakPtr<ObserverListBase<ObserverType> > list_;
+ ObserverListBase<ObserverType>& list_;
size_t index_;
size_t max_index_;
};
« no previous file with comments | « no previous file | base/observer_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698