| 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 e0c9b811865d297c0785129bb252e068f57b4a42..e4bd533ee442c7d60e5e6a8da5b6b337a769ba56 100644
|
| --- a/extensions/browser/api/api_resource_manager.h
|
| +++ b/extensions/browser/api/api_resource_manager.h
|
| @@ -131,6 +131,16 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
|
| return data_->GetResourceIds(extension_id);
|
| }
|
|
|
| + // Change the resource mapped to this |extension_id| at this
|
| + // |api_resource_id| to |resource|. Returns true and succeeds unless
|
| + // |api_resource_id| does not already identify a resource held by
|
| + // |extension_id|.
|
| + bool Replace(const std::string& extension_id,
|
| + int api_resource_id,
|
| + T* resource) {
|
| + return data_->Replace(extension_id, api_resource_id, resource);
|
| + }
|
| +
|
| protected:
|
| // content::NotificationObserver:
|
| virtual void Observe(int type,
|
| @@ -214,6 +224,22 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
|
| return GetOwnedResource(extension_id, api_resource_id);
|
| }
|
|
|
| + // Change the resource mapped to this |extension_id| at this
|
| + // |api_resource_id| to |resource|. Returns true and succeeds unless
|
| + // |api_resource_id| does not already identify a resource held by
|
| + // |extension_id|.
|
| + bool Replace(const std::string& extension_id,
|
| + int api_resource_id,
|
| + T* api_resource) {
|
| + DCHECK(content::BrowserThread::CurrentlyOn(thread_id_));
|
| + 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);
|
| + return true;
|
| + }
|
| + return false;
|
| + }
|
| +
|
| base::hash_set<int>* GetResourceIds(const std::string& extension_id) {
|
| DCHECK_CURRENTLY_ON(thread_id_);
|
| return GetOwnedResourceIds(extension_id);
|
|
|