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

Side by Side Diff: components/os_crypt/os_crypt_mac.mm

Issue 714273004: mac: Expose keychain access frequency to Telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mock_keychain_sleep
Patch Set: Add a common subclass to measurements. Created 6 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/os_crypt/os_crypt.h" 5 #include "components/os_crypt/os_crypt.h"
6 6
7 #include <CommonCrypto/CommonCryptor.h> // for kCCBlockSizeAES128 7 #include <CommonCrypto/CommonCryptor.h> // for kCCBlockSizeAES128
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 static bool mock_keychain_command_line_flag = 55 static bool mock_keychain_command_line_flag =
56 CommandLine::ForCurrentProcess()->HasSwitch( 56 CommandLine::ForCurrentProcess()->HasSwitch(
57 os_crypt::switches::kUseMockKeychain); 57 os_crypt::switches::kUseMockKeychain);
58 58
59 std::string password; 59 std::string password;
60 if (use_mock_keychain || mock_keychain_command_line_flag) { 60 if (use_mock_keychain || mock_keychain_command_line_flag) {
61 // Through manual testing, each call to SecKeychainFindGenericPassword 61 // Through manual testing, each call to SecKeychainFindGenericPassword
62 // takes 4.6ms with a SSD, 3 GHz Intel Xeon. On a slower processor with a 62 // takes 4.6ms with a SSD, 3 GHz Intel Xeon. On a slower processor with a
63 // HDD, this probably takes 4x as long. 63 // HDD, this probably takes 4x as long.
64 base::SpinCpuMicroseconds(18400); 64 base::SpinCpuMicroseconds(18400);
65 base::EmitAccessKeychainHistogram();
65 66
66 password = "mock_password"; 67 password = "mock_password";
67 } else { 68 } else {
68 AppleKeychain keychain; 69 AppleKeychain keychain;
69 KeychainPassword encryptor_password(keychain); 70 KeychainPassword encryptor_password(keychain);
70 password = encryptor_password.GetPassword(); 71 password = encryptor_password.GetPassword();
71 } 72 }
72 73
73 // Subsequent code must guarantee that the correct key is cached before 74 // Subsequent code must guarantee that the correct key is cached before
74 // returning. 75 // returning.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (!encryptor.Decrypt(raw_ciphertext, plaintext)) 167 if (!encryptor.Decrypt(raw_ciphertext, plaintext))
167 return false; 168 return false;
168 169
169 return true; 170 return true;
170 } 171 }
171 172
172 void OSCrypt::UseMockKeychain(bool use_mock) { 173 void OSCrypt::UseMockKeychain(bool use_mock) {
173 use_mock_keychain = use_mock; 174 use_mock_keychain = use_mock;
174 } 175 }
175 176
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698