| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/autofill/wallet/wallet_client.h" | 5 #include "chrome/browser/autofill/wallet/wallet_client.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 request_dict.SetString("reason", AutocheckoutStatusToString(status)); | 237 request_dict.SetString("reason", AutocheckoutStatusToString(status)); |
| 238 } | 238 } |
| 239 request_dict.SetString("google_transaction_id", google_transaction_id); | 239 request_dict.SetString("google_transaction_id", google_transaction_id); |
| 240 | 240 |
| 241 std::string post_body; | 241 std::string post_body; |
| 242 base::JSONWriter::Write(&request_dict, &post_body); | 242 base::JSONWriter::Write(&request_dict, &post_body); |
| 243 | 243 |
| 244 MakeWalletRequest(GetSendStatusUrl(), post_body, observer, kJsonMimeType); | 244 MakeWalletRequest(GetSendStatusUrl(), post_body, observer, kJsonMimeType); |
| 245 } | 245 } |
| 246 | 246 |
| 247 bool WalletClient::IsRequestInProgress() const { |
| 248 return request_.get() != NULL; |
| 249 } |
| 250 |
| 247 void WalletClient::MakeWalletRequest(const GURL& url, | 251 void WalletClient::MakeWalletRequest(const GURL& url, |
| 248 const std::string& post_body, | 252 const std::string& post_body, |
| 249 WalletClientObserver* observer, | 253 WalletClientObserver* observer, |
| 250 const std::string& content_type) { | 254 const std::string& content_type) { |
| 251 DCHECK(!request_.get()) << "Tried to fetch two things at once!"; | 255 DCHECK(!IsRequestInProgress()) << "Tried to fetch two things at once!"; |
| 252 DCHECK(observer); | 256 DCHECK(observer); |
| 253 | 257 |
| 254 observer_ = observer; | 258 observer_ = observer; |
| 255 | 259 |
| 256 request_.reset(net::URLFetcher::Create( | 260 request_.reset(net::URLFetcher::Create( |
| 257 0, url, net::URLFetcher::POST, this)); | 261 0, url, net::URLFetcher::POST, this)); |
| 258 request_->SetRequestContext(context_getter_); | 262 request_->SetRequestContext(context_getter_); |
| 259 DVLOG(1) << "url=" << url << ", post_body=" << post_body | 263 DVLOG(1) << "url=" << url << ", post_body=" << post_body |
| 260 << ", content_type=" << content_type; | 264 << ", content_type=" << content_type; |
| 261 request_->SetUploadData(content_type, post_body); | 265 request_->SetUploadData(content_type, post_body); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 : context_getter_(context_getter), | 421 : context_getter_(context_getter), |
| 418 observer_(NULL), | 422 observer_(NULL), |
| 419 request_type_(NO_PENDING_REQUEST) { | 423 request_type_(NO_PENDING_REQUEST) { |
| 420 DCHECK(context_getter); | 424 DCHECK(context_getter); |
| 421 } | 425 } |
| 422 | 426 |
| 423 WalletClient::~WalletClient() {} | 427 WalletClient::~WalletClient() {} |
| 424 | 428 |
| 425 } // namespace wallet | 429 } // namespace wallet |
| 426 | 430 |
| OLD | NEW |