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

Side by Side 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: Double. Spaces removed. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 T* Get(const std::string& extension_id, int api_resource_id) { 128 T* Get(const std::string& extension_id, int api_resource_id) {
129 return data_->Get(extension_id, api_resource_id); 129 return data_->Get(extension_id, api_resource_id);
130 } 130 }
131 131
132 base::hash_set<int>* GetResourceIds(const std::string& extension_id) { 132 base::hash_set<int>* GetResourceIds(const std::string& extension_id) {
133 return data_->GetResourceIds(extension_id); 133 return data_->GetResourceIds(extension_id);
134 } 134 }
135 135
136 bool Set(const std::string& extension_id, int api_resource_id, T* resource) {
137 return data_->Set(extension_id, api_resource_id, resource);
138 }
139
136 protected: 140 protected:
137 // content::NotificationObserver: 141 // content::NotificationObserver:
138 virtual void Observe(int type, 142 virtual void Observe(int type,
139 const content::NotificationSource& source, 143 const content::NotificationSource& source,
140 const content::NotificationDetails& details) OVERRIDE { 144 const content::NotificationDetails& details) OVERRIDE {
141 switch (type) { 145 switch (type) {
142 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 146 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
143 std::string id = 147 std::string id =
144 content::Details<extensions::UnloadedExtensionInfo>(details)-> 148 content::Details<extensions::UnloadedExtensionInfo>(details)->
145 extension->id(); 149 extension->id();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 extension_resource_map_[extension_id].erase(api_resource_id); 211 extension_resource_map_[extension_id].erase(api_resource_id);
208 api_resource_map_.erase(api_resource_id); 212 api_resource_map_.erase(api_resource_id);
209 } 213 }
210 } 214 }
211 215
212 T* Get(const std::string& extension_id, int api_resource_id) { 216 T* Get(const std::string& extension_id, int api_resource_id) {
213 DCHECK(content::BrowserThread::CurrentlyOn(thread_id_)); 217 DCHECK(content::BrowserThread::CurrentlyOn(thread_id_));
214 return GetOwnedResource(extension_id, api_resource_id); 218 return GetOwnedResource(extension_id, api_resource_id);
215 } 219 }
216 220
221 bool Set(const std::string& extension_id,
Ryan Sleevi 2014/02/24 20:06:49 I know this is not your code, and so the lack of d
lally 2014/02/27 17:05:59 I've renamed it Replace(), and documented that it
lally 2014/02/27 21:43:19 I just checked with Renaud, yup, the extension_ids
222 int api_resource_id,
223 T* api_resource) {
224 DCHECK(content::BrowserThread::CurrentlyOn(thread_id_));
225 T* old_resource = api_resource_map_[api_resource_id].get();
226 if (old_resource && extension_id == old_resource->owner_extension_id()) {
227 api_resource_map_[api_resource_id] = linked_ptr<T>(api_resource);
228 return true;
229 }
230 return false;
231 }
232
217 base::hash_set<int>* GetResourceIds(const std::string& extension_id) { 233 base::hash_set<int>* GetResourceIds(const std::string& extension_id) {
218 DCHECK(content::BrowserThread::CurrentlyOn(thread_id_)); 234 DCHECK(content::BrowserThread::CurrentlyOn(thread_id_));
219 return GetOwnedResourceIds(extension_id); 235 return GetOwnedResourceIds(extension_id);
220 } 236 }
221 237
222 void InitiateExtensionUnloadedCleanup(const std::string& extension_id) { 238 void InitiateExtensionUnloadedCleanup(const std::string& extension_id) {
223 content::BrowserThread::PostTask(thread_id_, FROM_HERE, 239 content::BrowserThread::PostTask(thread_id_, FROM_HERE,
224 base::Bind(&ApiResourceData::CleanupResourcesFromUnloadedExtension, 240 base::Bind(&ApiResourceData::CleanupResourcesFromUnloadedExtension,
225 this, extension_id)); 241 this, extension_id));
226 } 242 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 }; 341 };
326 342
327 content::BrowserThread::ID thread_id_; 343 content::BrowserThread::ID thread_id_;
328 content::NotificationRegistrar registrar_; 344 content::NotificationRegistrar registrar_;
329 scoped_refptr<ApiResourceData> data_; 345 scoped_refptr<ApiResourceData> data_;
330 }; 346 };
331 347
332 } // namespace extensions 348 } // namespace extensions
333 349
334 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_ 350 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_
OLDNEW
« 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