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

Side by Side Diff: components/autofill/core/browser/payments/payments_client.h

Issue 1859453002: components/autofill: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 26 matching lines...) Expand all
37 // on failure. 37 // on failure.
38 virtual void OnDidGetRealPan(AutofillClient::PaymentsRpcResult result, 38 virtual void OnDidGetRealPan(AutofillClient::PaymentsRpcResult result,
39 const std::string& real_pan) = 0; 39 const std::string& real_pan) = 0;
40 40
41 // Returns the legal message retrieved from Payments. On failure or not 41 // Returns the legal message retrieved from Payments. On failure or not
42 // meeting Payments's conditions for upload, |legal_message| will contain 42 // meeting Payments's conditions for upload, |legal_message| will contain
43 // nullptr. 43 // nullptr.
44 virtual void OnDidGetUploadDetails( 44 virtual void OnDidGetUploadDetails(
45 AutofillClient::PaymentsRpcResult result, 45 AutofillClient::PaymentsRpcResult result,
46 const base::string16& context_token, 46 const base::string16& context_token,
47 scoped_ptr<base::DictionaryValue> legal_message) = 0; 47 std::unique_ptr<base::DictionaryValue> legal_message) = 0;
48 48
49 // Returns the result of an upload request. 49 // Returns the result of an upload request.
50 virtual void OnDidUploadCard(AutofillClient::PaymentsRpcResult result) = 0; 50 virtual void OnDidUploadCard(AutofillClient::PaymentsRpcResult result) = 0;
51 }; 51 };
52 52
53 // PaymentsClient issues Payments RPCs and manages responses and failure 53 // PaymentsClient issues Payments RPCs and manages responses and failure
54 // conditions. Only one request may be active at a time. Initiating a new 54 // conditions. Only one request may be active at a time. Initiating a new
55 // request will cancel a pending request. 55 // request will cancel a pending request.
56 // Tests are located in 56 // Tests are located in
57 // src/components/autofill/content/browser/wallet/payments_client_unittest.cc. 57 // src/components/autofill/content/browser/wallet/payments_client_unittest.cc.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // GetUploadDetails has not already been made. 112 // GetUploadDetails has not already been made.
113 virtual void UploadCard(const UploadRequestDetails& details); 113 virtual void UploadCard(const UploadRequestDetails& details);
114 114
115 // Cancels and clears the current |request_|. 115 // Cancels and clears the current |request_|.
116 void CancelRequest(); 116 void CancelRequest();
117 117
118 private: 118 private:
119 // Initiates a Payments request using the state in |request|. If 119 // Initiates a Payments request using the state in |request|. If
120 // |authenticate| is true, ensures that an OAuth token is avialble first. 120 // |authenticate| is true, ensures that an OAuth token is avialble first.
121 // Takes ownership of |request|. 121 // Takes ownership of |request|.
122 void IssueRequest(scoped_ptr<PaymentsRequest> request, bool authenticate); 122 void IssueRequest(std::unique_ptr<PaymentsRequest> request,
123 bool authenticate);
123 124
124 // net::URLFetcherDelegate: 125 // net::URLFetcherDelegate:
125 void OnURLFetchComplete(const net::URLFetcher* source) override; 126 void OnURLFetchComplete(const net::URLFetcher* source) override;
126 127
127 // OAuth2TokenService::Consumer implementation. 128 // OAuth2TokenService::Consumer implementation.
128 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 129 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
129 const std::string& access_token, 130 const std::string& access_token,
130 const base::Time& expiration_time) override; 131 const base::Time& expiration_time) override;
131 void OnGetTokenFailure(const OAuth2TokenService::Request* request, 132 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
132 const GoogleServiceAuthError& error) override; 133 const GoogleServiceAuthError& error) override;
133 134
134 // Creates |url_fetcher_| based on the current state of |request_|. 135 // Creates |url_fetcher_| based on the current state of |request_|.
135 void InitializeUrlFetcher(); 136 void InitializeUrlFetcher();
136 137
137 // Initiates a new OAuth2 token request. 138 // Initiates a new OAuth2 token request.
138 void StartTokenFetch(bool invalidate_old); 139 void StartTokenFetch(bool invalidate_old);
139 140
140 // Adds the token to |url_fetcher_| and starts the request. 141 // Adds the token to |url_fetcher_| and starts the request.
141 void SetOAuth2TokenAndStartRequest(); 142 void SetOAuth2TokenAndStartRequest();
142 143
143 // The context for the request. 144 // The context for the request.
144 scoped_refptr<net::URLRequestContextGetter> context_getter_; 145 scoped_refptr<net::URLRequestContextGetter> context_getter_;
145 146
146 // Observer class that has its various On* methods called based on the results 147 // Observer class that has its various On* methods called based on the results
147 // of a Payments request. 148 // of a Payments request.
148 PaymentsClientDelegate* const delegate_; // must outlive |this|. 149 PaymentsClientDelegate* const delegate_; // must outlive |this|.
149 150
150 // The current request. 151 // The current request.
151 scoped_ptr<PaymentsRequest> request_; 152 std::unique_ptr<PaymentsRequest> request_;
152 153
153 // The fetcher being used to issue the current request. 154 // The fetcher being used to issue the current request.
154 scoped_ptr<net::URLFetcher> url_fetcher_; 155 std::unique_ptr<net::URLFetcher> url_fetcher_;
155 156
156 // The current OAuth2 token request object. 157 // The current OAuth2 token request object.
157 scoped_ptr<OAuth2TokenService::Request> access_token_request_; 158 std::unique_ptr<OAuth2TokenService::Request> access_token_request_;
158 159
159 // The OAuth2 token, or empty if not fetched. 160 // The OAuth2 token, or empty if not fetched.
160 std::string access_token_; 161 std::string access_token_;
161 162
162 // True if |request_| has already retried due to a 401 response from the 163 // True if |request_| has already retried due to a 401 response from the
163 // server. 164 // server.
164 bool has_retried_authorization_; 165 bool has_retried_authorization_;
165 166
166 base::WeakPtrFactory<PaymentsClient> weak_ptr_factory_; 167 base::WeakPtrFactory<PaymentsClient> weak_ptr_factory_;
167 168
168 DISALLOW_COPY_AND_ASSIGN(PaymentsClient); 169 DISALLOW_COPY_AND_ASSIGN(PaymentsClient);
169 }; 170 };
170 171
171 } // namespace payments 172 } // namespace payments
172 } // namespace autofill 173 } // namespace autofill
173 174
174 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_ 175 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_PAYMENTS_CLIENT_H_
OLDNEW
« no previous file with comments | « components/autofill/core/browser/name_field_unittest.cc ('k') | components/autofill/core/browser/payments/payments_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698