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

Unified Diff: chrome/service/cloud_print/cloud_print_url_fetcher.cc

Issue 8387011: Chrome proxy refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/service/cloud_print/cloud_print_url_fetcher.cc
===================================================================
--- chrome/service/cloud_print/cloud_print_url_fetcher.cc (revision 107156)
+++ chrome/service/cloud_print/cloud_print_url_fetcher.cc (working copy)
@@ -20,6 +20,10 @@
num_retries_(0) {
}
+bool CloudPrintURLFetcher::IsSameRequest(const content::URLFetcher* source) {
+ return (request_.get() == source);
+}
+
void CloudPrintURLFetcher::StartGetRequest(
const GURL& url,
Delegate* delegate,
@@ -65,15 +69,14 @@
source->GetResponseCode(),
source->GetCookies(),
data);
+
+ // If we get auth error, notify delegate and check if it wants to proceed.
+ if (action == CONTINUE_PROCESSING &&
+ source->GetResponseCode() == RC_FORBIDDEN) {
+ action = delegate_->OnRequestAuthError();
+ }
+
if (action == CONTINUE_PROCESSING) {
- // If we are not using an OAuth token, and we got an auth error, we are
- // done. Else, the token may have been refreshed. Let us try again.
- if ((RC_FORBIDDEN == source->GetResponseCode()) &&
- (!CloudPrintTokenStore::current() ||
- !CloudPrintTokenStore::current()->token_is_oauth())) {
- delegate_->OnRequestAuthError();
- return;
- }
// We need to retry on all network errors.
if (!source->GetStatus().is_success() || (source->GetResponseCode() != 200))
action = RETRY_REQUEST;
@@ -105,6 +108,12 @@
// be ignored.
request_->ReceivedContentWasMalformed();
+ // If we receive error code from the server "Media Type Not Supported",
+ // there is no reason to retry, request will never succeed.
+ // In that case we should call OnRequestGiveUp() right away.
+ if (source->GetResponseCode() == RC_UNSUPPORTED_MEDIA_TYPE)
+ num_retries_ = source->GetMaxRetries();
+
++num_retries_;
if ((-1 != source->GetMaxRetries()) &&
(num_retries_ > source->GetMaxRetries())) {
@@ -136,8 +145,8 @@
// Since we implement our own retry logic, disable the retry in URLFetcher.
request_->SetAutomaticallyRetryOn5xx(false);
request_->SetMaxRetries(max_retries);
+ delegate_ = delegate;
SetupRequestHeaders();
- delegate_ = delegate;
if (request_type == URLFetcher::POST) {
request_->SetUploadData(post_data_mime_type, post_data);
}
@@ -146,14 +155,9 @@
}
void CloudPrintURLFetcher::SetupRequestHeaders() {
- std::string headers;
- CloudPrintTokenStore* token_store = CloudPrintTokenStore::current();
- if (token_store) {
- headers = token_store->token_is_oauth() ?
- "Authorization: OAuth " : "Authorization: GoogleLogin auth=";
- headers += token_store->token();
+ std::string headers = delegate_->GetAuthHeader();
+ if (!headers.empty())
headers += "\r\n";
- }
headers += kChromeCloudPrintProxyHeader;
if (!additional_headers_.empty()) {
headers += "\r\n";
« no previous file with comments | « chrome/service/cloud_print/cloud_print_url_fetcher.h ('k') | chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698