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

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: Added a check on whether the socket to be TLS'd has a pending read. Created 6 years, 9 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 // Change the resource mapped to this |extension_id| at this
137 // |api_resource_id| to |resource|. |api_resource_id| must already
138 // identify a resource held by |extension_id|.
139 bool Replace(const std::string& extension_id,
140 int api_resource_id,
141 T* resource) {
142 return data_->Replace(extension_id, api_resource_id, resource);
143 }
144
136 protected: 145 protected:
137 // content::NotificationObserver: 146 // content::NotificationObserver:
138 virtual void Observe(int type, 147 virtual void Observe(int type,
139 const content::NotificationSource& source, 148 const content::NotificationSource& source,
140 const content::NotificationDetails& details) OVERRIDE { 149 const content::NotificationDetails& details) OVERRIDE {
141 switch (type) { 150 switch (type) {
142 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 151 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
143 std::string id = 152 std::string id =
144 content::Details<extensions::UnloadedExtensionInfo>(details)-> 153 content::Details<extensions::UnloadedExtensionInfo>(details)->
145 extension->id(); 154 extension->id();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 extension_resource_map_[extension_id].erase(api_resource_id); 216 extension_resource_map_[extension_id].erase(api_resource_id);
208 api_resource_map_.erase(api_resource_id); 217 api_resource_map_.erase(api_resource_id);
209 } 218 }
210 } 219 }
211 220
212 T* Get(const std::string& extension_id, int api_resource_id) { 221 T* Get(const std::string& extension_id, int api_resource_id) {
213 DCHECK(content::BrowserThread::CurrentlyOn(thread_id_)); 222 DCHECK(content::BrowserThread::CurrentlyOn(thread_id_));
214 return GetOwnedResource(extension_id, api_resource_id); 223 return GetOwnedResource(extension_id, api_resource_id);
215 } 224 }
216 225
226 // Change the resource mapped to this |extension_id| at this
227 // |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.
228 // identify a resource held by |extension_id|.
229 bool Replace(const std::string& extension_id,
230 int api_resource_id,
231 T* api_resource) {
232 DCHECK(content::BrowserThread::CurrentlyOn(thread_id_));
233 T* old_resource = api_resource_map_[api_resource_id].get();
234 if (old_resource && extension_id == old_resource->owner_extension_id()) {
235 api_resource_map_[api_resource_id] = linked_ptr<T>(api_resource);
236 return true;
237 }
238 return false;
239 }
240
217 base::hash_set<int>* GetResourceIds(const std::string& extension_id) { 241 base::hash_set<int>* GetResourceIds(const std::string& extension_id) {
218 DCHECK(content::BrowserThread::CurrentlyOn(thread_id_)); 242 DCHECK(content::BrowserThread::CurrentlyOn(thread_id_));
219 return GetOwnedResourceIds(extension_id); 243 return GetOwnedResourceIds(extension_id);
220 } 244 }
221 245
222 void InitiateExtensionUnloadedCleanup(const std::string& extension_id) { 246 void InitiateExtensionUnloadedCleanup(const std::string& extension_id) {
223 content::BrowserThread::PostTask(thread_id_, FROM_HERE, 247 content::BrowserThread::PostTask(thread_id_, FROM_HERE,
224 base::Bind(&ApiResourceData::CleanupResourcesFromUnloadedExtension, 248 base::Bind(&ApiResourceData::CleanupResourcesFromUnloadedExtension,
225 this, extension_id)); 249 this, extension_id));
226 } 250 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 }; 349 };
326 350
327 content::BrowserThread::ID thread_id_; 351 content::BrowserThread::ID thread_id_;
328 content::NotificationRegistrar registrar_; 352 content::NotificationRegistrar registrar_;
329 scoped_refptr<ApiResourceData> data_; 353 scoped_refptr<ApiResourceData> data_;
330 }; 354 };
331 355
332 } // namespace extensions 356 } // namespace extensions
333 357
334 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_ 358 #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