OLD | NEW |
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/service/cloud_print/cloud_print_url_fetcher.h" | 5 #include "chrome/service/cloud_print/cloud_print_url_fetcher.h" |
6 | 6 |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/service/cloud_print/cloud_print_consts.h" | 9 #include "chrome/service/cloud_print/cloud_print_consts.h" |
10 #include "chrome/service/cloud_print/cloud_print_helpers.h" | 10 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 ++num_retries_; | 117 ++num_retries_; |
118 if ((-1 != source->GetMaxRetries()) && | 118 if ((-1 != source->GetMaxRetries()) && |
119 (num_retries_ > source->GetMaxRetries())) { | 119 (num_retries_ > source->GetMaxRetries())) { |
120 // Retry limit reached. Give up. | 120 // Retry limit reached. Give up. |
121 delegate_->OnRequestGiveUp(); | 121 delegate_->OnRequestGiveUp(); |
122 } else { | 122 } else { |
123 // Either no retry limit specified or retry limit has not yet been | 123 // Either no retry limit specified or retry limit has not yet been |
124 // reached. Try again. Set up the request headers again because the token | 124 // reached. Try again. Set up the request headers again because the token |
125 // may have changed. | 125 // may have changed. |
126 SetupRequestHeaders(); | 126 SetupRequestHeaders(); |
127 request_->StartWithRequestContextGetter(GetRequestContextGetter()); | 127 request_->SetRequestContext(GetRequestContextGetter()); |
| 128 request_->Start(); |
128 } | 129 } |
129 } | 130 } |
130 } | 131 } |
131 | 132 |
132 void CloudPrintURLFetcher::StartRequestHelper( | 133 void CloudPrintURLFetcher::StartRequestHelper( |
133 const GURL& url, | 134 const GURL& url, |
134 content::URLFetcher::RequestType request_type, | 135 content::URLFetcher::RequestType request_type, |
135 Delegate* delegate, | 136 Delegate* delegate, |
136 int max_retries, | 137 int max_retries, |
137 const std::string& post_data_mime_type, | 138 const std::string& post_data_mime_type, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 171 |
171 net::URLRequestContextGetter* CloudPrintURLFetcher::GetRequestContextGetter() { | 172 net::URLRequestContextGetter* CloudPrintURLFetcher::GetRequestContextGetter() { |
172 ServiceURLRequestContextGetter* getter = | 173 ServiceURLRequestContextGetter* getter = |
173 g_service_process->GetServiceURLRequestContextGetter(); | 174 g_service_process->GetServiceURLRequestContextGetter(); |
174 // Now set up the user agent for cloudprint. | 175 // Now set up the user agent for cloudprint. |
175 std::string user_agent = getter->user_agent(); | 176 std::string user_agent = getter->user_agent(); |
176 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); | 177 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); |
177 getter->set_user_agent(user_agent); | 178 getter->set_user_agent(user_agent); |
178 return getter; | 179 return getter; |
179 } | 180 } |
OLD | NEW |