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

Side by Side Diff: chrome/common/net/gaia/oauth2_api_call_flow.cc

Issue 10386063: Move URLFetcherDelegate to net/ and split URLFetcher between net/ and content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head, fix win component build Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
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/common/net/gaia/oauth2_api_call_flow.h" 5 #include "chrome/common/net/gaia/oauth2_api_call_flow.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // If the access token is empty then directly try to mint one. 56 // If the access token is empty then directly try to mint one.
57 if (access_token_.empty()) { 57 if (access_token_.empty()) {
58 BeginMintAccessToken(); 58 BeginMintAccessToken();
59 } else { 59 } else {
60 state_ = API_CALL_STARTED; 60 state_ = API_CALL_STARTED;
61 url_fetcher_.reset(CreateURLFetcher()); 61 url_fetcher_.reset(CreateURLFetcher());
62 url_fetcher_->Start(); // OnURLFetchComplete will be called. 62 url_fetcher_->Start(); // OnURLFetchComplete will be called.
63 } 63 }
64 } 64 }
65 65
66 void OAuth2ApiCallFlow::EndApiCall(const URLFetcher* source) { 66 void OAuth2ApiCallFlow::EndApiCall(const net::URLFetcher* source) {
67 CHECK_EQ(API_CALL_STARTED, state_); 67 CHECK_EQ(API_CALL_STARTED, state_);
68 state_ = API_CALL_DONE; 68 state_ = API_CALL_DONE;
69 69
70 URLRequestStatus status = source->GetStatus(); 70 URLRequestStatus status = source->GetStatus();
71 if (!status.is_success()) { 71 if (!status.is_success()) {
72 state_ = ERROR_STATE; 72 state_ = ERROR_STATE;
73 ProcessApiCallFailure(source); 73 ProcessApiCallFailure(source);
74 return; 74 return;
75 } 75 }
76 76
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } else { 121 } else {
122 state_ = ERROR_STATE; 122 state_ = ERROR_STATE;
123 ProcessMintAccessTokenFailure(*error); 123 ProcessMintAccessTokenFailure(*error);
124 } 124 }
125 } 125 }
126 126
127 OAuth2AccessTokenFetcher* OAuth2ApiCallFlow::CreateAccessTokenFetcher() { 127 OAuth2AccessTokenFetcher* OAuth2ApiCallFlow::CreateAccessTokenFetcher() {
128 return new OAuth2AccessTokenFetcher(this, context_); 128 return new OAuth2AccessTokenFetcher(this, context_);
129 } 129 }
130 130
131 void OAuth2ApiCallFlow::OnURLFetchComplete(const URLFetcher* source) { 131 void OAuth2ApiCallFlow::OnURLFetchComplete(const net::URLFetcher* source) {
132 CHECK(source); 132 CHECK(source);
133 CHECK_EQ(API_CALL_STARTED, state_); 133 CHECK_EQ(API_CALL_STARTED, state_);
134 EndApiCall(source); 134 EndApiCall(source);
135 } 135 }
136 136
137 void OAuth2ApiCallFlow::OnGetTokenSuccess(const std::string& access_token) { 137 void OAuth2ApiCallFlow::OnGetTokenSuccess(const std::string& access_token) {
138 access_token_ = access_token; 138 access_token_ = access_token;
139 EndMintAccessToken(NULL); 139 EndMintAccessToken(NULL);
140 } 140 }
141 141
(...skipping 14 matching lines...) Expand all
156 result->SetRequestContext(context_); 156 result->SetRequestContext(context_);
157 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 157 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
158 net::LOAD_DO_NOT_SAVE_COOKIES); 158 net::LOAD_DO_NOT_SAVE_COOKIES);
159 result->AddExtraRequestHeader(MakeAuthorizationHeader(access_token_)); 159 result->AddExtraRequestHeader(MakeAuthorizationHeader(access_token_));
160 160
161 if (!empty_body) 161 if (!empty_body)
162 result->SetUploadData("application/x-www-form-urlencoded", body); 162 result->SetUploadData("application/x-www-form-urlencoded", body);
163 163
164 return result; 164 return result;
165 } 165 }
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/oauth2_api_call_flow.h ('k') | chrome/common/net/gaia/oauth2_api_call_flow_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698