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

Unified Diff: chrome/browser/extensions/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: Added a check on whether the socket to be TLS'd has a pending read. Created 6 years, 10 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: chrome/browser/extensions/api/api_resource_manager.h
diff --git a/chrome/browser/extensions/api/api_resource_manager.h b/chrome/browser/extensions/api/api_resource_manager.h
index b459c2292b30c3fdf2ad3ea64dbd79b54b68081c..129b6b2ce9613de74f2295591433d9057f5512ca 100644
--- a/chrome/browser/extensions/api/api_resource_manager.h
+++ b/chrome/browser/extensions/api/api_resource_manager.h
@@ -133,6 +133,15 @@ class ApiResourceManager : public ProfileKeyedAPI,
return data_->GetResourceIds(extension_id);
}
+ // Change the resource mapped to this |extension_id| at this
+ // |api_resource_id| to |resource|. |api_resource_id| must 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 +223,21 @@ class ApiResourceManager : public ProfileKeyedAPI,
return GetOwnedResource(extension_id, api_resource_id);
}
+ // Change the resource mapped to this |extension_id| at this
+ // |api_resource_id| to |resource|. |api_resource_id| must already
Ryan Sleevi 2014/03/12 23:35:27 nit: double spaces were re-introduced (and on line
lally 2014/03/17 01:58:06 Ugh, old habits die hard.
+ // 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);
« no previous file with comments | « no previous file | chrome/browser/extensions/api/socket/socket.h » ('j') | chrome/browser/extensions/api/socket/socket.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698