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

Side by Side Diff: chrome/common/net/gaia/oauth2_revocation_fetcher.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_revocation_fetcher.h" 5 #include "chrome/common/net/gaia/oauth2_revocation_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 state_ = REVOCATION_STARTED; 98 state_ = REVOCATION_STARTED;
99 fetcher_.reset(CreateFetcher( 99 fetcher_.reset(CreateFetcher(
100 getter_, 100 getter_,
101 MakeRevocationUrl(), 101 MakeRevocationUrl(),
102 MakeRevocationHeader(access_token_), 102 MakeRevocationHeader(access_token_),
103 MakeRevocationBody(client_id_, origin_), 103 MakeRevocationBody(client_id_, origin_),
104 this)); 104 this));
105 fetcher_->Start(); // OnURLFetchComplete will be called. 105 fetcher_->Start(); // OnURLFetchComplete will be called.
106 } 106 }
107 107
108 void OAuth2RevocationFetcher::EndRevocation(const URLFetcher* source) { 108 void OAuth2RevocationFetcher::EndRevocation(const net::URLFetcher* source) {
109 CHECK_EQ(REVOCATION_STARTED, state_); 109 CHECK_EQ(REVOCATION_STARTED, state_);
110 state_ = REVOCATION_DONE; 110 state_ = REVOCATION_DONE;
111 111
112 URLRequestStatus status = source->GetStatus(); 112 URLRequestStatus status = source->GetStatus();
113 if (!status.is_success()) { 113 if (!status.is_success()) {
114 OnRevocationFailure(CreateAuthError(status)); 114 OnRevocationFailure(CreateAuthError(status));
115 return; 115 return;
116 } 116 }
117 117
118 if (source->GetResponseCode() != net::HTTP_NO_CONTENT) { 118 if (source->GetResponseCode() != net::HTTP_NO_CONTENT) {
119 OnRevocationFailure(GoogleServiceAuthError( 119 OnRevocationFailure(GoogleServiceAuthError(
120 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); 120 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
121 return; 121 return;
122 } 122 }
123 123
124 OnRevocationSuccess(); 124 OnRevocationSuccess();
125 } 125 }
126 126
127 void OAuth2RevocationFetcher::OnRevocationSuccess() { 127 void OAuth2RevocationFetcher::OnRevocationSuccess() {
128 consumer_->OnRevocationSuccess(); 128 consumer_->OnRevocationSuccess();
129 } 129 }
130 130
131 void OAuth2RevocationFetcher::OnRevocationFailure( 131 void OAuth2RevocationFetcher::OnRevocationFailure(
132 const GoogleServiceAuthError& error) { 132 const GoogleServiceAuthError& error) {
133 state_ = ERROR_STATE; 133 state_ = ERROR_STATE;
134 consumer_->OnRevocationFailure(error); 134 consumer_->OnRevocationFailure(error);
135 } 135 }
136 136
137 void OAuth2RevocationFetcher::OnURLFetchComplete(const URLFetcher* source) { 137 void OAuth2RevocationFetcher::OnURLFetchComplete(
138 const net::URLFetcher* source) {
138 CHECK(source); 139 CHECK(source);
139 EndRevocation(source); 140 EndRevocation(source);
140 } 141 }
141 142
142 // static 143 // static
143 GURL OAuth2RevocationFetcher::MakeRevocationUrl() { 144 GURL OAuth2RevocationFetcher::MakeRevocationUrl() {
144 return GURL(kOAuth2RevokeTokenURL); 145 return GURL(kOAuth2RevokeTokenURL);
145 } 146 }
146 147
147 // static 148 // static
148 std::string OAuth2RevocationFetcher::MakeRevocationHeader( 149 std::string OAuth2RevocationFetcher::MakeRevocationHeader(
149 const std::string& access_token) { 150 const std::string& access_token) {
150 return StringPrintf(kAuthorizationHeaderFormat, access_token.c_str()); 151 return StringPrintf(kAuthorizationHeaderFormat, access_token.c_str());
151 } 152 }
152 153
153 // static 154 // static
154 std::string OAuth2RevocationFetcher::MakeRevocationBody( 155 std::string OAuth2RevocationFetcher::MakeRevocationBody(
155 const std::string& client_id, 156 const std::string& client_id,
156 const std::string& origin) { 157 const std::string& origin) {
157 std::string enc_client_id = net::EscapeUrlEncodedData(client_id, true); 158 std::string enc_client_id = net::EscapeUrlEncodedData(client_id, true);
158 std::string enc_origin = net::EscapeUrlEncodedData(origin, true); 159 std::string enc_origin = net::EscapeUrlEncodedData(origin, true);
159 return StringPrintf( 160 return StringPrintf(
160 kRevocationBodyFormat, 161 kRevocationBodyFormat,
161 enc_client_id.c_str(), 162 enc_client_id.c_str(),
162 enc_origin.c_str()); 163 enc_origin.c_str());
163 } 164 }
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/oauth2_revocation_fetcher.h ('k') | chrome/service/cloud_print/cloud_print_auth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698