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

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

Issue 76403004: An implementation of chrome.socket.secure(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Stop using Profile and move completely to URLRequestContext. Created 6 years, 5 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 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);

Powered by Google App Engine
This is Rietveld 408576698