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

Side by Side Diff: components/proximity_auth/cryptauth/cryptauth_api_call_flow.cc

Issue 738593002: Introduce CryptAuthClient, a class capable of performing all CryptAuth APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 6 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/proximity_auth/cryptauth/cryptauth_api_call_flow.h" 5 #include "components/proximity_auth/cryptauth/cryptauth_api_call_flow.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "net/url_request/url_fetcher.h" 8 #include "net/url_request/url_fetcher.h"
9 9
10 namespace proximity_auth { 10 namespace proximity_auth {
11 11
12 namespace { 12 namespace {
13 13
14 const char kNoResponseBodyError[] = "No response body"; 14 const char kNoResponseBodyError[] = "No response body";
15 const char kRequestFailedError[] = "Request failed"; 15 const char kRequestFailedError[] = "Request failed";
16 const char kHttpStatusErrorPrefix[] = "HTTP status: "; 16 const char kHttpStatusErrorPrefix[] = "HTTP status: ";
17 17
18 } // namespace 18 } // namespace
19 19
20 CryptAuthApiCallFlow::CryptAuthApiCallFlow(const GURL& request_url) 20 CryptAuthApiCallFlow::CryptAuthApiCallFlow(const GURL& request_url)
21 : request_url_(request_url) { 21 : request_url_(request_url) {
22 } 22 }
23 23
24 CryptAuthApiCallFlow::~CryptAuthApiCallFlow() { 24 CryptAuthApiCallFlow::~CryptAuthApiCallFlow() {
25 } 25 }
26 26
27 void CryptAuthApiCallFlow::Start(net::URLRequestContextGetter* context, 27 void CryptAuthApiCallFlow::Start(net::URLRequestContextGetter* context,
28 const std::string& access_token, 28 const std::string& access_token,
29 const std::string& serialized_request, 29 const std::string& serialized_request,
30 ResultCallback result_callback, 30 const ResultCallback& result_callback,
31 ErrorCallback error_callback) { 31 const ErrorCallback& error_callback) {
32 serialized_request_ = serialized_request; 32 serialized_request_ = serialized_request;
33 result_callback_ = result_callback; 33 result_callback_ = result_callback;
34 error_callback_ = error_callback; 34 error_callback_ = error_callback;
35 OAuth2ApiCallFlow::Start(context, access_token); 35 OAuth2ApiCallFlow::Start(context, access_token);
36 } 36 }
37 37
38 GURL CryptAuthApiCallFlow::CreateApiCallUrl() { 38 GURL CryptAuthApiCallFlow::CreateApiCallUrl() {
39 return request_url_; 39 return request_url_;
40 } 40 }
41 41
(...skipping 22 matching lines...) Expand all
64 if (source->GetStatus().status() == net::URLRequestStatus::SUCCESS) { 64 if (source->GetStatus().status() == net::URLRequestStatus::SUCCESS) {
65 error_message = 65 error_message =
66 kHttpStatusErrorPrefix + base::IntToString(source->GetResponseCode()); 66 kHttpStatusErrorPrefix + base::IntToString(source->GetResponseCode());
67 } else { 67 } else {
68 error_message = kRequestFailedError; 68 error_message = kRequestFailedError;
69 } 69 }
70 error_callback_.Run(error_message); 70 error_callback_.Run(error_message);
71 } 71 }
72 72
73 } // proximity_auth 73 } // proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/cryptauth/cryptauth_api_call_flow.h ('k') | components/proximity_auth/cryptauth/cryptauth_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698