summaryrefslogtreecommitdiffstats
path: root/components/autofill
diff options
context:
space:
mode:
Diffstat (limited to 'components/autofill')
-rw-r--r--components/autofill/content/browser/autocheckout_manager.cc23
-rw-r--r--components/autofill/content/browser/autocheckout_manager.h12
-rw-r--r--components/autofill/content/browser/autocheckout_request_manager.cc2
-rw-r--r--components/autofill/content/browser/autocheckout_request_manager.h9
-rw-r--r--components/autofill/content/browser/autocheckout_statistic.cc52
-rw-r--r--components/autofill/content/browser/autocheckout_statistic.h40
-rw-r--r--components/autofill/content/browser/wallet/wallet_client.cc13
-rw-r--r--components/autofill/content/browser/wallet/wallet_client.h14
-rw-r--r--components/autofill/content/browser/wallet/wallet_client_unittest.cc29
9 files changed, 185 insertions, 9 deletions
diff --git a/components/autofill/content/browser/autocheckout_manager.cc b/components/autofill/content/browser/autocheckout_manager.cc
index 438b2a7..33d44cc 100644
--- a/components/autofill/content/browser/autocheckout_manager.cc
+++ b/components/autofill/content/browser/autocheckout_manager.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/content/browser/autocheckout_request_manager.h"
+#include "components/autofill/content/browser/autocheckout_statistic.h"
#include "components/autofill/content/browser/autocheckout_steps.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_field.h"
@@ -198,6 +199,8 @@ void AutocheckoutManager::FillForms() {
page_meta_data_->click_elements_before_form_fill,
page_meta_data_->click_elements_after_form_fill,
page_meta_data_->proceed_element_descriptor));
+ // Record time taken for navigating current page.
+ RecordTimeTaken(page_meta_data_->current_page_number);
}
void AutocheckoutManager::OnClickFailed(AutocheckoutStatus status) {
@@ -335,6 +338,8 @@ void AutocheckoutManager::ReturnAutocheckoutData(
return;
}
+ latency_statistics_.clear();
+ last_step_completion_timestamp_ = base::TimeTicks().Now();
google_transaction_id_ = google_transaction_id;
in_autocheckout_flow_ = true;
metric_logger_->LogAutocheckoutBuyFlowMetric(
@@ -505,6 +510,7 @@ void AutocheckoutManager::SendAutocheckoutStatus(AutocheckoutStatus status) {
autocheckout_request_manager->SendAutocheckoutStatus(
status,
autofill_manager_->GetWebContents()->GetURL(),
+ latency_statistics_,
google_transaction_id_);
// Log the result of this Autocheckout flow to UMA.
@@ -525,4 +531,21 @@ void AutocheckoutManager::SetStepProgressForPage(
}
}
+void AutocheckoutManager::RecordTimeTaken(int page_number) {
+ AutocheckoutStatistic statistic;
+ statistic.page_number = page_number;
+ if (page_types_.count(page_number) == 1) {
+ for (size_t i = 0; i < page_types_[page_number].size(); ++i) {
+ statistic.steps.push_back(page_types_[page_number][i]);
+ }
+ }
+
+ statistic.time_taken =
+ base::TimeTicks().Now() - last_step_completion_timestamp_;
+ latency_statistics_.push_back(statistic);
+
+ // Reset timestamp.
+ last_step_completion_timestamp_ = base::TimeTicks().Now();
+}
+
} // namespace autofill
diff --git a/components/autofill/content/browser/autocheckout_manager.h b/components/autofill/content/browser/autocheckout_manager.h
index a5442b9..eec00f2 100644
--- a/components/autofill/content/browser/autocheckout_manager.h
+++ b/components/autofill/content/browser/autocheckout_manager.h
@@ -12,7 +12,9 @@
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "base/threading/thread_checker.h"
+#include "base/time.h"
#include "components/autofill/content/browser/autocheckout_page_meta_data.h"
+#include "components/autofill/content/browser/autocheckout_statistic.h"
#include "components/autofill/core/common/autocheckout_status.h"
class GURL;
@@ -123,6 +125,10 @@ class AutocheckoutManager {
// Sets the progress of all steps for the given page to the provided value.
void SetStepProgressForPage(int page_number, AutocheckoutStepStatus status);
+ // Account time spent between now and |last_step_completion_timestamp_|
+ // towards |page_number|.
+ void RecordTimeTaken(int page_number);
+
AutofillManager* autofill_manager_; // WEAK; owns us
// Credit card verification code.
@@ -156,6 +162,12 @@ class AutocheckoutManager {
// AutocheckoutStepTypes for the various pages of the flow.
std::map<int, std::vector<AutocheckoutStepType> > page_types_;
+ // Timestamp of last step's completion.
+ base::TimeTicks last_step_completion_timestamp_;
+
+ // Per page latency statistics.
+ std::vector<AutocheckoutStatistic> latency_statistics_;
+
std::string google_transaction_id_;
base::WeakPtrFactory<AutocheckoutManager> weak_ptr_factory_;
diff --git a/components/autofill/content/browser/autocheckout_request_manager.cc b/components/autofill/content/browser/autocheckout_request_manager.cc
index 22c9f5d..62c0eca 100644
--- a/components/autofill/content/browser/autocheckout_request_manager.cc
+++ b/components/autofill/content/browser/autocheckout_request_manager.cc
@@ -39,9 +39,11 @@ AutocheckoutRequestManager* AutocheckoutRequestManager::FromBrowserContext(
void AutocheckoutRequestManager::SendAutocheckoutStatus(
AutocheckoutStatus status,
const GURL& source_url,
+ const std::vector<AutocheckoutStatistic>& latency_statistics,
const std::string& google_transaction_id) {
wallet_client_.SendAutocheckoutStatus(status,
source_url,
+ latency_statistics,
google_transaction_id);
}
diff --git a/components/autofill/content/browser/autocheckout_request_manager.h b/components/autofill/content/browser/autocheckout_request_manager.h
index a186653..a115699 100644
--- a/components/autofill/content/browser/autocheckout_request_manager.h
+++ b/components/autofill/content/browser/autocheckout_request_manager.h
@@ -6,6 +6,7 @@
#define COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_REQUEST_MANAGER_H_
#include "base/supports_user_data.h"
+#include "components/autofill/content/browser/autocheckout_statistic.h"
#include "components/autofill/content/browser/wallet/wallet_client.h"
#include "components/autofill/content/browser/wallet/wallet_client_delegate.h"
#include "components/autofill/core/browser/autofill_metrics.h"
@@ -43,9 +44,11 @@ class AutocheckoutRequestManager : public base::SupportsUserData::Data,
// Sends the |status| of an Autocheckout flow to Online Wallet using
// |wallet_client_|.
- void SendAutocheckoutStatus(AutocheckoutStatus status,
- const GURL& source_url,
- const std::string& google_transaction_id);
+ void SendAutocheckoutStatus(
+ AutocheckoutStatus status,
+ const GURL& source_url,
+ const std::vector<AutocheckoutStatistic>& latency_statistics,
+ const std::string& google_transaction_id);
// wallet::WalletClientDelegate:
virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE;
diff --git a/components/autofill/content/browser/autocheckout_statistic.cc b/components/autofill/content/browser/autocheckout_statistic.cc
new file mode 100644
index 0000000..9df4f4e4
--- /dev/null
+++ b/components/autofill/content/browser/autocheckout_statistic.cc
@@ -0,0 +1,52 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/content/browser/autocheckout_statistic.h"
+
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/values.h"
+
+namespace autofill {
+
+namespace {
+
+std::string AutocheckoutStepToString(AutocheckoutStepType step) {
+ switch(step) {
+ case AUTOCHECKOUT_STEP_SHIPPING:
+ return "AUTOCHECKOUT_STEP_SHIPPING";
+ case AUTOCHECKOUT_STEP_DELIVERY:
+ return "AUTOCHECKOUT_STEP_DELIVERY";
+ case AUTOCHECKOUT_STEP_BILLING:
+ return "AUTOCHECKOUT_STEP_BILLING";
+ case AUTOCHECKOUT_STEP_PROXY_CARD:
+ return "AUTOCHECKOUT_STEP_PROXY_CARD";
+ }
+ NOTREACHED();
+ return "NOT_POSSIBLE";
+}
+
+} // namespace
+
+AutocheckoutStatistic::AutocheckoutStatistic() : page_number(-1) {
+}
+
+AutocheckoutStatistic::~AutocheckoutStatistic() {
+}
+
+scoped_ptr<base::DictionaryValue> AutocheckoutStatistic::ToDictionary() const {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ std::string description = base::IntToString(page_number);
+ for (size_t i = 0; i < steps.size(); ++i) {
+ description = description + "_" + AutocheckoutStepToString(steps[i]);
+ }
+ dict->SetString("step_description", description);
+ dict->SetInteger("time_taken", time_taken.InMilliseconds());
+ DVLOG(1) << "Step : " << description
+ << ", time_taken: " << time_taken.InMilliseconds();
+ return dict.Pass();
+}
+
+} // namespace autofill
+
diff --git a/components/autofill/content/browser/autocheckout_statistic.h b/components/autofill/content/browser/autocheckout_statistic.h
new file mode 100644
index 0000000..8720a9f
--- /dev/null
+++ b/components/autofill/content/browser/autocheckout_statistic.h
@@ -0,0 +1,40 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_STATISTIC_H__
+#define COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_STATISTIC_H__
+
+#include <vector>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/time.h"
+#include "components/autofill/content/browser/autocheckout_steps.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace autofill {
+
+// Per page statistics gathered in Autocheckout flow.
+struct AutocheckoutStatistic {
+ AutocheckoutStatistic();
+ ~AutocheckoutStatistic();
+
+ // Page number for which this statistic is being recorded.
+ int page_number;
+
+ // Autocheckout steps that are part of |page_number|.
+ std::vector<AutocheckoutStepType> steps;
+
+ // Time taken for performing |steps|, used for measuring latency.
+ base::TimeDelta time_taken;
+
+ // Helper method to convert AutocheckoutStatistic to json representation.
+ scoped_ptr<base::DictionaryValue> ToDictionary() const;
+};
+
+} // namespace autofill
+
+#endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_STATISTIC_H__
diff --git a/components/autofill/content/browser/wallet/wallet_client.cc b/components/autofill/content/browser/wallet/wallet_client.cc
index e129d1f..5062bcb 100644
--- a/components/autofill/content/browser/wallet/wallet_client.cc
+++ b/components/autofill/content/browser/wallet/wallet_client.cc
@@ -219,6 +219,7 @@ const char kSelectedInstrumentIdKey[] = "selected_instrument_id";
const char kSessionMaterialKey[] = "session_material";
const char kShippingAddressIdKey[] = "shipping_address_id";
const char kShippingAddressKey[] = "shipping_address";
+const char kAutocheckoutStepsKey[] = "steps";
const char kSuccessKey[] = "success";
const char kUpgradedBillingAddressKey[] = "upgraded_billing_address";
const char kUpgradedInstrumentIdKey[] = "upgraded_instrument_id";
@@ -462,6 +463,7 @@ void WalletClient::SaveInstrumentAndAddress(
void WalletClient::SendAutocheckoutStatus(
AutocheckoutStatus status,
const GURL& source_url,
+ const std::vector<AutocheckoutStatistic>& latency_statistics,
const std::string& google_transaction_id) {
DVLOG(1) << "Sending Autocheckout Status: " << status
<< " for: " << source_url;
@@ -470,6 +472,7 @@ void WalletClient::SendAutocheckoutStatus(
base::Unretained(this),
status,
source_url,
+ latency_statistics,
google_transaction_id));
return;
}
@@ -485,6 +488,16 @@ void WalletClient::SendAutocheckoutStatus(
source_url.GetWithEmptyPath().spec());
if (!success)
request_dict.SetString(kReasonKey, AutocheckoutStatusToString(status));
+ if (!latency_statistics.empty()) {
+ scoped_ptr<base::ListValue> latency_statistics_json(
+ new base::ListValue());
+ for (size_t i = 0; i < latency_statistics.size(); ++i) {
+ latency_statistics_json->Append(
+ latency_statistics[i].ToDictionary().release());
+ }
+ request_dict.Set(kAutocheckoutStepsKey,
+ latency_statistics_json.release());
+ }
request_dict.SetString(kGoogleTransactionIdKey, google_transaction_id);
std::string post_body;
diff --git a/components/autofill/content/browser/wallet/wallet_client.h b/components/autofill/content/browser/wallet/wallet_client.h
index 54b555c..b3b1d74a 100644
--- a/components/autofill/content/browser/wallet/wallet_client.h
+++ b/components/autofill/content/browser/wallet/wallet_client.h
@@ -13,6 +13,7 @@
#include "base/memory/ref_counted.h"
#include "base/time.h"
#include "base/values.h"
+#include "components/autofill/content/browser/autocheckout_statistic.h"
#include "components/autofill/content/browser/wallet/encryption_escrow_client.h"
#include "components/autofill/content/browser/wallet/encryption_escrow_client_observer.h"
#include "components/autofill/content/browser/wallet/full_wallet.h"
@@ -205,12 +206,15 @@ class WalletClient
const GURL& source_url);
// SendAutocheckoutStatus is used for tracking the success of Autocheckout
- // flows. |status| is the result of the flow, |merchant_domain| is the domain
+ // flows. |status| is the result of the flow, |source_url| is the domain
// where the purchase occured, and |google_transaction_id| is the same as the
- // one provided by GetWalletItems.
- void SendAutocheckoutStatus(autofill::AutocheckoutStatus status,
- const GURL& source_url,
- const std::string& google_transaction_id);
+ // one provided by GetWalletItems. |latency_statistics| contain statistics
+ // required to measure Autocheckout process.
+ void SendAutocheckoutStatus(
+ autofill::AutocheckoutStatus status,
+ const GURL& source_url,
+ const std::vector<AutocheckoutStatistic>& latency_statistics,
+ const std::string& google_transaction_id);
// UpdateAddress updates Online Wallet with the data in |address|.
virtual void UpdateAddress(const Address& address, const GURL& source_url);
diff --git a/components/autofill/content/browser/wallet/wallet_client_unittest.cc b/components/autofill/content/browser/wallet/wallet_client_unittest.cc
index 88bb406..0379cc9 100644
--- a/components/autofill/content/browser/wallet/wallet_client_unittest.cc
+++ b/components/autofill/content/browser/wallet/wallet_client_unittest.cc
@@ -9,6 +9,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/values.h"
+#include "components/autofill/content/browser/autocheckout_steps.h"
#include "components/autofill/content/browser/wallet/full_wallet.h"
#include "components/autofill/content/browser/wallet/instrument.h"
#include "components/autofill/content/browser/wallet/wallet_client.h"
@@ -466,6 +467,15 @@ const char kSendAutocheckoutStatusOfSuccessValidRequest[] =
"\"success\":true"
"}";
+const char kSendAutocheckoutStatusWithStatisticsValidRequest[] =
+ "{"
+ "\"google_transaction_id\":\"google_transaction_id\","
+ "\"merchant_domain\":\"https://example.com/\","
+ "\"steps\":[{\"step_description\":\"1_AUTOCHECKOUT_STEP_SHIPPING\""
+ ",\"time_taken\":100}],"
+ "\"success\":true"
+ "}";
+
const char kSendAutocheckoutStatusOfFailureValidRequest[] =
"{"
"\"google_transaction_id\":\"google_transaction_id\","
@@ -792,8 +802,10 @@ TEST_F(WalletClientTest, WalletError) {
delegate_.ExpectWalletErrorMetric(
AutofillMetrics::WALLET_SERVICE_UNAVAILABLE);
+ std::vector<AutocheckoutStatistic> statistics;
wallet_client_->SendAutocheckoutStatus(autofill::SUCCESS,
GURL(kMerchantUrl),
+ statistics,
"google_transaction_id");
VerifyAndFinishRequest(net::HTTP_INTERNAL_SERVER_ERROR,
kSendAutocheckoutStatusOfSuccessValidRequest,
@@ -807,8 +819,10 @@ TEST_F(WalletClientTest, WalletErrorResponseMissing) {
delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_UNKNOWN_ERROR);
+ std::vector<AutocheckoutStatistic> statistics;
wallet_client_->SendAutocheckoutStatus(autofill::SUCCESS,
GURL(kMerchantUrl),
+ statistics,
"google_transaction_id");
VerifyAndFinishRequest(net::HTTP_INTERNAL_SERVER_ERROR,
kSendAutocheckoutStatusOfSuccessValidRequest,
@@ -821,8 +835,10 @@ TEST_F(WalletClientTest, NetworkFailureOnExpectedVoidResponse) {
delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR);
+ std::vector<AutocheckoutStatistic> statistics;
wallet_client_->SendAutocheckoutStatus(autofill::SUCCESS,
GURL(kMerchantUrl),
+ statistics,
"google_transaction_id");
VerifyAndFinishRequest(net::HTTP_UNAUTHORIZED,
kSendAutocheckoutStatusOfSuccessValidRequest,
@@ -848,8 +864,10 @@ TEST_F(WalletClientTest, RequestError) {
delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_BAD_REQUEST);
+ std::vector<AutocheckoutStatistic> statistics;
wallet_client_->SendAutocheckoutStatus(autofill::SUCCESS,
GURL(kMerchantUrl),
+ statistics,
"google_transaction_id");
VerifyAndFinishRequest(net::HTTP_BAD_REQUEST,
kSendAutocheckoutStatusOfSuccessValidRequest,
@@ -1725,11 +1743,18 @@ TEST_F(WalletClientTest, SendAutocheckoutOfStatusSuccess) {
delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
+ AutocheckoutStatistic statistic;
+ statistic.page_number = 1;
+ statistic.steps.push_back(AUTOCHECKOUT_STEP_SHIPPING);
+ statistic.time_taken = base::TimeDelta::FromMilliseconds(100);
+ std::vector<AutocheckoutStatistic> statistics;
+ statistics.push_back(statistic);
wallet_client_->SendAutocheckoutStatus(autofill::SUCCESS,
GURL(kMerchantUrl),
+ statistics,
"google_transaction_id");
VerifyAndFinishRequest(net::HTTP_OK,
- kSendAutocheckoutStatusOfSuccessValidRequest,
+ kSendAutocheckoutStatusWithStatisticsValidRequest,
")]}"); // Invalid JSON. Should be ignored.
}
@@ -1737,8 +1762,10 @@ TEST_F(WalletClientTest, SendAutocheckoutStatusOfFailure) {
delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
+ std::vector<AutocheckoutStatistic> statistics;
wallet_client_->SendAutocheckoutStatus(autofill::CANNOT_PROCEED,
GURL(kMerchantUrl),
+ statistics,
"google_transaction_id");
VerifyAndFinishRequest(net::HTTP_OK,
kSendAutocheckoutStatusOfFailureValidRequest,