| 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 a3c774062cae3fc5a47104a4f9497aaec212c180..b3f016c4229f63583dfea01d81fc504c88e6a68f 100644
|
| --- a/extensions/browser/api/api_resource_manager.h
|
| +++ b/extensions/browser/api/api_resource_manager.h
|
| @@ -129,6 +129,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,
|
| @@ -209,6 +219,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(content::BrowserThread::CurrentlyOn(thread_id_));
|
| return GetOwnedResourceIds(extension_id);
|
|
|