Index: crypto/mock_keychain_mac.h |
=================================================================== |
--- crypto/mock_keychain_mac.h (revision 145645) |
+++ crypto/mock_keychain_mac.h (working copy) |
@@ -16,6 +16,12 @@ |
namespace crypto { |
+// type used for the keys in the std::map(s) |
stuartmorgan
2012/07/19 18:35:14
Please follow Chromium style for comments; this sh
|
+typedef uintptr_t MockKeychainKeyType; |
+ |
+// type used to identify MockKeychain items |
+typedef uintptr_t MockKeychainItemType; |
+ |
// Mock Keychain wrapper for testing code that interacts with the OS X |
// Keychain. Implemented by storing SecKeychainAttributeList and |
// KeychainPasswordData values in separate mutable containers and |
@@ -150,34 +156,44 @@ |
SecProtocolType protocol, |
SecAuthenticationType authenticationType) const; |
// Initializes storage for keychain data at |key|. |
- void InitializeKeychainData(unsigned int key) const; |
+ void InitializeKeychainData(MockKeychainKeyType key) const; |
// Sets the data and length of |tag| in the item-th test item. |
- void SetTestDataBytes(int item, UInt32 tag, const void* data, size_t length); |
+ void SetTestDataBytes( |
+ MockKeychainItemType item, |
+ UInt32 tag, |
+ const void* data, |
+ size_t length); |
// Sets the data and length of |tag| in the item-th test item based on |
// |value|. The null-terminator will not be included; the Keychain Services |
// docs don't indicate whether it is or not, so clients should not assume |
// that it will be. |
- void SetTestDataString(int item, UInt32 tag, const char* value); |
+ void SetTestDataString(MockKeychainItemType item, |
+ UInt32 tag, |
+ const char* value); |
// Sets the data of the corresponding attribute of the item-th test item to |
// |value|. Assumes that the space has alread been allocated, and the length |
// set. |
- void SetTestDataPort(int item, UInt32 value); |
- void SetTestDataProtocol(int item, SecProtocolType value); |
- void SetTestDataAuthType(int item, SecAuthenticationType value); |
- void SetTestDataNegativeItem(int item, Boolean value); |
- void SetTestDataCreator(int item, OSType value); |
+ void SetTestDataPort(MockKeychainItemType item, UInt32 value); |
+ void SetTestDataProtocol(MockKeychainItemType item, SecProtocolType value); |
+ void SetTestDataAuthType(MockKeychainItemType item, |
+ SecAuthenticationType value); |
+ void SetTestDataNegativeItem(MockKeychainItemType item, Boolean value); |
+ void SetTestDataCreator(MockKeychainItemType item, OSType value); |
// Sets the password data and length for the item-th test item. |
- void SetTestDataPasswordBytes(int item, const void* data, size_t length); |
+ void SetTestDataPasswordBytes( |
+ MockKeychainItemType item, |
+ const void* data, |
+ size_t length); |
// Sets the password for the item-th test item. As with SetTestDataString, |
// the data will not be null-terminated. |
- void SetTestDataPasswordString(int item, const char* value); |
+ void SetTestDataPasswordString(MockKeychainItemType item, const char* value); |
// Returns the address of the attribute in attribute_list with tag |tag|. |
static SecKeychainAttribute* AttributeWithTag( |
const SecKeychainAttributeList& attribute_list, |
UInt32 tag); |
- static const int kDummySearchRef = 1000; |
+ static const MockKeychainKeyType kDummySearchRef = 1000; |
typedef struct KeychainPasswordData { |
KeychainPasswordData() : data(NULL), length(0) {} |
@@ -187,15 +203,16 @@ |
// Mutable because the MockKeychain API requires its internal keychain storage |
// to be modifiable by users of this class. |
- mutable std::map<unsigned int, SecKeychainAttributeList> keychain_attr_list_; |
- mutable std::map<unsigned int, KeychainPasswordData> keychain_data_; |
- mutable unsigned int next_item_key_; |
+ mutable std::map<MockKeychainKeyType, |
+ SecKeychainAttributeList> keychain_attr_list_; |
+ mutable std::map<MockKeychainKeyType, KeychainPasswordData> keychain_data_; |
+ mutable MockKeychainItemType next_item_key_; |
// Tracks the items that should be returned in subsequent calls to |
// SearchCopyNext, based on the last call to SearchCreateFromAttributes. |
// We can't handle multiple active searches, since we don't track the search |
// ref we return, but we don't need to for our mocking. |
- mutable std::vector<unsigned int> remaining_search_results_; |
+ mutable std::vector<MockKeychainKeyType> remaining_search_results_; |
// Track copies and releases to make sure they balance. Really these should |
// be maps to track per item, but this should be good enough to catch |
@@ -205,7 +222,7 @@ |
mutable int attribute_data_copy_count_; |
// Tracks which items (by key) were added with AddInternetPassword. |
- mutable std::set<unsigned int> added_via_api_; |
+ mutable std::set<MockKeychainKeyType> added_via_api_; |
// Result code for the |FindGenericPassword()| method. |
OSStatus find_generic_result_; |
@@ -215,7 +232,7 @@ |
// Tracks the allocations and frees of password data in |FindGenericPassword| |
// and |ItemFreeContent|. |
- mutable unsigned int password_data_count_; |
+ mutable int password_data_count_; |
// Records the password being set when |AddGenericPassword()| gets called. |
mutable std::string add_generic_password_; |