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

Unified Diff: chrome/browser/extensions/api/api_resource_controller.h

Issue 10392181: Implement serial API for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: TerminalDevice -> FromCurrentPos Created 8 years, 7 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_controller.h
diff --git a/chrome/browser/extensions/api/api_resource_controller.h b/chrome/browser/extensions/api/api_resource_controller.h
index 1df2944be61aee82653207f44a91a40e70d7312f..9b01f69d47af79a531ead10c94d1176f5e96a8aa 100644
--- a/chrome/browser/extensions/api/api_resource_controller.h
+++ b/chrome/browser/extensions/api/api_resource_controller.h
@@ -32,7 +32,6 @@ class APIResourceController {
// Takes ownership of api_resource.
int AddAPIResource(APIResource* api_resource);
- bool RemoveAPIResource(int api_resource_id);
// APIResourceController knows about all classes derived from APIResource.
// This is intentional to avoid scattering potentially unsafe static_cast<>
@@ -41,21 +40,36 @@ class APIResourceController {
// Another alternative we considered and rejected was templatizing
// APIResourceController and scattering specialized versions throughout the
// codebase.
+
+ bool RemoveSocket(int api_resource_id);
+ bool RemoveSerialConnection(int api_resource_id);
+ bool RemoveUsbDeviceResource(int api_resource_id);
+
Socket* GetSocket(int api_resource_id) const;
SerialConnection* GetSerialConnection(int api_resource_id) const;
UsbDeviceResource* GetUsbDeviceResource(int api_resource_id) const;
private:
- int next_api_resource_id_;
typedef std::map<int, linked_ptr<APIResource> > APIResourceMap;
- APIResourceMap api_resource_map_;
APIResource* GetAPIResource(APIResource::APIResourceType api_resource_type,
int api_resource_id) const;
- APIResource* GetAPIResource(int api_resource_id) const;
+ bool RemoveAPIResource(APIResource::APIResourceType api_resource_type,
+ int api_resource_id);
int GenerateAPIResourceId();
+ APIResourceMap* GetResourceMapForType(
+ APIResource::APIResourceType api_resource_type) const;
+
+ int next_api_resource_id_;
+
+ // We need finer-grained control over the lifetime of these instances
+ // than RAII can give us.
+ APIResourceMap* socket_resource_map_;
+ APIResourceMap* serial_connection_resource_map_;
+ APIResourceMap* usb_device_resource_map_;
+
DISALLOW_COPY_AND_ASSIGN(APIResourceController);
};

Powered by Google App Engine
This is Rietveld 408576698