| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/content/browser/wallet/wallet_client.h" | 5 #include "components/autofill/content/browser/wallet/wallet_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 484 |
| 485 std::string post_body; | 485 std::string post_body; |
| 486 base::JSONWriter::Write(&request_dict, &post_body); | 486 base::JSONWriter::Write(&request_dict, &post_body); |
| 487 | 487 |
| 488 MakeWalletRequest(GetGetWalletItemsUrl(), post_body, kJsonMimeType); | 488 MakeWalletRequest(GetGetWalletItemsUrl(), post_body, kJsonMimeType); |
| 489 } | 489 } |
| 490 | 490 |
| 491 void WalletClient::SendAutocheckoutStatus( | 491 void WalletClient::SendAutocheckoutStatus( |
| 492 AutocheckoutStatus status, | 492 AutocheckoutStatus status, |
| 493 const GURL& source_url, | 493 const GURL& source_url, |
| 494 const std::vector<AutocheckoutStatistic>& latency_statistics, | |
| 495 const std::string& google_transaction_id) { | 494 const std::string& google_transaction_id) { |
| 496 DVLOG(1) << "Sending Autocheckout Status: " << status | 495 DVLOG(1) << "Sending Autocheckout Status: " << status |
| 497 << " for: " << source_url; | 496 << " for: " << source_url; |
| 498 if (HasRequestInProgress()) { | 497 if (HasRequestInProgress()) { |
| 499 pending_requests_.push(base::Bind(&WalletClient::SendAutocheckoutStatus, | 498 pending_requests_.push(base::Bind(&WalletClient::SendAutocheckoutStatus, |
| 500 base::Unretained(this), | 499 base::Unretained(this), |
| 501 status, | 500 status, |
| 502 source_url, | 501 source_url, |
| 503 latency_statistics, | |
| 504 google_transaction_id)); | 502 google_transaction_id)); |
| 505 return; | 503 return; |
| 506 } | 504 } |
| 507 | 505 |
| 508 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); | 506 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); |
| 509 request_type_ = SEND_STATUS; | 507 request_type_ = SEND_STATUS; |
| 510 | 508 |
| 511 base::DictionaryValue request_dict; | 509 base::DictionaryValue request_dict; |
| 512 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); | 510 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); |
| 513 bool success = status == SUCCESS; | 511 bool success = status == SUCCESS; |
| 514 request_dict.SetBoolean(kSuccessKey, success); | 512 request_dict.SetBoolean(kSuccessKey, success); |
| 515 request_dict.SetString(kMerchantDomainKey, | 513 request_dict.SetString(kMerchantDomainKey, |
| 516 source_url.GetWithEmptyPath().spec()); | 514 source_url.GetWithEmptyPath().spec()); |
| 517 if (!success) | 515 if (!success) |
| 518 request_dict.SetString(kReasonKey, AutocheckoutStatusToString(status)); | 516 request_dict.SetString(kReasonKey, AutocheckoutStatusToString(status)); |
| 519 if (!latency_statistics.empty()) { | |
| 520 scoped_ptr<base::ListValue> latency_statistics_json( | |
| 521 new base::ListValue()); | |
| 522 for (size_t i = 0; i < latency_statistics.size(); ++i) { | |
| 523 latency_statistics_json->Append( | |
| 524 latency_statistics[i].ToDictionary().release()); | |
| 525 } | |
| 526 request_dict.Set(kAutocheckoutStepsKey, | |
| 527 latency_statistics_json.release()); | |
| 528 } | |
| 529 request_dict.SetString(kGoogleTransactionIdKey, google_transaction_id); | 517 request_dict.SetString(kGoogleTransactionIdKey, google_transaction_id); |
| 530 | 518 |
| 531 std::string post_body; | 519 std::string post_body; |
| 532 base::JSONWriter::Write(&request_dict, &post_body); | 520 base::JSONWriter::Write(&request_dict, &post_body); |
| 533 | 521 |
| 534 MakeWalletRequest(GetSendStatusUrl(), post_body, kJsonMimeType); | 522 MakeWalletRequest(GetSendStatusUrl(), post_body, kJsonMimeType); |
| 535 } | 523 } |
| 536 | 524 |
| 537 bool WalletClient::HasRequestInProgress() const { | 525 bool WalletClient::HasRequestInProgress() const { |
| 538 return request_; | 526 return request_; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 NOTREACHED(); | 821 NOTREACHED(); |
| 834 return AutofillMetrics::UNKNOWN_API_CALL; | 822 return AutofillMetrics::UNKNOWN_API_CALL; |
| 835 } | 823 } |
| 836 | 824 |
| 837 NOTREACHED(); | 825 NOTREACHED(); |
| 838 return AutofillMetrics::UNKNOWN_API_CALL; | 826 return AutofillMetrics::UNKNOWN_API_CALL; |
| 839 } | 827 } |
| 840 | 828 |
| 841 } // namespace wallet | 829 } // namespace wallet |
| 842 } // namespace autofill | 830 } // namespace autofill |
| OLD | NEW |