diff options
author | ramankk@chromium.org <ramankk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-12 01:16:13 +0000 |
---|---|---|
committer | ramankk@chromium.org <ramankk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-12 01:16:13 +0000 |
commit | f0cbceb690653fa504cc201f8c4d684d6423d8a0 (patch) | |
tree | 10ada76a2b3cce5246ec85f043a61d7bc3fe4b27 /components | |
parent | f7540c4c1a7a9edcb45b1ee5556b2425c08359b5 (diff) | |
download | chromium_src-f0cbceb690653fa504cc201f8c4d684d6423d8a0.zip chromium_src-f0cbceb690653fa504cc201f8c4d684d6423d8a0.tar.gz chromium_src-f0cbceb690653fa504cc201f8c4d684d6423d8a0.tar.bz2 |
rAc: Wallet: Add metrics for malformed responses.
BUG=274649
Review URL: https://chromiumcodereview.appspot.com/23875012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222691 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
5 files changed, 44 insertions, 7 deletions
diff --git a/components/autofill/content/browser/wallet/wallet_client.cc b/components/autofill/content/browser/wallet/wallet_client.cc index 9e90515..b9e2a4c6 100644 --- a/components/autofill/content/browser/wallet/wallet_client.cc +++ b/components/autofill/content/browser/wallet/wallet_client.cc @@ -653,7 +653,7 @@ void WalletClient::OnURLFetchComplete( request_type_ = NO_PENDING_REQUEST; if (type != ACCEPT_LEGAL_DOCUMENTS && !response_dict) { - HandleMalformedResponse(scoped_request.get()); + HandleMalformedResponse(type, scoped_request.get()); return; } @@ -672,7 +672,7 @@ void WalletClient::OnURLFetchComplete( delegate_->OnDidAuthenticateInstrument( LowerCaseEqualsASCII(trimmed, "success")); } else { - HandleMalformedResponse(scoped_request.get()); + HandleMalformedResponse(type, scoped_request.get()); } break; } @@ -685,7 +685,7 @@ void WalletClient::OnURLFetchComplete( LogRequiredActions(full_wallet->required_actions()); delegate_->OnDidGetFullWallet(full_wallet.Pass()); } else { - HandleMalformedResponse(scoped_request.get()); + HandleMalformedResponse(type, scoped_request.get()); } break; } @@ -697,7 +697,7 @@ void WalletClient::OnURLFetchComplete( LogRequiredActions(wallet_items->required_actions()); delegate_->OnDidGetWalletItems(wallet_items.Pass()); } else { - HandleMalformedResponse(scoped_request.get()); + HandleMalformedResponse(type, scoped_request.get()); } break; } @@ -714,7 +714,7 @@ void WalletClient::OnURLFetchComplete( GetFormFieldErrors(*response_dict, &form_errors); if (instrument_id.empty() && shipping_address_id.empty() && required_actions.empty()) { - HandleMalformedResponse(scoped_request.get()); + HandleMalformedResponse(type, scoped_request.get()); } else { LogRequiredActions(required_actions); delegate_->OnDidSaveToWallet(instrument_id, @@ -739,9 +739,13 @@ void WalletClient::StartNextPendingRequest() { next_request.Run(); } -void WalletClient::HandleMalformedResponse(net::URLFetcher* request) { +void WalletClient::HandleMalformedResponse(RequestType request_type, + net::URLFetcher* request) { // Called to inform exponential backoff logic of the error. request->ReceivedContentWasMalformed(); + // Record failed API call in metrics. + delegate_->GetMetricLogger().LogWalletMalformedResponseMetric( + RequestTypeToUmaMetric(request_type)); HandleWalletError(MALFORMED_RESPONSE); } diff --git a/components/autofill/content/browser/wallet/wallet_client.h b/components/autofill/content/browser/wallet/wallet_client.h index 49c0fe2..89827a8 100644 --- a/components/autofill/content/browser/wallet/wallet_client.h +++ b/components/autofill/content/browser/wallet/wallet_client.h @@ -205,7 +205,8 @@ class WalletClient : public net::URLFetcherDelegate { const std::string& mime_type); // Performs bookkeeping tasks for any invalid requests. - void HandleMalformedResponse(net::URLFetcher* request); + void HandleMalformedResponse(RequestType request_type, + net::URLFetcher* request); void HandleNetworkError(int response_code); void HandleWalletError(ErrorType error_type); diff --git a/components/autofill/content/browser/wallet/wallet_client_unittest.cc b/components/autofill/content/browser/wallet/wallet_client_unittest.cc index 2ef1bb0..32d598e 100644 --- a/components/autofill/content/browser/wallet/wallet_client_unittest.cc +++ b/components/autofill/content/browser/wallet/wallet_client_unittest.cc @@ -584,6 +584,8 @@ class MockAutofillMetrics : public AutofillMetrics { MOCK_CONST_METHOD1(LogWalletErrorMetric, void(WalletErrorMetric metric)); MOCK_CONST_METHOD1(LogWalletRequiredActionMetric, void(WalletRequiredActionMetric action)); + MOCK_CONST_METHOD1(LogWalletMalformedResponseMetric, + void(WalletApiCallMetric metric)); private: DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics); }; @@ -623,6 +625,12 @@ class MockWalletClientDelegate : public WalletClientDelegate { LogWalletApiCallDuration(metric, testing::_)).Times(times); } + void ExpectLogWalletMalformedResponse( + AutofillMetrics::WalletApiCallMetric metric) { + EXPECT_CALL(metric_logger_, + LogWalletMalformedResponseMetric(metric)).Times(1); + } + void ExpectWalletErrorMetric(AutofillMetrics::WalletErrorMetric metric) { EXPECT_CALL(metric_logger_, LogWalletErrorMetric(metric)).Times(1); } @@ -1055,6 +1063,7 @@ TEST_F(WalletClientTest, GetFullWalletMalformedResponse) { delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_FULL_WALLET, 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::GET_FULL_WALLET); WalletClient::FullWalletRequest full_wallet_request( "instrument_id", @@ -1137,6 +1146,8 @@ TEST_F(WalletClientTest, AuthenticateInstrumentFailedMalformedResponse) { 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse( + AutofillMetrics::AUTHENTICATE_INSTRUMENT); wallet_client_->AuthenticateInstrument("instrument_id", "123"); @@ -1230,6 +1241,7 @@ TEST_F(WalletClientTest, SaveAddressFailedInvalidRequiredAction) { delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); scoped_ptr<Address> address = GetTestSaveableAddress(); wallet_client_->SaveToWallet(scoped_ptr<Instrument>(), @@ -1246,6 +1258,7 @@ TEST_F(WalletClientTest, SaveAddressFailedMalformedResponse) { delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); scoped_ptr<Address> address = GetTestSaveableAddress(); wallet_client_->SaveToWallet(scoped_ptr<Instrument>(), @@ -1314,6 +1327,7 @@ TEST_F(WalletClientTest, SaveInstrumentFailedInvalidRequiredActions) { delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); EXPECT_CALL(delegate_, OnWalletError(WalletClient::MALFORMED_RESPONSE)); @@ -1335,6 +1349,7 @@ TEST_F(WalletClientTest, SaveInstrumentFailedMalformedResponse) { delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); scoped_ptr<Instrument> instrument = GetTestInstrument(); wallet_client_->SaveToWallet(instrument.Pass(), @@ -1415,6 +1430,7 @@ TEST_F(WalletClientTest, SaveInstrumentAndAddressFailedInvalidRequiredAction) { 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); scoped_ptr<Instrument> instrument = GetTestInstrument(); scoped_ptr<Address> address = GetTestSaveableAddress(); @@ -1486,6 +1502,7 @@ TEST_F(WalletClientTest, UpdateAddressFailedInvalidRequiredAction) { delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); scoped_ptr<Address> address = GetTestShippingAddress(); address->set_object_id("shipping_address_id"); @@ -1504,6 +1521,7 @@ TEST_F(WalletClientTest, UpdateAddressMalformedResponse) { delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); scoped_ptr<Address> address = GetTestShippingAddress(); address->set_object_id("shipping_address_id"); @@ -1615,6 +1633,7 @@ TEST_F(WalletClientTest, UpdateInstrumentFailedInvalidRequiredAction) { 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(), scoped_ptr<Address>(), @@ -1632,6 +1651,7 @@ TEST_F(WalletClientTest, UpdateInstrumentMalformedResponse) { 1); delegate_.ExpectBaselineMetrics(); delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); + delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(), scoped_ptr<Address>(), diff --git a/components/autofill/core/browser/autofill_metrics.cc b/components/autofill/core/browser/autofill_metrics.cc index e4ad366..14d8a64 100644 --- a/components/autofill/core/browser/autofill_metrics.cc +++ b/components/autofill/core/browser/autofill_metrics.cc @@ -173,6 +173,7 @@ std::string WalletApiMetricToString( case AutofillMetrics::SAVE_TO_WALLET: return "SaveToWallet"; case AutofillMetrics::UNKNOWN_API_CALL: + case AutofillMetrics::NUM_WALLET_API_CALLS: NOTREACHED(); return "UnknownApiCall"; } @@ -381,6 +382,12 @@ void AutofillMetrics::LogWalletApiCallDuration( WalletApiMetricToString(metric), duration); } +void AutofillMetrics::LogWalletMalformedResponseMetric( + WalletApiCallMetric metric) const { + UMA_HISTOGRAM_ENUMERATION("Wallet.MalformedResponse", metric, + NUM_WALLET_API_CALLS); +} + void AutofillMetrics::LogWalletRequiredActionMetric( WalletRequiredActionMetric required_action) const { UMA_HISTOGRAM_ENUMERATION("RequestAutocomplete.WalletRequiredActions", diff --git a/components/autofill/core/browser/autofill_metrics.h b/components/autofill/core/browser/autofill_metrics.h index 00d138e..35dc2de 100644 --- a/components/autofill/core/browser/autofill_metrics.h +++ b/components/autofill/core/browser/autofill_metrics.h @@ -256,6 +256,7 @@ class AutofillMetrics { GET_FULL_WALLET, GET_WALLET_ITEMS, SAVE_TO_WALLET, + NUM_WALLET_API_CALLS }; // For measuring the frequency of errors while communicating with the Wallet @@ -385,6 +386,10 @@ class AutofillMetrics { WalletApiCallMetric metric, const base::TimeDelta& duration) const; + // Logs that the Wallet API call corresponding to |metric| was malformed. + virtual void LogWalletMalformedResponseMetric( + WalletApiCallMetric metric) const; + // Logs |required_action| to the required actions histogram. virtual void LogWalletRequiredActionMetric( WalletRequiredActionMetric required_action) const; |