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

Unified Diff: chrome/browser/extensions/extension_warning_set.h

Issue 10909096: Remove use of linked_ptr from ExtensionWarningSet Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
Index: chrome/browser/extensions/extension_warning_set.h
diff --git a/chrome/browser/extensions/extension_warning_set.h b/chrome/browser/extensions/extension_warning_set.h
index 44494b06477d5c0a27d373d9ba9bfc34d99e45e7..7e5fc5c50050d11a27c690ae355b6af617ab0d6f 100644
--- a/chrome/browser/extensions/extension_warning_set.h
+++ b/chrome/browser/extensions/extension_warning_set.h
@@ -9,7 +9,6 @@
#include <string>
#include <vector>
-#include "base/memory/linked_ptr.h"
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "base/threading/non_thread_safe.h"
@@ -102,14 +101,19 @@ class ExtensionWarning {
// Compare ExtensionWarnings based on the tuple of (extension_id, type).
// The message associated with ExtensionWarnings is purely informational
// and does not contribute to distinguishing extensions.
-bool operator<(const linked_ptr<ExtensionWarning>& a,
- const linked_ptr<ExtensionWarning>& b);
+class ExtensionWarningComparator
+ : public std::binary_function<ExtensionWarning*, ExtensionWarning*, bool> {
+ public:
+ bool operator()(ExtensionWarning* a, ExtensionWarning* b) const;
+};
// Container for ExtensionWarnings intended to be passed between threads.
// This exists to work around the lack of thread-safety of linke_ptrs.
// Only one thread should have access to an ExtensionWarningSet at any time.
class ExtensionWarningSet {
public:
+ typedef std::set<ExtensionWarning*, ExtensionWarningComparator> Set;
+
ExtensionWarningSet();
~ExtensionWarningSet();
@@ -118,13 +122,15 @@ class ExtensionWarningSet {
// insertion is ignored.
void Insert(scoped_ptr<ExtensionWarning> warning);
- // Returns and resets |warnings_|.
- std::set<linked_ptr<ExtensionWarning> > Release();
+ // Returns and resets |warnings_|. The ownership of the ExtensionWarnings
+ // is passed to the caller.
+ Set Release();
bool IsEmpty() const;
private:
- std::set<linked_ptr<ExtensionWarning> > warnings_;
+ // We own the objects in this dictionary.
+ Set warnings_;
DISALLOW_COPY_AND_ASSIGN(ExtensionWarningSet);
};
@@ -179,19 +185,19 @@ class ExtensionWarningService : public base::NonThreadSafe {
virtual void NotifyWarningsChanged();
private:
- typedef std::set<linked_ptr<ExtensionWarning> >::const_iterator
- const_iterator;
- typedef std::set<linked_ptr<ExtensionWarning> >::iterator iterator;
+ typedef ExtensionWarningSet::Set::const_iterator const_iterator;
+ typedef ExtensionWarningSet::Set::iterator iterator;
// Shows or hides the warning badge on the wrench menu depending on whether
// any non-suppressed warnings exist.
void UpdateWarningBadge();
- // Currently existing warnings.
- std::set<linked_ptr<ExtensionWarning> > warnings_;
+ // Currently existing warnings. We own these warnings.
+ ExtensionWarningSet::Set warnings_;
// Warnings that do not trigger a badge on the wrench menu.
- std::set<linked_ptr<ExtensionWarning> > badge_suppressions_;
+ // Weak pointers to objects in |warnings_|.
+ ExtensionWarningSet::Set badge_suppressions_;
Profile* profile_;
};

Powered by Google App Engine
This is Rietveld 408576698