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

Unified Diff: base/id_map.h

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Created 4 years, 1 month 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 | chrome/browser/android/compositor/layer_title_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/id_map.h
diff --git a/base/id_map.h b/base/id_map.h
index 8702982f172ffd0f06725207f296104946965d4d..7bdfd429d6dd6841ed859acbd5f13321220dae57 100644
--- a/base/id_map.h
+++ b/base/id_map.h
@@ -17,8 +17,13 @@
#include "base/macros.h"
#include "base/sequence_checker.h"
-// Ownership semantics - own pointer means the pointer is deleted in Remove()
-// & during destruction
+// Ownership semantics:
+// - OwnPointer means we store a unique_ptr that owns the object (so the
+// object is deleted in Remove() and during destruction).
+// - ExternalPointer means we store a raw pointer and don't own the object
+
+// TODO (http://crbug.com/647091): eliminate this enum, replace OwnPointer
+// mode in callsites with IDMap<unique_ptr<T>>
enum IDMapOwnershipSemantics {
IDMapExternalPointer,
IDMapOwnPointer
@@ -82,15 +87,12 @@ class IDMap {
AddWithIDInternal(std::move(data), id);
}
- // http://crbug.com/647091: Raw pointer Add()s in IDMapOwnPointer mode are
- // deprecated. Users of IDMapOwnPointer should transition to the unique_ptr
- // variant above, and the following methods should only be used in
- // IDMapExternalPointer mode.
+ // The following two methods are used in IDMapExternalPointer mode.
KeyType Add(T* data) {
aelias_OOO_until_Jul13 2016/11/08 01:55:09 I don't think the explicit overloading is needed a
- return AddInternal(V(data));
+ return AddInternal(data);
}
void AddWithID(T* data, KeyType id) {
- AddWithIDInternal(V(data), id);
+ AddWithIDInternal(data, id);
}
void Remove(KeyType id) {
« no previous file with comments | « no previous file | chrome/browser/android/compositor/layer_title_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698