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

Unified Diff: extensions/browser/api/api_resource_manager.h

Issue 2294653002: Some linked_ptr -> unique_ptr conversion in extensions/browser. (Closed)
Patch Set: nullptr Created 4 years, 4 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: extensions/browser/api/api_resource_manager.h
diff --git a/extensions/browser/api/api_resource_manager.h b/extensions/browser/api/api_resource_manager.h
index 02cae3a2b60982e337313f0c4806cd08a42aa919..fbb2d22441186525602c2d2431a5f5e66d9d89a6 100644
--- a/extensions/browser/api/api_resource_manager.h
+++ b/extensions/browser/api/api_resource_manager.h
@@ -9,7 +9,7 @@
#include <memory>
#include "base/containers/hash_tables.h"
-#include "base/memory/linked_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/scoped_observer.h"
#include "base/threading/non_thread_safe.h"
@@ -180,7 +180,7 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
// where resource lifetime is handled.
class ApiResourceData : public base::RefCountedThreadSafe<ApiResourceData> {
public:
- typedef std::map<int, linked_ptr<T> > ApiResourceMap;
+ typedef std::map<int, std::unique_ptr<T>> ApiResourceMap;
// Lookup map from extension id's to allocated resource id's.
typedef std::map<std::string, base::hash_set<int> > ExtensionToResourceMap;
@@ -190,8 +190,7 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
DCHECK(ThreadingTraits::IsCalledOnValidThread());
int id = GenerateId();
if (id > 0) {
- linked_ptr<T> resource_ptr(api_resource);
- api_resource_map_[id] = resource_ptr;
+ api_resource_map_[id] = base::WrapUnique<T>(api_resource);
const std::string& extension_id = api_resource->owner_extension_id();
ExtensionToResourceMap::iterator it =
@@ -231,7 +230,7 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
DCHECK(ThreadingTraits::IsCalledOnValidThread());
T* old_resource = api_resource_map_[api_resource_id].get();
if (old_resource && extension_id == old_resource->owner_extension_id()) {
- api_resource_map_[api_resource_id] = linked_ptr<T>(api_resource);
+ api_resource_map_[api_resource_id] = base::WrapUnique<T>(api_resource);
return true;
}
return false;
@@ -281,7 +280,7 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
virtual ~ApiResourceData() {}
T* GetOwnedResource(const std::string& extension_id, int api_resource_id) {
- linked_ptr<T> ptr = api_resource_map_[api_resource_id];
+ const std::unique_ptr<T>& ptr = api_resource_map_[api_resource_id];
T* resource = ptr.get();
if (resource && extension_id == resource->owner_extension_id())
return resource;
@@ -325,7 +324,7 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
if (remove_all) {
erase = true;
} else {
- linked_ptr<T> ptr = api_resource_map_[*it];
+ std::unique_ptr<T>& ptr = api_resource_map_[*it];
T* resource = ptr.get();
erase = (resource && !resource->IsPersistent());
}

Powered by Google App Engine
This is Rietveld 408576698