Index: crypto/mock_keychain_mac.cc |
=================================================================== |
--- crypto/mock_keychain_mac.cc (revision 145645) |
+++ crypto/mock_keychain_mac.cc (working copy) |
@@ -17,7 +17,7 @@ |
called_add_generic_(false), |
password_data_count_(0) {} |
-void MockKeychain::InitializeKeychainData(unsigned int key) const { |
+void MockKeychain::InitializeKeychainData(uintptr_t key) const { |
UInt32 tags[] = { kSecAccountItemAttr, |
kSecServerItemAttr, |
kSecPortItemAttr, |
@@ -61,7 +61,7 @@ |
} |
MockKeychain::~MockKeychain() { |
- for (std::map<unsigned int, SecKeychainAttributeList>::iterator it = |
+ for (std::map<uintptr_t, SecKeychainAttributeList>::iterator it = |
keychain_attr_list_.begin(); it != keychain_attr_list_.end(); ++it) { |
for (unsigned int i = 0; i < it->second.count; ++i) { |
if (it->second.attr[i].data) |
@@ -92,7 +92,7 @@ |
return &(attribute_list.attr[attribute_index]); |
} |
-void MockKeychain::SetTestDataBytes(int item, |
+void MockKeychain::SetTestDataBytes(uintptr_t item, |
UInt32 tag, |
const void* data, |
size_t length) { |
@@ -110,25 +110,30 @@ |
} |
} |
-void MockKeychain::SetTestDataString(int item, UInt32 tag, const char* value) { |
+void MockKeychain::SetTestDataString( |
+ uintptr_t item, |
+ UInt32 tag, |
+ const char* value) { |
SetTestDataBytes(item, tag, value, value ? strlen(value) : 0); |
} |
-void MockKeychain::SetTestDataPort(int item, UInt32 value) { |
+void MockKeychain::SetTestDataPort(uintptr_t item, UInt32 value) { |
SecKeychainAttribute* attribute = AttributeWithTag(keychain_attr_list_[item], |
kSecPortItemAttr); |
UInt32* data = static_cast<UInt32*>(attribute->data); |
*data = value; |
} |
-void MockKeychain::SetTestDataProtocol(int item, SecProtocolType value) { |
+void MockKeychain::SetTestDataProtocol(uintptr_t item, SecProtocolType value) { |
SecKeychainAttribute* attribute = AttributeWithTag(keychain_attr_list_[item], |
kSecProtocolItemAttr); |
SecProtocolType* data = static_cast<SecProtocolType*>(attribute->data); |
*data = value; |
} |
-void MockKeychain::SetTestDataAuthType(int item, SecAuthenticationType value) { |
+void MockKeychain::SetTestDataAuthType( |
+ uintptr_t item, |
+ SecAuthenticationType value) { |
SecKeychainAttribute* attribute = AttributeWithTag( |
keychain_attr_list_[item], kSecAuthenticationTypeItemAttr); |
SecAuthenticationType* data = static_cast<SecAuthenticationType*>( |
@@ -136,21 +141,21 @@ |
*data = value; |
} |
-void MockKeychain::SetTestDataNegativeItem(int item, Boolean value) { |
+void MockKeychain::SetTestDataNegativeItem(uintptr_t item, Boolean value) { |
SecKeychainAttribute* attribute = AttributeWithTag(keychain_attr_list_[item], |
kSecNegativeItemAttr); |
Boolean* data = static_cast<Boolean*>(attribute->data); |
*data = value; |
} |
-void MockKeychain::SetTestDataCreator(int item, OSType value) { |
+void MockKeychain::SetTestDataCreator(uintptr_t item, OSType value) { |
SecKeychainAttribute* attribute = AttributeWithTag(keychain_attr_list_[item], |
kSecCreatorItemAttr); |
OSType* data = static_cast<OSType*>(attribute->data); |
*data = value; |
} |
-void MockKeychain::SetTestDataPasswordBytes(int item, const void* data, |
+void MockKeychain::SetTestDataPasswordBytes(uintptr_t item, const void* data, |
size_t length) { |
keychain_data_[item].length = length; |
if (length > 0) { |
@@ -163,7 +168,9 @@ |
} |
} |
-void MockKeychain::SetTestDataPasswordString(int item, const char* value) { |
+void MockKeychain::SetTestDataPasswordString( |
+ uintptr_t item, |
+ const char* value) { |
SetTestDataPasswordBytes(item, value, value ? strlen(value) : 0); |
} |
@@ -175,7 +182,7 @@ |
UInt32* length, |
void** outData) const { |
DCHECK(itemRef); |
- unsigned int key = reinterpret_cast<unsigned int>(itemRef) - 1; |
+ uintptr_t key = reinterpret_cast<uintptr_t>(itemRef) - 1; |
if (keychain_attr_list_.find(key) == keychain_attr_list_.end()) |
return errSecInvalidItemRef; |
@@ -204,7 +211,7 @@ |
return errSecAuthFailed; |
} |
- unsigned int key = reinterpret_cast<unsigned int>(itemRef) - 1; |
+ uintptr_t key = reinterpret_cast<uintptr_t>(itemRef) - 1; |
if (keychain_attr_list_.find(key) == keychain_attr_list_.end()) |
return errSecInvalidItemRef; |
@@ -232,7 +239,7 @@ |
} |
OSStatus MockKeychain::ItemDelete(SecKeychainItemRef itemRef) const { |
- unsigned int key = reinterpret_cast<unsigned int>(itemRef) - 1; |
+ uintptr_t key = reinterpret_cast<uintptr_t>(itemRef) - 1; |
for (unsigned int i = 0; i < keychain_attr_list_[key].count; ++i) { |
if (keychain_attr_list_[key].attr[i].data) |
@@ -256,7 +263,7 @@ |
// Figure out which of our mock items matches, and set up the array we'll use |
// to generate results out of SearchCopyNext. |
remaining_search_results_.clear(); |
- for (std::map<unsigned int, SecKeychainAttributeList>::const_iterator it = |
+ for (std::map<uintptr_t, SecKeychainAttributeList>::const_iterator it = |
keychain_attr_list_.begin(); it != keychain_attr_list_.end(); ++it) { |
bool mock_item_matches = true; |
for (UInt32 search_attr = 0; search_attr < attrList->count; ++search_attr) { |
@@ -291,7 +298,7 @@ |
UInt16 port, |
SecProtocolType protocol, |
SecAuthenticationType authenticationType) const { |
- for (std::map<unsigned int, SecKeychainAttributeList>::const_iterator it = |
+ for (std::map<uintptr_t, SecKeychainAttributeList>::const_iterator it = |
keychain_attr_list_.begin(); it != keychain_attr_list_.end(); ++it) { |
SecKeychainAttribute* attribute; |
attribute = AttributeWithTag(it->second, kSecServerItemAttr); |
@@ -385,7 +392,7 @@ |
} |
// Pick the next unused slot. |
- unsigned int key = next_item_key_++; |
+ uintptr_t key = next_item_key_++; |
// Initialize keychain data storage at the target location. |
InitializeKeychainData(key); |
@@ -424,7 +431,7 @@ |
SecKeychainItemRef* itemRef) const { |
if (remaining_search_results_.empty()) |
return errSecItemNotFound; |
- unsigned int key = remaining_search_results_.front(); |
+ uintptr_t key = remaining_search_results_.front(); |
remaining_search_results_.erase(remaining_search_results_.begin()); |
*itemRef = reinterpret_cast<SecKeychainItemRef>(key + 1); |
++keychain_item_copy_count_; |
@@ -483,7 +490,7 @@ |
if (!ref) |
return; |
- if (reinterpret_cast<int>(ref) == kDummySearchRef) { |
+ if (reinterpret_cast<uintptr_t>(ref) == kDummySearchRef) { |
--search_copy_count_; |
} else { |
--keychain_item_copy_count_; |
@@ -515,7 +522,7 @@ |
} |
void MockKeychain::AddTestItem(const KeychainTestData& item_data) { |
- unsigned int key = next_item_key_++; |
+ uintptr_t key = next_item_key_++; |
InitializeKeychainData(key); |
SetTestDataAuthType(key, item_data.auth_type); |