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

Unified 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: Move GetEncryptionPassword so that it gets compiled on iOS. Created 5 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto/mock_apple_keychain.h ('k') | tools/perf/benchmarks/speedometer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/mock_apple_keychain.cc
diff --git a/crypto/mock_apple_keychain.cc b/crypto/mock_apple_keychain.cc
index 1ddfc8679461c6fddf320642405dc31f98643c0b..a1faa65382a788ff5d8ac81b21b9723b41fb537c 100644
--- a/crypto/mock_apple_keychain.cc
+++ b/crypto/mock_apple_keychain.cc
@@ -3,9 +3,23 @@
// found in the LICENSE file.
#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "base/time/time.h"
#include "crypto/mock_apple_keychain.h"
+namespace {
+
+// Adds an entry to a local histogram to indicate that the Apple Keychain would
+// have been accessed, if this class were not a mock of the Apple Keychain.
+void IncrementKeychainAccessHistogram() {
+ // This local histogram is accessed by Telemetry to track the number of times
+ // the keychain is accessed, since keychain access is known to be synchronous
+ // and slow.
+ LOCAL_HISTOGRAM_BOOLEAN("OSX.Keychain.Access", true);
+}
+
+} // namespace
+
namespace crypto {
OSStatus MockAppleKeychain::FindGenericPassword(
@@ -17,6 +31,8 @@ OSStatus MockAppleKeychain::FindGenericPassword(
UInt32* passwordLength,
void** passwordData,
SecKeychainItemRef* itemRef) const {
+ IncrementKeychainAccessHistogram();
+
// When simulating |noErr|, return canned |passwordData| and
// |passwordLength|. Otherwise, just return given code.
if (find_generic_result_ == noErr) {
@@ -48,6 +64,8 @@ OSStatus MockAppleKeychain::AddGenericPassword(
UInt32 passwordLength,
const void* passwordData,
SecKeychainItemRef* itemRef) const {
+ IncrementKeychainAccessHistogram();
+
called_add_generic_ = true;
DCHECK_GT(passwordLength, 0U);
@@ -58,4 +76,9 @@ OSStatus MockAppleKeychain::AddGenericPassword(
return noErr;
}
+std::string MockAppleKeychain::GetEncryptionPassword() const {
+ IncrementKeychainAccessHistogram();
+ return "mock_password";
+}
+
} // namespace crypto
« no previous file with comments | « crypto/mock_apple_keychain.h ('k') | tools/perf/benchmarks/speedometer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698