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

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: Morning LKGR Rebase. 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 3f63b612f74a4ace04e0db301bff3088effd64a9..56795e6d3ab4449a1f43a2850897871b119becd8 100644
--- a/extensions/browser/api/api_resource_manager.h
+++ b/extensions/browser/api/api_resource_manager.h
@@ -170,6 +170,16 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
// BrowserContextKeyedAPI implementation.
static const char* service_name() { return T::service_name(); }
+ // 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,
@@ -249,6 +259,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(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);
+ return true;
+ }
+ return false;
+ }
+
base::hash_set<int>* GetResourceIds(const std::string& extension_id) {
DCHECK(ThreadingTraits::IsCalledOnValidThread());
return GetOwnedResourceIds(extension_id);
« no previous file with comments | « chrome/test/data/extensions/api_test/sockets_tcp/api/background.js ('k') | extensions/browser/api/socket/socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698