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

Side by Side Diff: crypto/mock_apple_keychain.cc

Issue 714273004: mac: Expose keychain access frequency to Telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mock_keychain_sleep
Patch Set: Respond to offline comments from tonyg. Created 6 years 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
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 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "base/perf_util.h"
6 #include "base/time/time.h" 7 #include "base/time/time.h"
7 #include "crypto/mock_apple_keychain.h" 8 #include "crypto/mock_apple_keychain.h"
8 9
9 namespace crypto { 10 namespace crypto {
10 11
11 OSStatus MockAppleKeychain::FindGenericPassword( 12 OSStatus MockAppleKeychain::FindGenericPassword(
12 CFTypeRef keychainOrArray, 13 CFTypeRef keychainOrArray,
13 UInt32 serviceNameLength, 14 UInt32 serviceNameLength,
14 const char* serviceName, 15 const char* serviceName,
15 UInt32 accountNameLength, 16 UInt32 accountNameLength,
16 const char* accountName, 17 const char* accountName,
17 UInt32* passwordLength, 18 UInt32* passwordLength,
18 void** passwordData, 19 void** passwordData,
19 SecKeychainItemRef* itemRef) const { 20 SecKeychainItemRef* itemRef) const {
21 base::IncrementKeychainAccessHistogram();
22
20 // When simulating |noErr|, return canned |passwordData| and 23 // When simulating |noErr|, return canned |passwordData| and
21 // |passwordLength|. Otherwise, just return given code. 24 // |passwordLength|. Otherwise, just return given code.
22 if (find_generic_result_ == noErr) { 25 if (find_generic_result_ == noErr) {
23 static const char kPassword[] = "my_password"; 26 static const char kPassword[] = "my_password";
24 DCHECK(passwordData); 27 DCHECK(passwordData);
25 // The function to free this data is mocked so the cast is fine. 28 // The function to free this data is mocked so the cast is fine.
26 *passwordData = const_cast<char*>(kPassword); 29 *passwordData = const_cast<char*>(kPassword);
27 DCHECK(passwordLength); 30 DCHECK(passwordLength);
28 *passwordLength = arraysize(kPassword); 31 *passwordLength = arraysize(kPassword);
29 password_data_count_++; 32 password_data_count_++;
(...skipping 11 matching lines...) Expand all
41 44
42 OSStatus MockAppleKeychain::AddGenericPassword( 45 OSStatus MockAppleKeychain::AddGenericPassword(
43 SecKeychainRef keychain, 46 SecKeychainRef keychain,
44 UInt32 serviceNameLength, 47 UInt32 serviceNameLength,
45 const char* serviceName, 48 const char* serviceName,
46 UInt32 accountNameLength, 49 UInt32 accountNameLength,
47 const char* accountName, 50 const char* accountName,
48 UInt32 passwordLength, 51 UInt32 passwordLength,
49 const void* passwordData, 52 const void* passwordData,
50 SecKeychainItemRef* itemRef) const { 53 SecKeychainItemRef* itemRef) const {
54 base::IncrementKeychainAccessHistogram();
55
51 called_add_generic_ = true; 56 called_add_generic_ = true;
52 57
53 DCHECK_GT(passwordLength, 0U); 58 DCHECK_GT(passwordLength, 0U);
54 DCHECK(passwordData); 59 DCHECK(passwordData);
55 add_generic_password_ = 60 add_generic_password_ =
56 std::string(const_cast<char*>(static_cast<const char*>(passwordData)), 61 std::string(const_cast<char*>(static_cast<const char*>(passwordData)),
57 passwordLength); 62 passwordLength);
58 return noErr; 63 return noErr;
59 } 64 }
60 65
61 } // namespace crypto 66 } // namespace crypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698