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

Unified Diff: components/password_manager/core/browser/affiliated_match_helper.cc

Issue 1090163004: Add experiment to exercise AffiliationService with dummy data, plus add related UMA histograms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update_copy
Patch Set: Created 5 years, 8 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
Index: components/password_manager/core/browser/affiliated_match_helper.cc
diff --git a/components/password_manager/core/browser/affiliated_match_helper.cc b/components/password_manager/core/browser/affiliated_match_helper.cc
index 8777f9ecb92608ce125810fdc6a67e691a40d800..082a080bd6da5902f39313465533724bc82330a2 100644
--- a/components/password_manager/core/browser/affiliated_match_helper.cc
+++ b/components/password_manager/core/browser/affiliated_match_helper.cc
@@ -6,6 +6,8 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/command_line.h"
+#include "base/metrics/histogram_macros.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "components/autofill/core/common/password_form.h"
@@ -15,6 +17,35 @@ namespace password_manager {
namespace {
+// Dummy Android facet URIs for which affiliations will be fetched as part of an
+// experiment to exercise the AffiliationService code in the wild, before users
+// would get a chance to have real Android credentials saved.
+// Note: although somewhat redundant, the URLs are listed explictly so that they
+// are easy to find in code search if somebody is curious why they are fetched.
+const char* kDummyAndroidFacetURIs[] = {
+ "android://oEOFeXmqYvBlkpl3gJlItdIzb59KFnmFGuc1eHFQcIKpEWQuV2X4L7GYkRtdqTi_"
+ "g9YvgKFAXew3rMDjeAkWVA==@one.example.one",
+ "android://oEOFeXmqYvBlkpl3gJlItdIzb59KFnmFGuc1eHFQcIKpEWQuV2X4L7GYkRtdqTi_"
+ "g9YvgKFAXew3rMDjeAkWVA==@two.example.one",
+ "android://oEOFeXmqYvBlkpl3gJlItdIzb59KFnmFGuc1eHFQcIKpEWQuV2X4L7GYkRtdqTi_"
+ "g9YvgKFAXew3rMDjeAkWVA==@twoprime.example.one",
+ "android://oEOFeXmqYvBlkpl3gJlItdIzb59KFnmFGuc1eHFQcIKpEWQuV2X4L7GYkRtdqTi_"
+ "g9YvgKFAXew3rMDjeAkWVA==@three.example.one",
+ "android://oEOFeXmqYvBlkpl3gJlItdIzb59KFnmFGuc1eHFQcIKpEWQuV2X4L7GYkRtdqTi_"
+ "g9YvgKFAXew3rMDjeAkWVA==@four.example.one",
+ "android://oEOFeXmqYvBlkpl3gJlItdIzb59KFnmFGuc1eHFQcIKpEWQuV2X4L7GYkRtdqTi_"
+ "g9YvgKFAXew3rMDjeAkWVA==@fourprime.example.one",
+};
+
+// Dummy Web facet URIs for the same purpose. The URIs with the same numbers are
+// in the same equivalence class.
+const char* kDummyWebFacetURIs[] = {"https://one.example.com",
+ "https://two.example.com",
+ "https://three.example.com",
+ "https://threeprime.example.com",
+ "https://four.example.com",
+ "https://fourprime.example.com"};
+
// Returns whether or not |form| represents a credential for an Android
// application, and if so, returns the |facet_uri| of that application.
bool IsAndroidApplicationCredential(const autofill::PasswordForm& form,
@@ -27,6 +58,16 @@ bool IsAndroidApplicationCredential(const autofill::PasswordForm& form,
return facet_uri->IsValidAndroidFacetURI();
}
+// Called back by the AffiliationService in response to requesting affiliations
+// for the dummy Web facets URIs above.
+void OnRetrievedAffiliationResultsForDummyWebURIs(
+ const AffiliatedFacets& results,
+ bool success) {
+ UMA_HISTOGRAM_BOOLEAN("AffiliationService.DummyData.RequestSuccess", success);
+ UMA_HISTOGRAM_COUNTS_100("AffiliationService.DummyData.RequestResultCount",
Ilya Sherman 2015/04/21 00:38:05 Would it be appropriate for these histograms to be
Mike West 2015/04/21 08:53:42 Sounds good to me too.
engedy 2015/04/21 18:29:07 SGTM, I have moved histograms to the PasswordManag
+ results.size());
Ilya Sherman 2015/04/21 00:38:05 Should this be logged both on success and on failu
engedy 2015/04/21 18:29:07 Yeah, does not make much sense on failure. Added c
+}
+
} // namespace
// static
@@ -157,6 +198,16 @@ void AffiliatedMatchHelper::CompleteGetAffiliatedWebRealms(
result_callback.Run(affiliated_realms);
}
+void AffiliatedMatchHelper::VerifyAffiliationsOfDummyFacetsPrefetched() {
+ DCHECK(affiliation_service_);
+ for (const char* web_facet_uri : kDummyWebFacetURIs) {
+ affiliation_service_->GetAffiliations(
+ FacetURI::FromCanonicalSpec(web_facet_uri),
+ AffiliationService::StrategyOnCacheMiss::FAIL,
+ base::Bind(&OnRetrievedAffiliationResultsForDummyWebURIs));
+ }
+}
+
void AffiliatedMatchHelper::OnLoginsChanged(
const PasswordStoreChangeList& changes) {
for (const PasswordStoreChange& change : changes) {
@@ -178,6 +229,21 @@ void AffiliatedMatchHelper::OnGetPasswordStoreResults(
if (IsAndroidApplicationCredential(*form, &facet_uri))
affiliation_service_->Prefetch(facet_uri, base::Time::Max());
}
+
+ // If the respective experiment is enabled, test prefetching affiliation data
+ // for dummy Android facet URIs to discover potenial issues in the wild before
+ // users would get a chance to have real Android credentials saved.
+ if (password_manager::IsAffiliationRequestsForDummyFacetsEnabled(
+ *base::CommandLine::ForCurrentProcess())) {
+ for (const char* android_facet_uri : kDummyAndroidFacetURIs) {
+ affiliation_service_->Prefetch(
+ FacetURI::FromCanonicalSpec(android_facet_uri), base::Time::Max());
+ }
+
+ verify_dummy_prefetch_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromMinutes(1), this,
+ &AffiliatedMatchHelper::VerifyAffiliationsOfDummyFacetsPrefetched);
Mike West 2015/04/21 08:53:42 How often is this going to trigger?
engedy 2015/04/21 18:29:07 Right, this is why I should not be sending out CLs
+ }
}
} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698