OLD | NEW |
---|---|
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 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/time.h" | 6 #include "base/time.h" |
7 #include "chrome/browser/mock_keychain_mac.h" | 7 #include "crypto/mock_keychain_mac.h" |
8 | |
9 namespace crypto { | |
8 | 10 |
9 MockKeychain::MockKeychain() | 11 MockKeychain::MockKeychain() |
10 : next_item_key_(0), | 12 : next_item_key_(0), |
11 search_copy_count_(0), | 13 search_copy_count_(0), |
12 keychain_item_copy_count_(0), | 14 keychain_item_copy_count_(0), |
13 attribute_data_copy_count_(0), | 15 attribute_data_copy_count_(0), |
14 find_generic_result_(noErr), | 16 find_generic_result_(noErr), |
15 called_add_generic_(false), | 17 called_add_generic_(false), |
16 password_data_count_(0) {} | 18 password_data_count_(0) {} |
17 | 19 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 keychain_attr_list_[key].attr[i].length = data_size; | 57 keychain_attr_list_[key].attr[i].length = data_size; |
56 keychain_attr_list_[key].attr[i].data = calloc(1, data_size); | 58 keychain_attr_list_[key].attr[i].data = calloc(1, data_size); |
57 } | 59 } |
58 } | 60 } |
59 } | 61 } |
60 | 62 |
61 MockKeychain::~MockKeychain() { | 63 MockKeychain::~MockKeychain() { |
62 for (std::map<unsigned int, SecKeychainAttributeList>::iterator it = | 64 for (std::map<unsigned int, SecKeychainAttributeList>::iterator it = |
63 keychain_attr_list_.begin(); it != keychain_attr_list_.end(); ++it) { | 65 keychain_attr_list_.begin(); it != keychain_attr_list_.end(); ++it) { |
64 for (unsigned int i = 0; i < it->second.count; ++i) { | 66 for (unsigned int i = 0; i < it->second.count; ++i) { |
65 if (it->second.attr[i].data) { | 67 if (it->second.attr[i].data) { |
Ryan Sleevi
2012/03/16 20:58:37
nit: Per http://www.chromium.org/developers/coding
akalin
2012/03/17 07:19:44
I made a pass to clean up simple if statements and
| |
66 free(it->second.attr[i].data); | 68 free(it->second.attr[i].data); |
67 } | 69 } |
68 } | 70 } |
69 free(it->second.attr); | 71 free(it->second.attr); |
70 if (keychain_data_[it->first].data) { | 72 if (keychain_data_[it->first].data) { |
71 free(keychain_data_[it->first].data); | 73 free(keychain_data_[it->first].data); |
72 } | 74 } |
73 } | 75 } |
74 keychain_attr_list_.clear(); | 76 keychain_attr_list_.clear(); |
75 keychain_data_.clear(); | 77 keychain_data_.clear(); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 SetTestDataProtocol(key, item_data.protocol); | 518 SetTestDataProtocol(key, item_data.protocol); |
517 SetTestDataString(key, kSecPathItemAttr, item_data.path); | 519 SetTestDataString(key, kSecPathItemAttr, item_data.path); |
518 SetTestDataPort(key, item_data.port); | 520 SetTestDataPort(key, item_data.port); |
519 SetTestDataString(key, kSecSecurityDomainItemAttr, | 521 SetTestDataString(key, kSecSecurityDomainItemAttr, |
520 item_data.security_domain); | 522 item_data.security_domain); |
521 SetTestDataString(key, kSecCreationDateItemAttr, item_data.creation_date); | 523 SetTestDataString(key, kSecCreationDateItemAttr, item_data.creation_date); |
522 SetTestDataString(key, kSecAccountItemAttr, item_data.username); | 524 SetTestDataString(key, kSecAccountItemAttr, item_data.username); |
523 SetTestDataPasswordString(key, item_data.password); | 525 SetTestDataPasswordString(key, item_data.password); |
524 SetTestDataNegativeItem(key, item_data.negative_item); | 526 SetTestDataNegativeItem(key, item_data.negative_item); |
525 } | 527 } |
528 | |
529 } // namespace crypto | |
OLD | NEW |